public async Task CreateTipoTarefaCommand_Handle() { // Arrange IUnitOfWork unitOfWork = DbContextHelper.GetContext(); IMapper mapper = AutoMapperHelper.GetMappings(); CreateTipoTarefaCommand request = new() { TipoTarefa = MockViewModelHelper.GetNewTipoTarefa() }; // Act TipoTarefaHandler handler = new(unitOfWork, mapper); OperationResult response = await handler.Handle(request, CancellationToken.None); // Assert Assert.True(response == OperationResult.Success); }
public async Task UpdateTipoTarefaCommand_Handle() { // Arrange IUnitOfWork unitOfWork = DbContextHelper.GetContext(); IMapper mapper = AutoMapperHelper.GetMappings(); Guid tipoTarefaId = Guid.NewGuid(); DateTime dataInclusao = DateTime.Now; TipoTarefa tipoTarefa = MockEntityHelper.GetNewTipoTarefa(tipoTarefaId); await unitOfWork.TipoTarefaRepository.AddAsync(tipoTarefa); await unitOfWork.SaveChangesAsync(); unitOfWork.TipoTarefaRepository.Detatch(tipoTarefa); UpdateTipoTarefaCommand request = new() { TipoTarefa = MockViewModelHelper.GetNewTipoTarefa(tipoTarefaId, dataInclusao) }; GetTipoTarefaQuery request2 = new() { Id = tipoTarefaId }; // Act TipoTarefaHandler handler = new(unitOfWork, mapper); OperationResult response = await handler.Handle(request, CancellationToken.None); TipoTarefaViewModel response2 = await handler.Handle(request2, CancellationToken.None); // Assert Assert.True(response == OperationResult.Success); Assert.True(response2 != null); Assert.True(response2.Id == tipoTarefaId); Assert.True(response2.DataInclusao.Ticks == dataInclusao.Ticks); } }