public void CanGetPhotos() { // arrange var expected = new List <PhotoDomainModel> { new PhotoDomainModel() { Id = 1, AlbumId = 2, Title = "Title", ThumbnailUrl = "TURL", Url = "URL" } }; var source = JsonConvert.SerializeObject(expected); var delegatingHandlerStub = new DelegatingHandlerStub(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent(source, Encoding.UTF8, "application/json") }); var httpClient = new HttpClient(delegatingHandlerStub) { BaseAddress = new Uri("http://foo/") }; var service = new PhotoAlbumService(httpClient); // act var actual = service.GetPhotos().Result; // assert actual.Should().BeEquivalentTo(expected); }
public void Can_Get_Drivers() { // arrange var source = File.ReadAllText("F1Drivers.json"); var delegatingHandlerStub = new DelegatingHandlerStub(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent(source, Encoding.UTF8, "application/json") }); var httpClient = new HttpClient(delegatingHandlerStub) { BaseAddress = new Uri("http://foo/") }; var service = new F1DriverService(httpClient); // act var actual = service.GetDrivers(); // assert actual.Should().BeEquivalentTo(expectedF1Drivers); }