public async Task Returns_Ok_And_Response( GetIndexQueryResult getIndexQueryResult, [Frozen] Mock <IMediator> mockMediator, [Greedy] OpportunityController opportunityController ) { var sectorsList = _fixture.Create <IEnumerable <string> >(); mockMediator .Setup(x => x.Send( It.IsAny <GetIndexQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(getIndexQueryResult); var controllerResult = await opportunityController.GetIndex(sectorsList); var okObjectResult = controllerResult as OkObjectResult; var responseObject = okObjectResult.Value as GetIndexResponse; Assert.IsNotNull(controllerResult); Assert.IsNotNull(okObjectResult); Assert.IsNotNull(responseObject); Assert.IsNotNull(responseObject.Opportunities); Assert.IsNotNull(responseObject.Sectors); Assert.IsNotNull(responseObject.JobRoles); Assert.IsNotNull(responseObject.Levels); Assert.AreEqual(okObjectResult.StatusCode, (int)HttpStatusCode.OK); }