public void UnitTest4() { var conn = new MockDbConnection(); conn.Mocks .WhenTag("COUNT_EMPLOYEES") .ReturnsTable(MockTable.SingleCell("Count", 14)); int count = GetNumberOfEmployees(conn); Assert.AreEqual(14, count); }
public void UnitTest5() { var conn = new MockDbConnection(); conn.Mocks .WhenTag("COUNT_EMPLOYEES") .ReturnsTable(cmd => MockTable.SingleCell("Count", cmd.Parameters.Count())); int count = GetNumberOfEmployees(conn); Assert.AreEqual(0, count); }
public void Mock_ReturnsScalar_MockTableSingleWithoutColumnName_Test() { var conn = new MockDbConnection(); var table = MockTable.SingleCell(11); conn.Mocks .WhenAny() .ReturnsTable(table); DbCommand cmd = conn.CreateCommand(); object result = cmd.ExecuteScalar(); Assert.AreEqual(11, result); }