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