Beispiel #1
0
        public async Task Then_Returns_Ok_And_Response(
            int opportunityId,
            GetDetailQueryResult getDetailQueryResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] OpportunityController opportunityController)
        {
            mockMediator
            .Setup(x => x.Send(
                       It.Is <GetDetailQuery>(y => y.OpportunityId == opportunityId),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(getDetailQueryResult);

            var controllerResult = await opportunityController.Detail(opportunityId);

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

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