public async Task TestOverallApiPullAllDogs() { var ceoDogProvider = new DogCeoAnimalProvider(getLiveProviderOptions()); var list = await ceoDogProvider.ListBreedsAsync(); Assert.IsTrue(0 < list.Count); }
public async Task TestOverallApiPullImageBluetick() { var ceoDogProvider = new DogCeoAnimalProvider(getLiveProviderOptions()); var imageSrc = await ceoDogProvider.GetRandomBreedImageAsync("bluetick"); Assert.IsNotNull(imageSrc); }
public void DoesNotBuildInvalidUriGetAllDogs() { var ceoDogProvider = new DogCeoAnimalProvider(getLiveProviderOptions()); var allDogsUri = new Uri("https://dog.ceo/api/breeds/list/all/"); var val = ceoDogProvider.GetUriForPath(Constants.DataProviderBreedListPath); Assert.AreNotEqual(allDogsUri, val); }
public void ProtocolIsHttpWhenUseSSLIsFalse() { var opts = new DogCeoDataProviderOptions { DataProviderUseSSL = false }; var ceoDogProvider = new DogCeoAnimalProvider(opts); Assert.AreEqual("http", ceoDogProvider.GetProtocol().ToLower()); }
public void ParseSampleJson() { var ceoDogProvider = new DogCeoAnimalProvider(new DogCeoDataProviderOptions()); var testString = "{\"affenpinscher\": [],\"african\": [], \"bulldog\": [\"boston\", \"french\"]}"; var testList = new List <Dog> { new Dog { Breed = "affenpinscher" }, new Dog { Breed = "african" }, new Dog { Breed = "bulldog", SubBreeds = new [] { "boston", "french" } } }; var dogs = ceoDogProvider.ParseBreedList(testString); if (testList.Count != dogs.Length) { Assert.Fail("Wrong number of elements returned from parsed string."); } for (var i = 0; i < testList.Count; i++) { if (testList [i].Breed != dogs [i].Breed) { Assert.Fail("Element #{0} returned wrong breed name.", i); } if (null != testList [i].SubBreeds) { if (null == dogs [i].SubBreeds) { Assert.Fail("Element #{0} failed to populate sub-breeds.", i); } if (testList [i].SubBreeds.Length != dogs [i].SubBreeds.Length) { Assert.Fail("Element #{0} failed to populate the correct number of sub-breeds.", i); } for (var ii = 0; ii < testList [i].SubBreeds.Length; ii++) { var testName = testList [i].SubBreeds [ii]; var valName = dogs [i].SubBreeds [ii]; if (!string.Equals(testName, valName)) { Assert.Fail("Element #{0}, sub-breed {1} yielded incorrect sub-breed name.", i); } } } } }