Beispiel #1
0
            public void Arrange()
            {
                var fixture = new Fixture();

                _providers  = fixture.CreateMany <Provider>().ToList();
                _repository = new Mock <IProviderRepository>();
                _repository.Setup(x => x.GetProviders()).ReturnsAsync(_providers);
                _handler = new GetProvidersQueryHandler(_repository.Object);
            }
        public async Task Then_The_Api_Is_Called_With_The_Request_And_Providers_Returned(
            GetProvidersQuery query,
            GetProvidersListResponse apiResponse,
            [Frozen] Mock <ICourseDeliveryApiClient <CourseDeliveryApiConfiguration> > apiClient,
            GetProvidersQueryHandler handler
            )
        {
            apiClient.Setup(x => x.Get <GetProvidersListResponse>(It.IsAny <GetProvidersRequest>())).ReturnsAsync(apiResponse);

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

            actual.Providers.Should().BeEquivalentTo(apiResponse.Providers);
        }
Beispiel #3
0
        public async Task Then_Gets_Providers_From_The_Service(
            GetProvidersQuery query,
            List <ProviderSummary> providersFromService,
            [Frozen] Mock <IProviderService> mockProviderService,
            GetProvidersQueryHandler handler)
        {
            //Arrange
            mockProviderService
            .Setup(x => x.GetRegisteredProviders())
            .ReturnsAsync(providersFromService);

            //Act
            var actual = await handler.Handle(query, It.IsAny <CancellationToken>());

            //Assert
            actual.RegisteredProviders.Should().BeEquivalentTo(providersFromService);
        }