public void TestDeletePrincipal() { //SETUP var options = SqliteInMemory.CreateOptions <Chapter06Context>(); using var context = new Chapter06Context(options); context.Database.EnsureCreated(); context.Add(new OnePrincipal { Link = new OneDependent() }); context.SaveChanges(); context.ChangeTracker.Clear(); //ATTEMPT var depToRemove = new OnePrincipal { Id = 1 }; context.Remove(depToRemove); context.SaveChanges(); //VERIFY context.OneDependents.Count().ShouldEqual(0); context.OnePrincipals.Count().ShouldEqual(0); }
public void TestMissingIncludeNotSafeOk() { //SETUP var options = SqliteInMemory.CreateOptions <Chapter06Context>(); using var context = new Chapter06Context(options); context.Database.EnsureCreated(); var bookSetup = new BookNotSafe(); bookSetup.Reviews.Add(new ReviewNotSafe()); context.Add(bookSetup); context.SaveChanges(); context.ChangeTracker.Clear(); //ATTEMPT var book = context.Books //#A //... missing Include(x => x.Reviews) //#B .First(x => x.Reviews.Any()); //VERIFY book.Reviews.ShouldNotBeNull(); }