public async Task Test1() { var location = new Location(this.placeInfo.Location !.Lat, this.placeInfo.Location.Lon); var expected = new IataPoint(this.placeInfo.Iata !, location); var provider = new PlaceInfoProvider(this.placesApiClientMock.Object, this.repositoryMock.Object); this.SetupRepositoryGetAsyncMethod(location); var result = await provider.GetPlaceInfoAsync(this.placeInfo.Iata !, CancellationToken.None); result.Should().BeOfType <Result <IataPoint> >(); result.Value.Should().BeEquivalentTo(expected); }
public async Task Test2() { var location = new Location(this.placeInfo.Location !.Lat, this.placeInfo.Location.Lon); var expected = new IataPoint(this.placeInfo.Iata !, location); var apiResponse = new ApiResponse <PlacesApiResponse>(new HttpResponseMessage(HttpStatusCode.OK), this.placeInfo, new RefitSettings()); var provider = new PlaceInfoProvider(this.placesApiClientMock.Object, this.repositoryMock.Object); this.SetupApiClientGetPlaceInfoAsyncMethod(apiResponse); var result = await provider.GetPlaceInfoAsync(this.placeInfo.Iata !, CancellationToken.None); result.Should().BeOfType <Result <IataPoint> >(); result.Value.Should().BeEquivalentTo(expected); }
public async Task Test3() { var responseMessage = new HttpResponseMessage(HttpStatusCode.NotFound); var exception = await ApiException.Create(new HttpRequestMessage(), HttpMethod.Get, responseMessage, new RefitSettings()); var apiResponse = new ApiResponse <PlacesApiResponse>(responseMessage, null, new RefitSettings(), exception); var provider = new PlaceInfoProvider(this.placesApiClientMock.Object, this.repositoryMock.Object); this.SetupApiClientGetPlaceInfoAsyncMethod(apiResponse); var result = await provider.GetPlaceInfoAsync(this.placeInfo.Iata !, CancellationToken.None); result.Should().BeOfType <Result <IataPoint> >(); result.IsFailure.Should().Be(true); }