public async Task UpdateAsync_WithNonExistentWorkExperience_ReturnsFalse() { var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var serviceModel = new WorkExperienceServiceModel() { Position = "NewTest", Institute = "InstituteTest", From = 2000, To = 2001, }; var workService = new WorkHistoryService(new EfRepository <Resume>(context), new EfRepository <WorkExperience>(context)); var result = await workService.UpdateAsync(serviceModel); Assert.False(result); }
public async Task UpdateAsync_WithValidData_ReturnsTrue() { string expectedResult = "NewPosition"; var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var model = new WorkExperience() { Position = "PositionTest", Institute = "InstituteTest", From = 2000, To = 2001, }; await context.AddAsync(model); context.SaveChanges(); var serviceModel = new WorkExperienceServiceModel() { Id = model.Id, Position = expectedResult, Institute = "InstituteTest", From = 2000, To = 2001, }; var workService = new WorkHistoryService(new EfRepository <Resume>(context), new EfRepository <WorkExperience>(context)); var result = await workService.UpdateAsync(serviceModel); Assert.True(result); var actualResult = (await context.WorksHistory.SingleAsync(w => w.Id == model.Id)).Position; Assert.Equal(expectedResult, actualResult); }