Beispiel #1
0
        public void ExecuteNonQuery_IncorrectQuery_ReturnNull()
        {
            var query = "INSERT INTO test111 f1 VALUES (10)";

            var mockSqlProvider = new Mock <ISqlProvider>();
            var connect         = new SqlConnection();

            var client = new SqlServerClient();

            mockSqlProvider.Setup(c => c.SetupCommand(It.IsAny <string>(), null)).Returns(connect.CreateCommand);

            client._provider = mockSqlProvider.Object;
            var count = client.ExecuteNonQuery(query);

            count.Should().Be(0);
        }
Beispiel #2
0
        public void ExecuteNonQuery_CorrectQuery_ReturnTable()
        {
            var query = "INSERT INTO test111 (f1) VALUES (1)";

            var mockSqlProvider = new Mock <ISqlProvider>();

            var client = new SqlServerClient();

            mockSqlProvider
            .Setup(u => u.UsingTransaction(It.IsAny <Action <SqlTransaction> >(), It.IsAny <Action <Exception> >(), null))
            .Callback((Action <SqlTransaction> action, Action <Exception> ex, Action success) => new DataTable());

            client._provider = mockSqlProvider.Object;

            var count = client.ExecuteNonQuery(query);

            count.Should().Be(0); //TODO (not 0)
        }