コード例 #1
0
        public async Task Then_Returns_Results_From_Service(
            GetShortlistForUserQuery query,
            Domain.Shortlist.ShortlistForUser shortlistFromService,
            [Frozen] Mock <IShortlistService> mockService,
            GetShortlistForUserQueryHandler handler)
        {
            mockService
            .Setup(service => service.GetShortlistForUser(query.ShortlistUserId))
            .ReturnsAsync(shortlistFromService);

            var result = await handler.Handle(query, CancellationToken.None);

            result.Shortlist.Should().BeEquivalentTo(shortlistFromService.Shortlist);
        }
        public async Task Then_The_Data_Is_Returned_From_The_Api(
            Guid shortlistUserId,
            Domain.Shortlist.ShortlistForUser apiResponse,
            [Frozen] Mock <IApiClient> apiClient,
            ShortlistService service)
        {
            //Arrange
            apiClient.Setup(x =>
                            x.Get <Domain.Shortlist.ShortlistForUser>(
                                It.Is <GetShortlistForUserApiRequest>(c => c.GetUrl.Contains(shortlistUserId.ToString(), StringComparison.InvariantCultureIgnoreCase))))
            .ReturnsAsync(apiResponse);

            //Act
            var actual = await service.GetShortlistForUser(shortlistUserId);

            //Assert
            actual.Should().BeEquivalentTo(apiResponse);
        }