Beispiel #1
0
        public void ShouldExecuteBatch()
        {
            var sut = new SqlServerConnection("Data Source=.;Initial Catalog=DbSessionTests;Integrated Security=True;");

            sut.ExecuteBatch("INSERT INTO TestTable VALUES(@Id, @Value)", new []
            {
                new ParameterSet {
                    new Parameter <int>("Id", 79), new Parameter <int>("Value", 79)
                },
                new ParameterSet {
                    new Parameter <int>("Id", 80), new Parameter <int>("Value", 80)
                }
            });

            using (var connection = new SqlConnection("Data Source=.;Initial Catalog=DbSessionTests;Integrated Security=True;"))
            {
                var command = connection.CreateCommand();
                command.CommandText = "SELECT TestValue FROM TestTable WHERE Id = 79";
                connection.Open();
                var result = int.Parse(command.ExecuteScalar().ToString());

                Assert.That(result, Is.EqualTo(79));

                command.CommandText = "SELECT TestValue FROM TestTable WHERE Id = 80";
                result = int.Parse(command.ExecuteScalar().ToString());

                Assert.That(result, Is.EqualTo(80));
            }
        }