Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }