public void StubDataReader_FieldCount_Success() { var result1 = new StubResultSet("col6", "col7", "col8"); var result2 = new StubResultSet("col9", "col0"); using (var reader = new StubDataReader(result1, result2)) { Assert.IsNotNull(reader, "The StubDataReader object should not have been null"); Assert.AreEqual(3, reader.FieldCount, "The field count for the first result set was incorrect"); reader.NextResult(); Assert.AreEqual(2, reader.FieldCount, "The field count for the second result was incorrect"); } }
public void StubDataReader_CurrentResultSet_NextResult_Failure() { using (var reader = new StubDataReader()) { Assert.IsNotNull(reader, "The StubDataReader object should not have been null"); Assert.IsFalse(reader.NextResult(), "NextResult() should not have had data"); try { var results = reader.CurrentResultSet; Assert.Fail("Call to CurrentResultSet should have thrown an exception"); } catch (InvalidOperationException exception) { Assert.AreEqual("Current ResultSet is at EOF", exception.Message, "Unexpected EOF exception message"); } } }
public void StubDataReader_CurrentResultSet_NextResult_Success() { var result1 = new StubResultSet("col1", "col2", "col3"); var result2 = new StubResultSet("col4", "col5"); using (var reader = new StubDataReader(result1, result2)) { Assert.IsNotNull(reader, "The StubDataReader object should not have been null"); var currentSet = reader.CurrentResultSet; Assert.IsNotNull(currentSet, "First call to CurrentResultSet should not have returned null"); Assert.AreEqual(result1, currentSet, "First call to CurrentResultSet did not return the first set"); Assert.IsTrue(reader.NextResult(), "First call to NextResult() should have had data"); currentSet = reader.CurrentResultSet; Assert.IsNotNull(currentSet, "Second call to CurrentResultSet should not have returned null"); Assert.AreEqual(result2, currentSet, "Second call to CurrentResultSet did not return the second set"); } }