public async Task Handle_InvalidUserId_ShouldThrowNotFoundException() { var createCommand = new CreateFinancialProjectCommand { Title = "Create", Users = new List <ApplicationUser> { User } }; await SendAsync(createCommand); var query = new GetFinancialProjectsByUserIdQuery { UserId = "ads" }; FluentActions.Invoking(async() => await SendAsync(query)).Should().Throw <NotFoundException>(); }
public async Task Handle_ValidUserId_ShouldReturnProject() { var createCommand = new CreateFinancialProjectCommand { Title = "Create", Users = new List <ApplicationUser> { User } }; var project = await SendAsync(createCommand); var createReceipt = new CreateReceiptCommand { FinancialProjectId = project.Id, Location = "Title", DateVisited = DateTime.Now }; var receiptId = await SendAsync(createReceipt); var query = new GetFinancialProjectsByUserIdQuery { UserId = User.Id }; var model = await SendAsync(query); model.Should().NotBeNull(); model.FinancialProjects.First().Users.First().Id.Should().Be(User.Id); model.FinancialProjects.First().Title.Should().Be(createCommand.Title); model.FinancialProjects.First().Receipts.First().Id.Should().Be(receiptId); model.FinancialProjects.First().Id.Should().Be(project.Id); model.FinancialProjects.First().Receipts.First().Location.Should().Be(createReceipt.Location); model.FinancialProjects.First().CreatedBy.Should().Be(User.Id); model.FinancialProjects.First().Receipts.First().DateVisited.Should().BeCloseTo(DateTime.Now, 1000); }
public void Handle_EmptyUserId_ShouldThrowValidationException() { var query = new GetFinancialProjectsByUserIdQuery(); FluentActions.Invoking(async() => await SendAsync(query)).Should().Throw <ValidationException>(); }