Esempio n. 1
0
        public void Get_All_Persons_From_Empty_Db()
        {
            var expected = new List<PersonDTO>();
            var mock = new Mock<IRepository<Person>>();
            mock.Setup(p => p.GetAll()).Returns(new List<Person>());
            var personService = new PersonService(mock.Object);

            var result = personService.GetAllPersons();
            Assert.IsInstanceOf<IEnumerable<PersonDTO>>(result);
            CollectionAssert.AreEqual("$" + expected, "$" + result);
        }
Esempio n. 2
0
        public void Get_All_Persons_From_Db_With_Many_Persons()
        {
            var expected = new List<PersonDTO> { _persDto1, _persDto2, _persDto3, _persDto4, _persDto5 };

            _pers1.Phones[0].Person = _pers1;
            _pers1.Phones[1].Person = _pers1;
            _pers2.Phones[0].Person = _pers2;
            _pers3.Phones[0].Person = _pers3;
            _pers4.Phones[0].Person = _pers4;

            var persons = new List<Person> { _pers1, _pers2, _pers3, _pers4, _pers5 };

            var mock = new Mock<IRepository<Person>>();
            mock.Setup(x => x.GetAll()).Returns(persons);
            var personService = new PersonService(mock.Object);

            var result = personService.GetAllPersons().ToList();

            Assert.IsInstanceOf<IEnumerable<PersonDTO>>(result);
            CollectionAssert.AreEqual("$" + expected, "$" + result);
        }