コード例 #1
0
        private static void BasicLinqExample()
        {
            var basicLinq = new BasicLinq();

            basicLinq.Run();

            Console.ReadKey();
        }
コード例 #2
0
        public void IncludePersonWithNameAbby_EmptyList_ReturnsFalse()
        {
            // Arrange
            var people = TestData.NoPeople;

            //Act
            var includesPerson = BasicLinq.IncludesPersonWithName(people, "Abby");

            //Assert
            includesPerson.Should().BeFalse();
        }
コード例 #3
0
        public void FindOldestPerson_LotsOfPeople_ReturnsFelicityPlott()
        {
            // Arrange
            var people = TestData.LotsOfPeople;

            //Act
            var oldestPerson = BasicLinq.FindOldestPerson(people);

            //Assert
            oldestPerson.Should().BeEquivalentTo(new Person("Felicity", "Plott", new List <string>(), new DateTime(1800, 4, 5), 99, Colour.Blue, "London"));
        }
コード例 #4
0
        public void FindOldestPerson_AllThePeople_ReturnsPerson()
        {
            // Arrange
            var people = TestData.AllThePeople;

            //Act
            var oldestPerson = BasicLinq.FindOldestPerson(people);

            //Assert
            oldestPerson.Should().NotBeNull();
        }
コード例 #5
0
        public void GetFirstNamesOfPeople_SinglePerson_ReturnsListWithSingleName()
        {
            // Arrange
            var people = TestData.AbbySmith;

            //Act
            var names = BasicLinq.GetFirstNamesOfPeople(people);

            //Assert
            names.Should().ContainSingle().Subject.Should().Be("Abby");
        }
コード例 #6
0
        public void IncludePersonWithNameBob_AbbySmith_ReturnsTrue()
        {
            // Arrange
            var people = TestData.AbbySmith;

            //Act
            var includesPerson = BasicLinq.IncludesPersonWithName(people, "Bob");

            //Assert
            includesPerson.Should().BeFalse();
        }
コード例 #7
0
        public void GetFirstNamesOfPeople_EmptyList_ReturnsEmptyList()
        {
            // Arrange
            var people = TestData.NoPeople;

            //Act
            var names = BasicLinq.GetFirstNamesOfPeople(people);

            //Assert
            names.Should().BeEmpty();
        }
コード例 #8
0
        public void IncludePersonWithNameFelicity_LotsOfPeople_ReturnsTrue()
        {
            // Arrange
            var people = TestData.LotsOfPeople;

            //Act
            var includesPerson = BasicLinq.IncludesPersonWithName(people, "Felicity");

            //Assert
            includesPerson.Should().BeTrue();
        }
コード例 #9
0
        public void IncludePersonWithNameEll_LotsOfPeople_ReturnsFalse()
        {
            // Arrange
            var people = TestData.LotsOfPeople;

            //Act
            var includesPerson = BasicLinq.IncludesPersonWithName(people, "Ell");

            //Assert
            includesPerson.Should().BeFalse();
        }
コード例 #10
0
        public void OrderByAgeDescending_EmptyList_ReturnsEmptyList()
        {
            // Arrange
            var people = TestData.NoPeople;

            //Act
            var orderedPeople = BasicLinq.OrderByAgeDescending(people);

            //Assert
            orderedPeople.Should().BeEmpty();
        }
コード例 #11
0
        public void FindOldestPerson_EmptyList_ReturnsNull()
        {
            // Arrange
            var people = TestData.NoPeople;

            //Act
            var oldestPerson = BasicLinq.FindOldestPerson(people);

            //Assert
            oldestPerson.Should().BeNull();
        }
コード例 #12
0
        public void GetPeopleOlderThan30_AbbySmith_ReturnsEmptyList()
        {
            // Arrange
            var       people    = TestData.AbbySmith;
            const int cutOffAge = 30;

            //Act
            var peopleOlderThanCutOffAge = BasicLinq.GetPeopleOlderThan(people, cutOffAge);

            //Assert
            peopleOlderThanCutOffAge.Should().BeEmpty();
        }
コード例 #13
0
        public void GetPeopleOlderThan10_EmptyList_ReturnsEmptyList()
        {
            // Arrange
            var       people    = TestData.NoPeople;
            const int cutOffAge = 10;

            //Act
            var peopleOlderThanCutOffAge = BasicLinq.GetPeopleOlderThan(people, cutOffAge);

            //Assert
            peopleOlderThanCutOffAge.Should().BeEmpty();
        }
