public async Task DeleteFailsWhenIdNotInDatabase() { AutoMapperInitializer.InitializeMapper(); var context = InMemoryDbContextInitializer.InitializeContext(); var repository = new EfDeletableEntityRepository <JobLevel>(context); var service = new JobLevelsService(repository); var result = await service.DeleteAsync(100); Assert.False(result); }
public async Task DeleteMarksRecordAsDeleted() { AutoMapperInitializer.InitializeMapper(); var context = InMemoryDbContextInitializer.InitializeContext(); await context.JobLevels.AddAsync(new JobLevel { Id = 1, Name = "Sector", IsDeleted = false }); await context.SaveChangesAsync(); var repository = new EfDeletableEntityRepository <JobLevel>(context); var service = new JobLevelsService(repository); var result = await service.DeleteAsync(1); var dbRecord = await context.JobLevels.FindAsync(1); Assert.True(result); Assert.True(dbRecord.IsDeleted); Assert.NotNull(dbRecord.DeletedOn); Assert.Equal(1, context.JobLevels.IgnoreQueryFilters().Count()); }