public async void CommandGetHistoricIsValid_Executed_Success() { var historicWritingRepository = new Mock <IHistoricWritingRepository>(); var historicReadingRepository = new Mock <IHistoricReadingRepository>(); var historicCommand = new HistoricCommand() { Id = 0, IdRickAndMorty = 1, Location = "Earth 137" }; var entity = new Historic() { Id = historicCommand.Id, IdRickAndMorty = historicCommand.IdRickAndMorty, Location = historicCommand.Location }; historicWritingRepository.Setup(p => p.AddTravel(It.IsAny <Historic>())).Returns(Task.FromResult(entity)); var historicCommandHandler = new HistoricCommandHandler(historicReadingRepository.Object, historicWritingRepository.Object); var historicDb = await historicCommandHandler.AddTravel(historicCommand); var historics = await historicCommandHandler.GetHistoric(historicDb.Id); historicReadingRepository.Verify(prop => prop.GetHistoric(It.IsAny <int>()), Times.Once); Assert.NotNull(historics); }
public async Task <ActionResult> AddTravel([FromBody] HistoricCommand command) { var historic = await historicCommandHandler.AddTravel(command); return(Ok(historic)); }
public async Task <Historic> AddTravel(HistoricCommand command) { var entity = _mapperCommandToEntity.Map <HistoricCommand, Historic>(command); return(await historicWritingRepository.AddTravel(entity)); }