public async Task Handle_ValidId_ShouldActivateProject() { var projectId = await CreateFinancialProject(); var delete = new DeleteFinancialProjectCommand { Id = projectId }; await SendAsync(delete); var entity = await FindAsync <CoolWebsite.Domain.Entities.Financial.FinancialProject>(projectId); entity.Deleted.Should().BeCloseTo(DateTime.Now, 1000); entity.DeletedByUserId.Should().Be(User.Id); var activateCommand = new ActivateFinancialProjectCommand { ProjectId = projectId }; await SendAsync(activateCommand); var activatedEntity = await FindAsync <CoolWebsite.Domain.Entities.Financial.FinancialProject>(projectId); activatedEntity.Deleted.Should().Be(null); activatedEntity.DeletedByUserId.Should().Be(null); }
public async Task Handle_ValidIdNotCreatedByUser_ShouldThrowNotFoundException() { var projectId = await CreateFinancialProject(); var delete = new DeleteFinancialProjectCommand { Id = projectId }; await SendAsync(delete); var entity = await FindAsync <CoolWebsite.Domain.Entities.Financial.FinancialProject>(projectId); entity.Deleted.Should().BeCloseTo(DateTime.Now, 1000); entity.DeletedByUserId.Should().Be(User.Id); var activateCommand = new ActivateFinancialProjectCommand { ProjectId = projectId }; await RunAsUserAsync("*****@*****.**", "nah"); FluentActions.Invoking(async() => await SendAsync(activateCommand)).Should().Throw <NotFoundException>(); }
public void Handle_InvalidId_ShouldThrowNotFoundException() { var command = new DeleteFinancialProjectCommand { Id = "asdasd" }; FluentActions.Invoking(async() => await SendAsync(command)).Should().Throw <NotFoundException>(); }
public async Task <IActionResult> ArchiveProject(string id) { var command = new DeleteFinancialProjectCommand { Id = id }; try { await Mediator.Send(command); return(RedirectToAction("Index")); } catch (ValidationException e) { Console.WriteLine(e); throw; } }
public async Task Handle_ValidId_ShouldDelete() { var id = await CreateFinancialProject(); var command = new DeleteFinancialProjectCommand { Id = id }; var notDeleted = await FindAsync <CoolWebsite.Domain.Entities.Financial.FinancialProject>(id); notDeleted.Deleted.Should().BeNull(); await SendAsync(command); var entity = await FindAsync <CoolWebsite.Domain.Entities.Financial.FinancialProject>(id); entity.Deleted.Should().BeCloseTo(DateTime.Now, 1000); entity.DeletedByUserId.Should().Be(User.Id); }
public async Task Handle_ValidUserId_ShouldReturnListOfFinancialProjects() { var project = await CreateFinancialProject(); var deleteCommand = new DeleteFinancialProjectCommand { Id = project }; await SendAsync(deleteCommand); var query = new GetArchiveFinancialProjectsByUserQuery(); var entity = await SendAsync(query); entity.Should().NotBeNull(); entity.Count.Should().Be(1); entity.First().Id.Should().Be(project); entity.First().Users.FirstOrDefault(x => x.Id == User.Id).Should().NotBeNull(); entity.First().Deleted.Should().BeCloseTo(DateTime.Now, 10000); }
public void Handle_EmptyId_ShouldThrowValidationException() { var command = new DeleteFinancialProjectCommand(); FluentActions.Invoking(async() => await SendAsync(command)).Should().Throw <ValidationException>(); }