本文整理汇总了C#中Results.Read方法的典型用法代码示例。如果您正苦于以下问题:C# Results.Read方法的具体用法?C# Results.Read怎么用?C# Results.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Results
的用法示例。
在下文中一共展示了Results.Read方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: should_throw_if_read_attempted_after_all_results_have_been_read
public void should_throw_if_read_attempted_after_all_results_have_been_read()
{
// Arrange
var reader = SetupPersonTable().CreateDataReader();
var results = new Results(reader);
results.Read<MockPerson>();
// Act & Assert
Assert.Throws<ResultsException>(() => results.Read<MockPerson>());
}
示例2: should_advance_to_next_result_after_every_read
public void should_advance_to_next_result_after_every_read()
{
// Arrange
var mockReader = new Mock<IDataReader>();
mockReader.Setup(reader => reader.Read()).Returns(false);
var results = new Results(mockReader.Object);
results.Read<dynamic>();
mockReader.Verify(reader => reader.NextResult(), Times.Once());
}
示例3: should_read_result
public void should_read_result()
{
// Arrange
var reader = SetupPersonTable().CreateDataReader();
var results = new Results(reader);
// Act
var objects = results.Read<MockPerson>();
// Assert
Assert.That(objects.Length, Is.EqualTo(2));
Assert.That(objects[0].Name, Is.EqualTo("John Doe"));
Assert.That(objects[1].Name, Is.EqualTo("Jane Doe"));
}
示例4: should_automatically_dispose_reader_after_all_results_have_been_read
public void should_automatically_dispose_reader_after_all_results_have_been_read()
{
// Arrange
var mockReader = new Mock<IDataReader>();
mockReader.Setup(reader => reader.FieldCount).Returns(2);
mockReader.Setup(reader => reader.GetName(0)).Returns("Name");
mockReader.Setup(reader => reader["Name"]).Returns("John Doe");
mockReader.Setup(reader => reader.GetName(1)).Returns("Age");
mockReader.Setup(reader => reader["Age"]).Returns(21);
var results = new Results(mockReader.Object);
// Act
results.Read<MockPerson>();
// Assert
mockReader.Verify(mdr => mdr.Dispose(), Times.Once());
}