コード例 #1
0
        public async Task And_Opportunity_Doesnt_Exist_Then_Returns_NotFound(
            int accountId,
            int opportunityId,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] OpportunityController opportunityController)
        {
            mockMediator
            .Setup(x => x.Send(
                       It.Is <GetApplicationDetailsQuery>(y => y.OpportunityId == opportunityId),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(new GetApplicationDetailsQueryResult());

            var controllerResult = await opportunityController.GetApplicationDetails(accountId, opportunityId, default);

            var notFoundResult = controllerResult as NotFoundResult;

            Assert.IsNotNull(controllerResult);
            Assert.IsNotNull(notFoundResult);
            Assert.AreEqual(notFoundResult.StatusCode, (int)HttpStatusCode.NotFound);
        }
コード例 #2
0
        public async Task And_Opportunity_Exists_Then_Returns_Ok_Pledge_And_Standards(
            long accountId,
            int opportunityId,
            GetApplicationDetailsQueryResult getApplicationDetailsQueryResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] OpportunityController opportunityController)
        {
            mockMediator
            .Setup(x => x.Send(
                       It.Is <GetApplicationDetailsQuery>(y => y.OpportunityId == opportunityId),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(getApplicationDetailsQueryResult);

            var controllerResult = await opportunityController.GetApplicationDetails(accountId, opportunityId, default);

            var okObjectResult = controllerResult as OkObjectResult;
            var response       = okObjectResult.Value as ApplicationDetailsResponse;

            Assert.IsNotNull(controllerResult);
            Assert.IsNotNull(okObjectResult);
            Assert.IsNotNull(response);
            Assert.AreEqual(okObjectResult.StatusCode, (int)HttpStatusCode.OK);
        }