コード例 #14
0
        public void FindOldestPerson_AbbySmith_ReturnsAbbySmith()
        {
            // Arrange
            var people = TestData.AbbySmith;

            //Act
            var oldestPerson = BasicLinq.FindOldestPerson(people);

            //Assert
            oldestPerson.Should().BeEquivalentTo(new Person("Abby", "Smith", new List <string> {
                "Olivia"
            }, new DateTime(1990, 1, 5), 29, Colour.Blue, "Leeds"));
        }
コード例 #15
0
        public void OrderByAgeAscending_AbbySmith_ReturnsAbbySmith()
        {
            // Arrange
            var people = TestData.AbbySmith;

            //Act
            var orderedPeople = BasicLinq.OrderByAgeAscending(people);

            //Assert
            orderedPeople.Should().BeInAscendingOrder(person => person.Age);
            orderedPeople.Should().HaveCount(people.Count);
            //Equivalent to ignores order
            orderedPeople.Should().BeEquivalentTo(people);
        }
コード例 #16
0
        public void OrderByAgeDescending_LotsOfPeople_ReturnsOrderedList()
        {
            // Arrange
            var people = TestData.LotsOfPeople;

            //Act
            var orderedPeople = BasicLinq.OrderByAgeDescending(people);

            //Assert
            orderedPeople.Should().BeInDescendingOrder(person => person.Age);
            orderedPeople.Should().HaveCount(people.Count);
            //Equivalent to ignores order
            orderedPeople.Should().BeEquivalentTo(people);
        }
コード例 #17
0
        public void GetPeopleOlderThan29_AbbySmith_ReturnsAbbySmith()
        {
            // Arrange
            var       people    = TestData.AbbySmith;
            const int cutOffAge = 29;

            //Act
            var peopleOlderThanCutOffAge = BasicLinq.GetPeopleOlderThan(people, cutOffAge);

            //Assert
            var person = peopleOlderThanCutOffAge.Should().ContainSingle().Subject;

            person.FirstName.Should().Be("Abby");
            person.LastName.Should().Be("Smith");
        }
コード例 #18
0
        public void GetPeopleOlderThan18_LotsOfPeople_ReturnsPeopleOlderThan18()
        {
            // Arrange
            var       people    = TestData.LotsOfPeople;
            const int cutOffAge = 18;

            //Act
            var peopleOlderThanCutOffAge = BasicLinq.GetPeopleOlderThan(people, cutOffAge);

            //Assert
            peopleOlderThanCutOffAge.Should().HaveCount(8);
            peopleOlderThanCutOffAge.Should().BeEquivalentTo(new List <Person>
            {
                new Person("Abby", "Smith", new List <string> {
                    "Olivia"
                }, new DateTime(1990, 1, 5), 29, Colour.Blue, "Leeds"),
                new Person("Dani", "Hayes", new List <string> {
                    "Holmes", "Reed"
                }, new DateTime(1986, 6, 5), 55, Colour.Blue, "Sheffield"),
                new Person("Ellie", "Ball", new List <string> {
                    "Hunt"
                }, new DateTime(1975, 7, 5), 37, Colour.Blue, "Leeds"),
                new Person("Felicity", "Plott", new List <string>(), new DateTime(1800, 4, 5), 99, Colour.Blue, "London"),
                new Person("George", "Hayes", new List <string> {
                    "Olivia"
                }, new DateTime(1925, 10, 5), 74, Colour.Blue, "Leeds"),
                new Person("Ismail", "Ray", new List <string> {
                    "Francis", null
                }, new DateTime(2200, 9, 5), 46, Colour.Green, "Leeds"),
                new Person("Jake", "Smith", new List <string> {
                    "\n"
                }, new DateTime(1995, 3, 5), 18, Colour.Blue, "Nowhere"),
                new Person("Lenny", "Smith", new List <string> {
                    "1231914=9123812=03&&&%%%"
                }, new DateTime(1990, 1, 5), 18, Colour.Blue, "Leeds")
            });
        }
コード例 #19
0
        public void GetFirstNamesOfPeople_LotsOfPeople_ReturnsListWithAllNames()
        {
            // Arrange
            var people = TestData.LotsOfPeople;

            //Act
            var names = BasicLinq.GetFirstNamesOfPeople(people);

            //Assert
            names.Should().BeEquivalentTo(new List <string>
            {
                "Abby",
                "Bob",
                "Charlie",
                "Dani",
                "Ellie",
                "Felicity",
                "George",
                "Hannah",
                "Ismail",
                "Jake",
                "Lenny"
            });
        }