Exemplo n.º 1
0
        public async Task Then_Returns_Ok_And_Response(
            long accountId,
            int opportunityId,
            GetMoreDetailsQueryResult getMoreDetailsQueryResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] OpportunityController opportunityController)
        {
            mockMediator
            .Setup(x => x.Send(
                       It.Is <GetMoreDetailsQuery>(y => y.OpportunityId == opportunityId),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(getMoreDetailsQueryResult);

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

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

            Assert.IsNotNull(controllerResult);
            Assert.IsNotNull(okObjectResult);
            Assert.IsNotNull(response);
            Assert.AreEqual(okObjectResult.StatusCode, (int)HttpStatusCode.OK);
            Assert.AreEqual(getMoreDetailsQueryResult.Opportunity.Id, response.Opportunity.Id);
            Assert.AreEqual(getMoreDetailsQueryResult.Sectors, response.Sectors);
            Assert.AreEqual(getMoreDetailsQueryResult.JobRoles, response.JobRoles);
            Assert.AreEqual(getMoreDetailsQueryResult.Levels, response.Levels);
        }