Exemple #1
0
        static void Main(string[] args)
        {
            try
            {
                var peopleBL = new PeopleBL(new PeopleServiceProxy()); //can be initalized using dependency injection

                //print cat names under a female owner
                var maleOwnerCatCollection = peopleBL.GetAllPetNameCollection(Gender.Male, PetType.Cat).Result;
                Console.WriteLine("MALE");
                Console.WriteLine("=====================");
                foreach (var item in maleOwnerCatCollection)
                {
                    Console.WriteLine(item);
                }


                Console.WriteLine();

                //print cat names under a female owner
                var femaleOwnerCatCollection = peopleBL.GetAllPetNameCollection(Gender.Female, PetType.Cat).Result;
                Console.WriteLine("FEMALE");
                Console.WriteLine("=====================");
                foreach (var item in femaleOwnerCatCollection)
                {
                    Console.WriteLine(item);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            Console.Read();
        }
        public void GetAllPetNameCollection_OnExecute_ShouldReturnElementsInOrder()
        {
            var           mock       = _factory.CreateMock <IPeopleServiceProxy>();
            List <People> collection = GetMockData();

            mock.Expects.One.MethodWith(_ => _.GetAll()).WillReturn(Task.FromResult(collection.AsEnumerable()));
            var peopleBL = new PeopleBL(mock.MockObject);
            var result   = peopleBL.GetAllPetNameCollection(Gender.Male, PetType.Cat).Result.ToList();

            Assert.IsTrue(result[0] == "Garfield");
            Assert.IsTrue(result[1] == "Simba");
        }
        public void GetAllPetNameCollection_OnExecute_ShouldReturnOnlyFilteredElements()
        {
            var           mock       = _factory.CreateMock <IPeopleServiceProxy>();
            List <People> collection = GetMockData();

            mock.Expects.One.MethodWith(_ => _.GetAll()).WillReturn(Task.FromResult(collection.AsEnumerable()));
            var peopleBL = new PeopleBL(mock.MockObject);
            var result   = peopleBL.GetAllPetNameCollection(Gender.Male, PetType.Cat).Result.ToList();

            Assert.IsTrue(result.Count == 2);
            Assert.IsTrue(result.Any(a => a == "Garfield"));
            Assert.IsTrue(result.Any(a => a == "Simba"));
            Assert.IsFalse(result.Any(a => a == "Fido"));
            Assert.IsFalse(result.Any(a => a == "Tom"));
            Assert.IsFalse(result.Any(a => a == "Tabby"));
        }