public void TestDeleteMediaNull(int testId) { // Arrange var options = BuildTestDbOptions(); int expected; // Act using (var context = new ApplicationDbContext(options)) { context.Database.EnsureCreated(); var repository = new MediaRepository(context); expected = context.Media.ToList().Count; var testObject = context.Media.FirstOrDefault(m => m.Id == testId); repository.DeleteMedia(testObject); } // Assert using (var context = new ApplicationDbContext(options)) { var actual = context.Media.ToList().Count; Assert.Equal(expected, actual); context.Database.EnsureDeleted(); } }
public void TestDeleteMediaNonNullObject(int testId) { // Arrange var options = BuildTestDbOptions(); // Act using (var context = new ApplicationDbContext(options)) { context.Database.EnsureCreated(); var repository = new MediaRepository(context); var testObject = context.Media.FirstOrDefault(m => m.Id == testId); repository.DeleteMedia(testObject); } // Assert using (var context = new ApplicationDbContext(options)) { var results = context.Media.ToList(); Assert.DoesNotContain(results, m => m.Id == testId); context.Database.EnsureDeleted(); } }