Beispiel #1
0
        public void ExecuteQuery_IncorrectQuery_ReturnNull()
        {
            var query = "select top 1 * test111";

            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(outResult, count) = client.ExecuteQuery(query);

            count.Should().Be(0);
        }
Beispiel #2
0
        public void ExecuteQuery_CorrectQuery_ReturnTable()
        {
            var query = "select top 1 * from test111";

            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(outResult, count) = client.ExecuteQuery(query);

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