public async Task ShouldGetMemoryAndStorage() { Expression <Func <IMobileMemoryAndStorage, bool> > mobileMemoryAndStorage = m => m.MinimumMemoryRequirement == "1GB" && m.Description == "desc"; Expression <Func <IClientApplication, bool> > clientApplication = c => c.MobileMemoryAndStorage == Mock.Of(mobileMemoryAndStorage); mockMediator .Setup(m => m.Send( It.Is <GetClientApplicationBySolutionIdQuery>(q => q.Id == SolutionId), It.IsAny <CancellationToken>())) .ReturnsAsync(Mock.Of(clientApplication)); var result = await memoryAndStorageController.GetMemoryAndStorageAsync(SolutionId) as ObjectResult; Assert.NotNull(result); result.StatusCode.Should().Be(StatusCodes.Status200OK); var memoryAndStorage = result.Value as GetSolutionMemoryAndStorageResult; Assert.NotNull(memoryAndStorage); memoryAndStorage.MinimumMemoryRequirement.Should().Be("1GB"); memoryAndStorage.Description.Should().Be("desc"); mockMediator.Verify(m => m.Send( It.Is <GetClientApplicationBySolutionIdQuery>(q => q.Id == SolutionId), It.IsAny <CancellationToken>())); }
public async Task ShouldGetMemoryAndStorage() { _mockMediator .Setup(m => m.Send(It.Is <GetClientApplicationBySolutionIdQuery>(q => q.Id == SolutionId), It.IsAny <CancellationToken>())).ReturnsAsync(Mock.Of <IClientApplication>(c => c.MobileMemoryAndStorage == Mock.Of <IMobileMemoryAndStorage>(m => m.MinimumMemoryRequirement == "1GB" && m.Description == "desc"))); var result = (await _memoryAndStorageController.GetMemoryAndStorageAsync(SolutionId) .ConfigureAwait(false)) as ObjectResult; result?.StatusCode.Should().Be((int)HttpStatusCode.OK); var memoryAndStorage = result?.Value as GetSolutionMemoryAndStorageResult; memoryAndStorage?.MinimumMemoryRequirement.Should().Be("1GB"); memoryAndStorage?.Description.Should().Be("desc"); _mockMediator.Verify( m => m.Send(It.Is <GetClientApplicationBySolutionIdQuery>(q => q.Id == SolutionId), It.IsAny <CancellationToken>()), Times.Once); }