示例#1
0
        public void ItShouldGetPersonById()
        {
            var personRepository = new FeikPersonRepository();

            personRepository.Persons.Add(new Person {
                Id = 7
            });
            PersonController personController = new PersonController(personRepository);

            var contentResult = personController.GetPerson(7) as OkNegotiatedContentResult <Person>;

            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(7, contentResult.Content.Id);
        }
示例#2
0
        public void ItShouldGetAllEmployee()
        {
            var personRepository = new FeikPersonRepository();

            personRepository.Persons.Add(new Person {
                BirthDay = new DateTime(1991, 11, 22)
            });
            personRepository.Persons.Add(new Person {
                BirthDay = new DateTime(1991, 04, 30)
            });
            personRepository.Persons.Add(new Person {
                BirthDay = new DateTime(1991, 07, 15)
            });
            PersonController personController = new PersonController(personRepository);

            var contentResult = personController.GetSeniorEmployee() as OkNegotiatedContentResult <Person>;

            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content.BirthDay);
            Assert.AreEqual(new DateTime(1991, 04, 30), contentResult.Content.BirthDay);
        }
示例#3
0
        public void ItShouldGetAverageSalary()
        {
            var personRepository = new FeikPersonRepository();

            personRepository.Persons.Add(new Person {
                Salary = 25000
            });
            personRepository.Persons.Add(new Person {
                Salary = 50000
            });
            personRepository.Persons.Add(new Person {
                Salary = 15000
            });
            PersonController personController = new PersonController(personRepository);

            var contentResult = personController.GetAverageSalary() as OkNegotiatedContentResult <decimal>;

            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(30000, contentResult.Content);
        }