Exemplo n.º 1
0
        public void OrderByDescending_IEnumerable_OrdersCorrectly()
        {
            _customers = new List <Customer>
            {
                TestHelper.Bobby(),
                    TestHelper.Billy(),
                    TestHelper.Bobby(),
            };

            var order = new CustomerTestOrder().ByNameDescending();

            var result = _customers.NPredicateBuilderOrder(order);

            Assert.AreEqual("Billy", result.Last().Name);
        }
Exemplo n.º 2
0
        public void OrderBy_IQueryable_OrdersCorrectly()
        {
            _customers = new List <Customer>
            {
                TestHelper.Bobby(),
                    TestHelper.Billy(),
                    TestHelper.Bobby(),
            };

            var order = new CustomerTestOrder().ByName();

            var result = _customers.AsQueryable().NPredicateBuilderEFOrder(order);

            Assert.AreEqual("Billy", result.First().Name);
        }
Exemplo n.º 3
0
        public void ThenBy_IQueryable_OrdersCorrectly()
        {
            _customers = new List <Customer>
            {
                new Customer(Guid.NewGuid(), "Bobby", 30),
                new Customer(Guid.NewGuid(), "Billy", 30),
                new Customer(Guid.NewGuid(), "Billy", 20),
            };

            var order = new CustomerTestOrder()
                        .ByName()
                        .ThenByAge();

            var result = _customers.AsQueryable().NPredicateBuilderEFOrder(order);

            Assert.AreEqual("Billy", result.First().Name);
            Assert.AreEqual(20, result.First().Age);
        }
Exemplo n.º 4
0
        public void ThenByDescending_IEnumerable_OrdersCorrectly()
        {
            _customers = new List <Customer>
            {
                new Customer(Guid.NewGuid(), "Bobby", 30),
                new Customer(Guid.NewGuid(), "Billy", 30),
                new Customer(Guid.NewGuid(), "Billy", 20),
            };

            var order = new CustomerTestOrder()
                        .ByName()
                        .ThenByAgeDescending();

            var result = _customers.NPredicateBuilderOrder(order);

            Assert.AreEqual("Billy", result.First().Name);
            Assert.AreEqual(30, result.First().Age);
        }