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); }
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")); }
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> >()); }
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")); }
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); }
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); }