public void CreateHistoryNote_Calls_Insert_In_Repo() { var dto = new HistoryNoteDto(); historyNoteService.CreateHistoryNote(dto); mockRepo.Verify(r => r.Insert(It.IsAny <HistoryNoteEntity>()), Times.Once); }
public HistoryNoteDto CreateHistoryNote(HistoryNoteDto historyNoteDto) { var historyNoteToInsert = _mapper.Map <HistoryNoteEntity>(historyNoteDto); var historyNote = _historyNoteRepository.Insert(historyNoteToInsert); return(_mapper.Map <HistoryNoteDto>(historyNote)); }
public void CreateHistoryNote_Returns_HistoryNoteDto() { var entity = new HistoryNoteEntity(); var dto = new HistoryNoteDto(); mockRepo.Setup(r => r.Insert(It.IsAny <HistoryNoteEntity>())) .Returns(entity); mockMapper.Setup(m => m.Map <HistoryNoteDto>(entity)).Returns(dto); var actual = historyNoteService.CreateHistoryNote(dto); Assert.AreEqual(dto, actual); }
public void CreateHistoryNote_Inserts_HistoryNote() { var entity = new HistoryNoteEntity(); var dto = new HistoryNoteDto(); mockRepo.Setup(r => r.GetById(It.IsAny <Guid>())) .Returns(entity); mockMapper.Setup(m => m.Map <HistoryNoteEntity>(dto)).Returns(entity); historyNoteService.CreateHistoryNote(dto); mockRepo.Verify(r => r.Insert(entity), Times.Once); }
public void GetRepiarNote_Returns_HistoryNoteDto() { var id = Guid.NewGuid(); var entity = new HistoryNoteEntity(); var dto = new HistoryNoteDto(); mockRepo.Setup(r => r.GetById(It.IsAny <Guid>())).Returns(entity); mockMapper.Setup(m => m.Map <HistoryNoteDto>(entity)).Returns(dto); HistoryNoteDto actual = historyNoteService.GetHistoryNote(id); Assert.AreEqual(actual, dto); }
public void UpdateHistoryNote(HistoryNoteDto HistoryNoteDto) { HistoryNoteEntity historyNote = _historyNoteRepository.GetById(HistoryNoteDto.Id); if (historyNote != null) { historyNote.Description = HistoryNoteDto.Description; historyNote.BikeHistoryItemId = HistoryNoteDto.BikeHistoryItemId; historyNote.LastEditedDateTime = DateTime.UtcNow; _historyNoteRepository.Update(historyNote); } }
public void UpdateHistoryNote_Calls_Update_In_Repo() { var desc = "test"; var entity = new HistoryNoteEntity(); var dto = new HistoryNoteDto { Description = desc, BikeHistoryItemId = Guid.NewGuid() }; mockRepo.Setup(r => r.GetById(It.IsAny <Guid>())).Returns(entity); mockMapper.Setup(m => m.Map <HistoryNoteDto>(entity)).Returns(dto); historyNoteService.UpdateHistoryNote(dto); mockRepo.Verify(r => r.Update(It.IsAny <HistoryNoteEntity>()), Times.Once); }
private void CreateHistoryNoteForBikeUpdate(IEnumerable <ObjectPropertyDifference> differences, Guid historyItemId) { var builder = new StringBuilder(); builder.Append("Items changed in bike update:\n"); foreach (var difference in differences) { builder.Append($" {difference.PropertyName} was updated from {difference.LeftValue} to {difference.RightValue}"); } var historyNote = new HistoryNoteDto { BikeHistoryItemId = historyItemId, Description = builder.ToString() }; _historyNoteService.CreateHistoryNote(historyNote); }
public void UpdateHistoryNote_Updates_HistoryNote() { var id = Guid.NewGuid(); var desc = "test"; var entity = new HistoryNoteEntity(); var dto = new HistoryNoteDto { Description = desc, BikeHistoryItemId = id }; mockRepo.Setup(r => r.GetById(It.IsAny <Guid>())).Returns(entity); mockMapper.Setup(m => m.Map <HistoryNoteDto>(entity)).Returns(dto); historyNoteService.UpdateHistoryNote(dto); mockRepo.Verify(r => r.Update(It.Is <HistoryNoteEntity>(rn => rn.Description == desc && rn.BikeHistoryItemId == id && rn.LastEditedDateTime.Date == DateTime.UtcNow.Date)), Times.Once); }