public async Task Handle_GivenInvalidRequest_ShouldThrowNotFoundException() { // Arrange var query = new GetTeamDetailsQuery { Id = 131 }; var sut = new GetTeamDetailsQueryHandler(this.deletableEntityRepository, It.IsAny <IMapper>(), It.IsAny <IUserAccessor>()); // Act & Assert await Should.ThrowAsync <NotFoundException>(sut.Handle(query, It.IsAny <CancellationToken>())); }
public async Task Handle_GivenValidRequest_ShouldReturnViewModel() { // Arrange var query = new GetTeamDetailsQuery { Id = 1 }; var userAccessorMock = new Mock <IUserAccessor>(); userAccessorMock.Setup(x => x.UserId).Returns("Foo1"); var sut = new GetTeamDetailsQueryHandler(this.deletableEntityRepository, this.mapper, userAccessorMock.Object); // Act var viewModel = await sut.Handle(query, It.IsAny <CancellationToken>()); // Assert viewModel.ShouldNotBeNull(); viewModel.Name.ShouldBe("FooTeam1"); viewModel.IsOwner.ShouldBe(true); viewModel.IsMember.ShouldBe(true); }
public async Task <IActionResult> Details(GetTeamDetailsQuery query) => this.View(await this.Mediator.Send(query));
public async Task <IActionResult> Details(GetTeamDetailsQuery query) { var viewModel = await this.Mediator.Send(query); return(this.View(viewModel)); }