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

            sut.ExecuteOnTransaction("INSERT INTO TestTable VALUES(4, @Value)", new ParameterSet {
                new Parameter <int>("Value", 7)
            });
            sut.RollBack();

            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 = 4";
                connection.Open();
                var result = command.ExecuteScalar();

                Assert.That(result, Is.Null);
            }
        }