public async Task Then_Returns_Ok_And_Response( long accountId, int opportunityId, GetApplyQueryResult getApplyQueryResult, [Frozen] Mock <IMediator> mockMediator, [Greedy] OpportunityController opportunityController) { mockMediator .Setup(x => x.Send( It.Is <GetApplyQuery>(y => y.OpportunityId == opportunityId), It.IsAny <CancellationToken>())) .ReturnsAsync(getApplyQueryResult); var controllerResult = await opportunityController.Apply(accountId, opportunityId); var okObjectResult = controllerResult as OkObjectResult; var response = okObjectResult.Value as GetApplyResponse; Assert.IsNotNull(controllerResult); Assert.IsNotNull(okObjectResult); Assert.IsNotNull(response); Assert.AreEqual(okObjectResult.StatusCode, (int)HttpStatusCode.OK); Assert.AreEqual(getApplyQueryResult.Opportunity.Id, response.Opportunity.Id); Assert.AreEqual(getApplyQueryResult.Sectors, response.Sectors); Assert.AreEqual(getApplyQueryResult.JobRoles, response.JobRoles); Assert.AreEqual(getApplyQueryResult.Levels, response.Levels); }
public async Task Post_Returns_ApplicationId() { var actionResult = await _controller.Apply(_accountId, _opportunityId, _request); var createdResult = actionResult as CreatedResult; Assert.IsNotNull(createdResult); var response = createdResult.Value as ApplyResponse; Assert.IsNotNull(response); Assert.AreEqual(_result.ApplicationId, response.ApplicationId); }