コード例 #1
0
        public void RequireDbContextHandler_ExceptionThrownInTransaction_DbRollback()
        {
            Assert.Throws <InvalidOperationException>(() => RepoB.AddItemException());

            Assert.False(DbContextFactory.IsOpen());

            DbContextTemplate.ExecuteQuery <TestDbContext>(ctx => Assert.Empty(Items));

            Assert.False(DbContextFactory.IsOpen());
        }
コード例 #2
0
        public void RequireDbContextHandler_AddItem_ItemCreated()
        {
            RepoB.AddItem();

            Assert.False(DbContextFactory.IsOpen());

            DbContextTemplate.ExecuteQuery <TestDbContext>(ctx => Assert.Equal("testitem", Items.Single().Name));

            Assert.False(DbContextFactory.IsOpen());
        }
コード例 #3
0
        public void RequireDbContextHandler_ModifyDbWithoutRequireDb_ExceptionThrown()
        {
            var ex = Assert.Throws <InvalidOperationException>(() => RepoB.AddItemWithNoTransaction());

            Assert.Equal($"Detected dbcontext is changed by method AddItemWithNoTransaction at class {typeof(RepoB).FullName}, but transaction is not opened.", ex.Message);
        }
コード例 #4
0
 public void RequireDbContextHandler_NormalQuery_ResultReceived()
 {
     DbContextTemplate.ExecuteQuery <TestDbContext>(ctx => Assert.Equal(0, RepoB.CountItems()));
 }