Esempio n. 1
0
        public void Should_retrieve_data_from_petowner_api()
        {
            var path = ConfigurationManager.AppSettings["PetOwnerAPI.Url"];
            var uri  = new Uri(path);

            IJsonToPetOwnerConverter converter = new JsonToPetOwnerConverter();
            var httpClient = new HttpClient();
            IPetOwnerApiService apiService = new PetOwnerApiService(httpClient, uri);

            IPetFinder         petFinder      = new CatFinder();
            IPetOwnerFinder    petOwnerFinder = new PetOwnerFinder();
            IPetOwnerFilter    petOwnerFilter = new PetOwnerFilter(petOwnerFinder, petFinder);
            IComparer <string> comparer       = new AlphabeticComparer();
            IPetSorter         petSorter      = new PetNameAlphabeticalSorter(comparer);
            IPetOwnerGrouper   grouper        = new PetOwnerGrouper();
            var apiClient = new PetOwnerApiClient.Client.PetOwnerApiClient(converter, apiService, petOwnerFilter, petSorter, grouper);
            var apiResult = apiClient.GetPetsByPetOwnerGender().Result;

            Assert.IsTrue(apiResult != null);
            Assert.IsTrue(string.IsNullOrEmpty(apiResult.Error));
            if (apiResult.PetsByGender != null)
            {
                var distinctGenders = apiResult.PetsByGender.Select(x => x.Gender).Distinct().ToList();
                var allGenders      = apiResult.PetsByGender.Select(x => x.Gender).ToList();

                Assert.IsTrue(distinctGenders.SequenceEqual(allGenders));
                foreach (var pet in apiResult.PetsByGender)
                {
                    Assert.IsTrue(pet.PetNames.Count() > 0);
                }
            }
        }
Esempio n. 2
0
        public void Should_return_false_when_pet_type_is_dog()
        {
            var catFinder = new CatFinder();
            var pet       = new Pet {
                Type = "Dog", Name = "Fido"
            };
            var result = catFinder.Find(pet);

            Assert.AreEqual(false, result);
        }
Esempio n. 3
0
        public void Should_return_true_when_pet_type_is_cat_lowercase()
        {
            var catFinder = new CatFinder();
            var pet       = new Pet {
                Type = "cat", Name = "Garfield"
            };
            var result = catFinder.Find(pet);

            Assert.AreEqual(true, result);
        }