public async Task UpdateCarHelpEntry_Invoke() { var carHelpEntry = new CarHelpEntry { Id = Guid.NewGuid() }; var dto = new UpdateCarHelpEntryRequestDto { CarHelpId = carHelpEntry.Id.ToString(), Description = "test" }; var carHelpEntries = new List <CarHelpEntry> { carHelpEntry }.AsQueryable(); var mockCarSet = FakeDbSetFactory <CarHelpEntry> .Get(carHelpEntries); _fakeDb.Setup(m => m.GetSet <CarHelpEntry>()).Returns(mockCarSet.Object); _sut = new CarHelpEntryService(_fakeDb.Object); await _sut.UpdateCarHelpEntry(dto); _fakeDb.Verify(v => v.GetSet <CarHelpEntry>()); _fakeDb.Verify(v => v.SaveDbAsync()); carHelpEntry.Description.Should().Be(dto.Description); }
public async Task UpdateCarHelpEntry(UpdateCarHelpEntryRequestDto request) { var carHelpEntrySet = _dataService.GetSet <CarHelpEntry>(); var carHelpEntry = await carHelpEntrySet .Include(x => x.Employee) .FirstOrDefaultAsync(x => x.Id.ToString() == request.CarHelpId); if (carHelpEntry == null) { throw new InvalidCarHelpEntryIdException(); } carHelpEntry.Description = request.Description; carHelpEntry.Price = request.Price; carHelpEntry.Name = request.Name; carHelpEntry.Status = request.Status; carHelpEntry.Updated = DateTime.UtcNow; await _dataService.SaveDbAsync(); }