public async Task <IActionResult> AcceptResult(AcceptMatchResultCommand command, int playWeekId) { await this.Mediator.Send(command); return(this.RedirectToAction(nameof(Details), new GetMatchesForPlayWeekQuery { PlayWeekId = playWeekId })); }
public async Task Hanlde_GivenInvalidRequest_ShouldThrowForbiddenException() { // Arrange var command = new AcceptMatchResultCommand { Id = 1 }; var sut = new AcceptMatchResultCommandHandler(this.deletableEntityRepository, this.mediatorMock.Object); // Act & Assert await Should.ThrowAsync <ForbiddenException>(sut.Handle(command, It.IsAny <CancellationToken>())); }
public async Task Hanlde_GivenValidRequest_ShouldAcceptMatchResult() { // Arrange var command = new AcceptMatchResultCommand { Id = 1 }; var desiredMatch = this.dbContext.Matches.SingleOrDefault(x => x.Id == 1); desiredMatch.IsResultConfirmed = false; this.dbContext.SaveChanges(); var sut = new AcceptMatchResultCommandHandler(this.deletableEntityRepository, this.mediatorMock.Object); // Act var affectedRows = await sut.Handle(command, It.IsAny <CancellationToken>()); // Assert affectedRows.ShouldBe(1); mediatorMock.Verify(m => m.Send(It.IsAny <AddPointsCommand>(), It.IsAny <CancellationToken>()), Times.Exactly(2)); }