Beispiel #1
0
 public static void ClassCleanup()
 {
     using (var dbContext = new ValidationDbContext())
     {
         if (dbContext.Database.Exists())
         {
             dbContext.Database.Delete();
         }
     }
 }
Beispiel #2
0
        public static void ClassInitialize(TestContext context)
        {
            using (var dbContext = new ValidationDbContext())
            {
                if (dbContext.Database.Exists())
                {
                    dbContext.Database.Delete();
                }

                dbContext.Database.Initialize(true);
            }
        }
Beispiel #3
0
        public void 新增Member時_若MemberLogs不存在_調用DbContext_Save_應預期得到例外()
        {
            using (var dbContext = new ValidationDbContext())
            {
                var id         = Guid.NewGuid();
                var memberToDb = new Member
                {
                    Id = id
                };


                dbContext.Members
                .Add(memberToDb);

                Action action = () => { dbContext.SaveChanges(); };
                action.Should().Throw <DbEntityValidationException>();
            }
        }