public async Task PopulatedPrivateCloudShouldReturnCorrectDetails(string summary, string link, string hostingModel, string requiredHscn) { _mediatorMock.Setup(m => m.Send(It.Is <GetHostingBySolutionIdQuery>(q => q.Id == _solutionId), It.IsAny <CancellationToken>())) .ReturnsAsync(Mock.Of <IHosting>(h => h.PrivateCloud == Mock.Of <IPrivateCloud>(p => p.Summary == summary && p.Link == link && p.HostingModel == hostingModel && p.RequiresHSCN == requiredHscn))); var result = await _controller.Get(_solutionId).ConfigureAwait(false) as ObjectResult; result.Should().NotBeNull(); result.StatusCode.Should().Be((int)HttpStatusCode.OK); result.Value.Should().BeOfType <GetPrivateCloudResult>(); var privateCloudResult = result.Value as GetPrivateCloudResult; privateCloudResult.Summary.Should().Be(summary); privateCloudResult.Link.Should().Be(link); privateCloudResult.HostingModel.Should().Be(hostingModel); if (requiredHscn == null) { privateCloudResult.RequiredHscn.Should().BeEmpty(); } else { privateCloudResult.RequiredHscn.Should().BeEquivalentTo(requiredHscn); } }
public async Task PopulatedPrivateCloudShouldReturnCorrectDetails( string summary, string link, string hostingModel, string requiresHscn) { Expression <Func <IPrivateCloud, bool> > privateCloud = p => p.Summary == summary && p.Link == link && p.HostingModel == hostingModel && p.RequiresHscn == requiresHscn; mediatorMock .Setup(m => m.Send( It.Is <GetHostingBySolutionIdQuery>(q => q.Id == SolutionId), It.IsAny <CancellationToken>())) .ReturnsAsync(Mock.Of <IHosting>(h => h.PrivateCloud == Mock.Of(privateCloud))); var result = await controller.Get(SolutionId) as ObjectResult; Assert.NotNull(result); result.StatusCode.Should().Be(StatusCodes.Status200OK); result.Value.Should().BeOfType <GetPrivateCloudResult>(); var privateCloudResult = result.Value as GetPrivateCloudResult; Assert.NotNull(privateCloudResult); privateCloudResult.Summary.Should().Be(summary); privateCloudResult.Link.Should().Be(link); privateCloudResult.HostingModel.Should().Be(hostingModel); if (requiresHscn is null) { privateCloudResult.RequiredHscn.Should().BeEmpty(); } else { privateCloudResult.RequiredHscn.Should().BeEquivalentTo(requiresHscn); } }