public void SomethingElsePersistence_DeleteSomethingElseById_DeletionCascades() { int id = 1; List <int> childIds; var something1 = new Domain.Something() { Name = "Bob" }; Domain.SomethingElse somethingElse1 = Domain.SomethingElse.CreateNamedSomethingElse("Fred Bloggs"); using (var ctx = new DbContextFactory().CreateAppDbContext(nameof(SomethingElsePersistence_DeleteSomethingElseById_DeletionCascades))) { var persistence = new SomethingElsePersistence(ctx); persistence.SaveSomethingElse(somethingElse1); var updatedSomethingElse = persistence.UpdateSomethingElseByIdAddSomething(somethingElse1.Id, something1); var somethingElse = ctx.SomethingElses.Include(s => s.Somethings).Where(r => r.Id == id).FirstOrDefault(); childIds = somethingElse.Somethings.Select(c => c.Id).ToList(); ctx.Remove(somethingElse); ctx.SaveChanges(); } using (var ctx = new DbContextFactory().CreateAppDbContext(nameof(SomethingElsePersistence_DeleteSomethingElseById_DeletionCascades))) { Assert.Empty(ctx.Somethings.Where(c => childIds.Contains(c.Id))); }; }
public void SomethingElseFactory_Create_CreatesSomethingElseWithName() { SomethingElseFactory factory = new SomethingElseFactory(); string expected = "Fred Bloggs"; Domain.SomethingElse actual = factory.Create(expected); Assert.IsType <Domain.SomethingElse>(actual); Assert.Equal(expected, actual.Name); }