Beispiel #1
0
        public async Task Then_Gets_AccountLegalEntity_From_Mediator(
            long accountLegalEntityId,
            GetAccountLegalEntityQueryResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] AccountLegalEntityController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <GetAccountLegalEntityQuery>(x => x.AccountLegalEntityId == accountLegalEntityId),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

            var controllerResult = await controller.Get(accountLegalEntityId) as ObjectResult;

            Assert.IsNotNull(controllerResult);
            controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
            var model = controllerResult.Value as GetAccountLegalEntityQueryResult;

            Assert.IsNotNull(model);
            model.Should().BeEquivalentTo(mediatorResult);
        }
Beispiel #2
0
        public AccountLegalEntityControllerTestFixtures SetQueryResponse(long forAccountLegalEntityId, GetAccountLegalEntityQueryResult sendQueryResult)
        {
            MediatorMock
            .Setup(m => m.Send(
                       It.Is <GetAccountLegalEntityQuery>(request => request.AccountLegalEntityId == forAccountLegalEntityId),
                       It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(sendQueryResult));

            return(this);
        }