コード例 #1
0
        public async System.Threading.Tasks.Task GetFilterParameters_CallsApi()
        {
            // arrange
            string endpoint = "endPoint";

            configuration[EndPoints.Api.GetFilterParameters].Returns(endpoint);
            FilterParametersDto parameters = new FilterParametersDto()
            {
                Countries       = new List <CountryDto>(),
                ItemTypes       = new List <ItemTypeDto>(),
                OrderPriorities = new List <OrderPriorityDto>(),
                Regions         = new List <RegionDto>(),
                SalesChannels   = new List <SalesChannelDto>()
            };
            GetSalesRequestDto requestDto = GetSalesRequestDtoBuilder.Build();

            httpClient.GetAsync <FilterParametersDto>(endpoint).Returns(parameters);


            // act
            await saleService.GetFilterParameters(requestDto);

            // assert
            await httpClient.Received(1).GetAsync <FilterParametersDto>(endpoint);
        }
コード例 #2
0
        public async Task Accept_header_is_added_to_request_when_authenticated()
        {
            _httpClientWrapper
            .Get(Arg.Is("web-address"), Arg.Any <IDictionary <string, string> >())
            .Returns(AuthorizedResponse("ok"));

            await _sut.GetAsync <JsonResponse>("web-address");

            await _httpClientWrapper.Received(1).Get(Arg.Any <string>(), HeaderIs("Accept", "test-media-string"));
        }
コード例 #3
0
        public async Task Renews_token_using_authentication_uri()
        {
            await _token.RenewToken(_headers, "api-authentication-uri");

            await _httpClient
            .Received(1)
            .Send(
                "api-authentication-uri",
                Arg.Any <HttpMethod>(),
                Arg.Any <HttpContent>(),
                Arg.Any <IDictionary <string, string> >());
        }
コード例 #4
0
        public async Task Content_type_header_is_added_to_request_when_authenticated()
        {
            await _sut.SendAsync(_resourceBuilder.Build());

            await _httpClientWrapper
            .Received(1)
            .Send(
                Arg.Any <string>(),
                Arg.Any <HttpMethod>(),
                Arg.Any <HttpContent>(),
                HeaderIs("Content-type", "test-media-value"));
        }
コード例 #5
0
        public async Task GetUserSectorsAsync_CallsApi()
        {
            // arrange
            string endpoint = "endPoint";

            configuration[EndPoints.Api.GetUserSectors].Returns(endpoint);

            // act
            await userSectorsService.GetUserSectorsAsync();

            // asert
            await httpClient.Received(1).GetAsync <IEnumerable <UserSectorsDto> >(endpoint);
        }
コード例 #6
0
        public async Task GetSectorsAsync_CallsApiAndCalculateLevel()
        {
            // arrange
            string endpoint = "endPoint";

            configuration[EndPoints.Api.GetSectors].Returns(endpoint);
            List <SectorDto> sectors = new List <SectorDto>()
            {
                SectorDtoBuilder.Build(parent: SectorDtoBuilder.Build(level: 1)),
                SectorDtoBuilder.Build(parentId: null),
                SectorDtoBuilder.Build(parentId: null)
            };

            httpClient.GetAsync <IEnumerable <SectorDto> >(endpoint).Returns(sectors);

            // act
            var result = await sectorService.GetSectorsAsync();

            // assert
            await httpClient.Received(1).GetAsync <IEnumerable <SectorDto> >(endpoint);

            result.Count(x => x.ParentId == null && x.Level == 0).Should().Be(2);
        }