Exemple #1
0
        public void enumerable_whereIf_tests()
        {
            IEnumerable <User> users;

            users = Sources.getUsers()
                    .whereIf(true, u => u.Age > 30)
                    .whereIf(false, u => u.Age < 50);

            Assert.AreEqual(3, users.Count());

            users = users.whereIfStringIsFilled(null, u => u.Age < 50);
            Assert.AreEqual(3, users.Count());

            users = users.whereIfStringIsFilled("", u => u.Age < 50);
            Assert.AreEqual(3, users.Count());

            users = users.whereIfStringIsFilled("pepe", u => u.Age < 50);
            Assert.AreEqual(1, users.Count());
        }
Exemple #2
0
        public void enumerable_tests()
        {
            User[] sortedUsers, unsortedUsers;

            unsortedUsers = Sources
                            .getUsers()
                            .ToArray();

            sortedUsers = Sources
                          .getUsers()
                          .orderBy(u => u.Age, OrderDirection.Descendant)
                          .thenBy(u => u.SurName, OrderDirection.Ascendant)
                          .ToArray();

            Assert.ReferenceEquals(unsortedUsers[0], sortedUsers[3]);
            Assert.ReferenceEquals(unsortedUsers[1], sortedUsers[1]);
            Assert.ReferenceEquals(unsortedUsers[2], sortedUsers[0]);
            Assert.ReferenceEquals(unsortedUsers[3], sortedUsers[2]);
        }
Exemple #3
0
        public void string_enumerables_tests()
        {
            string[] strings;

            strings = Sources
                      .getStrings()
                      .notNull()
                      .trim()
                      .ToArray();

            Assert.AreEqual(6, strings.Length);
            Assert.AreEqual("pepe", strings[2]);
            Assert.AreEqual("tronco", strings[4]);

            strings = strings
                      .notEmpty()
                      .ToArray();

            Assert.AreEqual(2, strings.Length);
            Assert.AreEqual("pepe", strings[0]);
            Assert.AreEqual("tronco", strings[1]);
        }