Пример #1
0
        public void GetByIdTest()
        {
            var person = factory.GetPersonById(1);

            Assert.IsNotNull(person);
            Assert.IsTrue(person.FirstName.Equals("James"));
        }
Пример #2
0
        public void GetPersonById_FilterCorrectly(Tuple <bool, Person> data)
        {
            var selector = PersonFactory.GetPersonById(1).Compile();
            var result   = selector(data.Item2);

            Assert.AreEqual(data.Item1, result);
        }
Пример #3
0
        static void Main(string[] args)
        {
            var factory = new PersonFactory();

            Console.Write("Enter an id: ");
            var input = Console.ReadKey(true);

            var key = input.KeyChar.ToString();

            int id;

            if (int.TryParse(key, out id))
            {
                Person person = factory.GetPersonById(id);

                if (person != null)
                {
                    Console.WriteLine("Hello World! " + String.Format("This is {0} {1}", person.FirstName, person.LastName));
                }
                else
                {
                    Console.WriteLine("Person doesn't exist");
                }
            }
            else
            {
                Console.WriteLine("id is not correct");
            }

            Console.ReadKey(true);
        }
        public async Task GetByUserIdAsync_CallsRepoWithCorrectArgs()
        {
            var userId = 1;
            var projectionExpression = PersonFactory.GetPersonById(userId);

            var result = await _personService.GetByUserIdAsync(userId);

            await _personRepository
            .ReceivedWithAnyArgs()
            .GetByUserIdAsync(projectionExpression, PersonFactory.GetPersonOrganization);
        }
Пример #5
0
        public Task <PersonOrganization> GetByUserIdAsync(long userId)
        {
            Expression <Func <Person, bool> > projectionExpression = PersonFactory.GetPersonById(userId);

            return(_personRepository.GetByUserIdAsync(projectionExpression, PersonFactory.GetPersonOrganization));
        }