예제 #1
0
        public void FindWithActivePhonesWithoutStorageTest()
        {
            var user = new User
            {
                Id    = 1,
                Login = "******"
            };

            user.Contacts.Add(new Phone {
                IsActive = true, PhoneNumber = "123-321"
            });

            var specification = new ActivePhonesSpecification();

            Assert.IsTrue(specification.IsSatisfiedBy.Compile().Invoke(user));
        }
예제 #2
0
        public void FindWithActivePhonesTest()
        {
            var user = new User
            {
                Id    = 1,
                Login = "******"
            };

            user.Contacts.Add(new Phone {
                IsActive = true, PhoneNumber = "123-321"
            });

            var queryable = new[] { user }.AsQueryable();

            var specification = new ActivePhonesSpecification();
            var result        = queryable.Where(specification.IsSatisfiedBy);

            CollectionAssert.AreEquivalent(new[] { 1 }, result.Select(o => o.Id));
        }