public async Task Handle_GivenInvalidRequest_ShouldThrowForbiddenException() { // Arrange var query = new EditMatchResultQuery { Id = 1 }; var userAccessorMock = new Mock <IUserAccessor>(); userAccessorMock.Setup(x => x.UserId).Returns("Foo5"); var sut = new EditMatchResultQueryHandler(this.deletableEntityRepository, userAccessorMock.Object, this.mapper); // Act & Assert await Should.ThrowAsync <ForbiddenException>(sut.Handle(query, It.IsAny <CancellationToken>())); }
public async Task Handle_GivenValidRequest_ShouldReturnCommand() { // Arrange var query = new EditMatchResultQuery { Id = 2 }; var userAccessorMock = new Mock <IUserAccessor>(); userAccessorMock.Setup(x => x.UserId).Returns("Foo2"); var sut = new EditMatchResultQueryHandler(this.deletableEntityRepository, userAccessorMock.Object, this.mapper); // Act var command = await sut.Handle(query, It.IsAny <CancellationToken>()); // Assert command.ShouldNotBeNull(); command.ShouldBeOfType <EditMatchResultCommand>(); }
public async Task <IActionResult> EditResult(EditMatchResultQuery query) { var result = await this.Mediator.Send(query); return(this.View(result)); }
public async Task <IActionResult> EditResult(EditMatchResultQuery query) => this.View(await this.Mediator.Send(query));