public async Task UpdateAsyncCorrectlyUpdatesInformation() { AutoMapperInitializer.InitializeMapper(); var context = InMemoryDbContextInitializer.InitializeContext(); await context.ApplicationStatuses.AddRangeAsync(this.SeedData()); await context.SaveChangesAsync(); var repository = new EfDeletableEntityRepository <JobApplicationStatus>(context); var service = new JobApplicationStatusesService(repository); var model = new EditViewModel { Name = "NewName", IsDeleted = true, }; var result = await service.UpdateAsync(1, model); Assert.NotEqual(-1, result); var dbRecord = await context.ApplicationStatuses.FindAsync(1); Assert.NotEqual("First", dbRecord.Name); Assert.NotNull(dbRecord.DeletedOn); Assert.True(dbRecord.IsDeleted); }
public async Task UpdateAsyncFailsWhenIdNotInDb() { AutoMapperInitializer.InitializeMapper(); var context = InMemoryDbContextInitializer.InitializeContext(); var repository = new EfDeletableEntityRepository <JobApplicationStatus>(context); var service = new JobApplicationStatusesService(repository); var model = new EditViewModel { Name = "NewName", IsDeleted = true, }; var result = await service.UpdateAsync(100, model); Assert.Equal(-1, result); }