Пример #1
0
        public void HaveCorrectThreeDeleteQueries()
        {
            const string expectedQuery_0 = "DELETE FROM [Foo] WHERE [IdRow] IN (@P1,@P2,@P3,@P4,@P5,@P6,@P7,@P8,@P9,@P10)";
            const string expectedQuery_1 = "DELETE FROM [Foo] WHERE [IdRow] IN (@P1,@P2,@P3,@P4,@P5,@P6,@P7,@P8,@P9,@P10)";
            const string expectedQuery_2 = "DELETE FROM [Foo] WHERE [IdRow] IN (@P1,@P2,@P3,@P4,@P5)";

            int[] expectedParameters_0 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            int[] expectedParameters_1 = { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
            int[] expectedParameters_2 = { 21, 22, 23, 24, 25 };

            CommandGenerator <Foo> generator = GetFooGenerator();

            generator.MaxParametersForDeleteCommandsInPart = 10;

            var result = generator.GetDeleteCommands(Enumerable.Range(1, 25)).ToList();

            result.Should().HaveCount(3);
            result[0].CommandText.Should().Be(expectedQuery_0);
            result[1].CommandText.Should().Be(expectedQuery_1);
            result[2].CommandText.Should().Be(expectedQuery_2);

            GetParameterValues <int>(result[0].Parameters).Should().Equal(expectedParameters_0);
            GetParameterValues <int>(result[1].Parameters).Should().Equal(expectedParameters_1);
            GetParameterValues <int>(result[2].Parameters).Should().Equal(expectedParameters_2);
        }