コード例 #1
0
        public void NamesOfPeopleOlderThanThirty_AbbySmith_ReturnsEmpty()
        {
            // Arrange
            var people = TestData.AbbySmith;

            //Act
            var peopleOlderThan = IntermediateLinq.NamesOfPeopleOlderThan(people, 30);

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

            //Act
            var peopleWithOtherNames = IntermediateLinq.PeopleWithOtherNames(people);

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

            //Act
            var peopleOlderThan = IntermediateLinq.NamesOfPeopleOlderThan(people, 20);

            //Assert
            peopleOlderThan.Should().BeEmpty();
        }
コード例 #4
0
        public void NamesOfPeopleOlderThanTwenty_AllThePeople_ReturnsPeople()
        {
            // Arrange
            var people = TestData.AllThePeople;

            //Act
            var peopleOlderThan = IntermediateLinq.NamesOfPeopleOlderThan(people, 20);

            //Assert
            peopleOlderThan.Should().NotBeNull();
        }
コード例 #5
0
        public void CombinePeople_EmptyLists_ReturnsEmptyList()
        {
            // Arrange
            var firstList  = TestData.NoPeople;
            var secondList = TestData.NoPeople;

            //Act
            var combinedPeople = IntermediateLinq.CombinePeople(firstList, secondList);

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

            //Act
            var peopleWithOtherNames = IntermediateLinq.PeopleWithOtherNames(people);

            //Assert
            peopleWithOtherNames.Should().HaveCount(1);
            peopleWithOtherNames.Should().BeEquivalentTo(TestData.AbbySmith);
        }
コード例 #7
0
        public void NamesOfPeopleOlderThanTwenty_AbbySmith_ReturnsAbbySmith()
        {
            // Arrange
            var people = TestData.AbbySmith;

            //Act
            var peopleOlderThan = IntermediateLinq.NamesOfPeopleOlderThan(people, 20);

            //Assert
            peopleOlderThan.Should().HaveCount(TestData.AbbySmith.Count);
            peopleOlderThan.Should().BeEquivalentTo("Abby");
        }
コード例 #8
0
        public void CalculateHowManyPeopleLiveInLeeds_LotsOfPeople_ReturnsSix()
        {
            // Arrange
            const string place = "Leeds";

            var people = TestData.LotsOfPeople;

            //Act
            var peopleLivingInLeeds = IntermediateLinq.CalculateHowManyPeopleLiveIn(people, place);

            //Assert
            peopleLivingInLeeds.Should().Be(6);
        }
コード例 #9
0
        public void CombinePeople_LotsOfPeopleAndEmptyList_ReturnsLotsOfPeople()
        {
            // Arrange
            var firstList  = TestData.LotsOfPeople;
            var secondList = TestData.NoPeople;

            //Act
            var combinedPeople = IntermediateLinq.CombinePeople(firstList, secondList);

            //Assert
            combinedPeople.Should().HaveCount(TestData.LotsOfPeople.Count);
            combinedPeople.Should().BeEquivalentTo(TestData.LotsOfPeople);
        }
コード例 #10
0
        public void FindPeopleWhosFavouriteColourIsRed_EmptyList_ReturnsEmptyList()
        {
            // Arrange
            var favouriteColour = Colour.Red;

            var people = TestData.NoPeople;

            //Act
            var peopleWithFavouriteColour = IntermediateLinq.FindPeopleWhosFavouriteColourIs(people, favouriteColour);

            //Assert
            peopleWithFavouriteColour.Should().BeEmpty();
        }
コード例 #11
0
        public void PeopleWithOtherNamesOf_EmptyList_ReturnsEmptyList()
        {
            // Arrange
            const string name = "Olivia";

            var people = TestData.NoPeople;

            //Act
            var peopleWithOtherNames = IntermediateLinq.PeopleWithOtherNameOf(people, name);

            //Assert
            peopleWithOtherNames.Should().BeEmpty();
        }
コード例 #12
0
        public void CalculateHowManyPeopleLiveInLeeds_EmptyList_ReturnsZero()
        {
            // Arrange
            const string place = "Leeds";

            var people = TestData.NoPeople;

            //Act
            var peopleLivingInLeeds = IntermediateLinq.CalculateHowManyPeopleLiveIn(people, place);

            //Assert
            peopleLivingInLeeds.Should().Be(0);
        }
コード例 #13
0
        public void CalculateHowManyPeopleLiveInLeeds_AbbySmith_ReturnsOne()
        {
            // Arrange
            const string place = "Leeds";

            var people = TestData.AbbySmith;

            //Act
            var peopleLivingInLeeds = IntermediateLinq.CalculateHowManyPeopleLiveIn(people, place);

            //Assert
            peopleLivingInLeeds.Should().Be(1);
        }
コード例 #14
0
        public void FindPeopleWhosFavouriteColourIsBlue_AbbySmith_ReturnsAbbySmith()
        {
            // Arrange
            var favouriteColour = Colour.Blue;

            var people = TestData.AbbySmith;

            //Act
            var peopleWithFavouriteColour = IntermediateLinq.FindPeopleWhosFavouriteColourIs(people, favouriteColour);

            //Assert
            peopleWithFavouriteColour.Should().HaveCount(1);
            peopleWithFavouriteColour.Should().BeEquivalentTo(TestData.AbbySmith);
        }
        public void DoesSomeoneExistWhoIsOverAgeFiftyWithFavouriteColourOfGreen_LotsOfPeople_ReturnsFalse()
        {
            // Arrange
            const int age             = 50;
            var       favouriteColour = Colour.Green;

            var people = TestData.LotsOfPeople;

            //Act
            var peopleWithFavouriteColour = IntermediateLinq.DoesSomeoneExistWhoIsOverAgeWithFavouriteColourOf(people, age, favouriteColour);

            //Assert
            peopleWithFavouriteColour.Should().BeFalse();
        }
コード例 #16
0
        public void PeopleWithOtherNamesOfOlivia_AbbySmith_ReturnsAbbySmith()
        {
            // Arrange
            const string name = "Olivia";

            var people = TestData.AbbySmith;

            //Act
            var peopleWithOtherNames = IntermediateLinq.PeopleWithOtherNameOf(people, name);

            //Assert
            peopleWithOtherNames.Should().HaveCount(1);
            peopleWithOtherNames.Should().BeEquivalentTo(TestData.AbbySmith);
        }
        public void DoesSomeoneExistWhoIsOverAgeTwentyWithFavouriteColourOfBlue_LotsOfPeople_ReturnsTrue()
        {
            // Arrange
            const int age             = 20;
            var       favouriteColour = Colour.Blue;

            var people = TestData.LotsOfPeople;

            //Act
            var peopleWithFavouriteColour = IntermediateLinq.DoesSomeoneExistWhoIsOverAgeWithFavouriteColourOf(people, age, favouriteColour);

            //Assert
            peopleWithFavouriteColour.Should().BeTrue();
        }
        public void DoesSomeoneExistWhoIsOverAgeTwentyWithFavouriteColourOfRed_EmptyList_ReturnsFalse()
        {
            // Arrange
            const int age             = 20;
            var       favouriteColour = Colour.Red;

            var people = TestData.NoPeople;

            //Act
            var peopleWithFavouriteColour = IntermediateLinq.DoesSomeoneExistWhoIsOverAgeWithFavouriteColourOf(people, age, favouriteColour);

            //Assert
            peopleWithFavouriteColour.Should().BeFalse();
        }
コード例 #19
0
        public void CombinePeople_AbbySmithAndLotsOfPeople_ReturnsCombinedList()
        {
            // Arrange
            var firstList         = TestData.AbbySmith;
            var secondList        = TestData.LotsOfPeople;
            var combinedListCount = TestData.AbbySmith.Count + TestData.LotsOfPeople.Count;

            //Act
            var combinedPeople = IntermediateLinq.CombinePeople(firstList, secondList);

            //Assert
            combinedPeople.Should().HaveCount(combinedListCount);
            combinedPeople.Should().Contain(TestData.AbbySmith.FirstOrDefault());
        }
コード例 #20
0
        public void FindPeopleWhosFavouriteColourIsOrange_LotsOfPeople_ReturnsBobHumphrey()
        {
            // Arrange
            var favouriteColour = Colour.Orange;

            var people = TestData.LotsOfPeople;

            //Act
            var peopleWithFavouriteColour = IntermediateLinq.FindPeopleWhosFavouriteColourIs(people, favouriteColour);

            //Assert
            peopleWithFavouriteColour.Should().HaveCount(1);
            peopleWithFavouriteColour.Should().BeEquivalentTo(new List <Person>
            {
                new Person("Bob", "Humphrey", new List <string>(), new DateTime(1956, 12, 5), 12, Colour.Orange, "Leeds")
            });
        }
コード例 #21
0
        public void FindPeopleWhosFavouriteColourIsPurple_LotsOfPeople_ReturnsCharliePaul()
        {
            // Arrange
            var favouriteColour = Colour.Purple;

            var people = TestData.LotsOfPeople;

            //Act
            var peopleWithFavouriteColour = IntermediateLinq.FindPeopleWhosFavouriteColourIs(people, favouriteColour);

            //Assert
            peopleWithFavouriteColour.Should().HaveCount(1);
            peopleWithFavouriteColour.Should().BeEquivalentTo(new List <Person>
            {
                new Person("Charlie", "Paul", null, new DateTime(2009, 5, 5), 10, Colour.Purple, "Lancaster")
            });
        }
コード例 #22
0
        public void PeopleWithOtherNamesOfFrancis_LotsOfPeople_ReturnsIsmailRay()
        {
            // Arrange
            const string name = "Francis";

            var people = TestData.LotsOfPeople;

            //Act
            var peopleWithOtherNames = IntermediateLinq.PeopleWithOtherNameOf(people, name);

            //Assert
            peopleWithOtherNames.Should().HaveCount(1);
            peopleWithOtherNames.Should().BeEquivalentTo(new List <Person>
            {
                new Person("Ismail", "Ray", new List <string> {
                    "Francis", null
                }, new DateTime(2200, 9, 5), 46, Colour.Green, "Leeds")
            });
        }
コード例 #23
0
        public void FindPeopleWhosFavouriteColourIsGreen_LotsOfPeople_ReturnsIsmailRay()
        {
            // Arrange
            var favouriteColour = Colour.Green;

            var people = TestData.LotsOfPeople;

            //Act
            var peopleWithFavouriteColour = IntermediateLinq.FindPeopleWhosFavouriteColourIs(people, favouriteColour);

            //Assert
            peopleWithFavouriteColour.Should().HaveCount(1);
            peopleWithFavouriteColour.Should().BeEquivalentTo(new List <Person>
            {
                new Person("Ismail", "Ray", new List <string> {
                    "Francis", null
                }, new DateTime(2200, 9, 5), 46, Colour.Green, "Leeds")
            });
        }
コード例 #24
0
        public void NamesOfPeopleOlderThanTwentyFive_LotsOfPeople_ReturnsCorrectPeople()
        {
            // Arrange
            const int expectedCount = 6;

            var people = TestData.LotsOfPeople;

            //Act
            var peopleOlderThan = IntermediateLinq.NamesOfPeopleOlderThan(people, 25);

            //Assert
            peopleOlderThan.Should().HaveCount(expectedCount);
            peopleOlderThan.Should().Contain("Abby");
            peopleOlderThan.Should().Contain("Dani");
            peopleOlderThan.Should().Contain("Ellie");
            peopleOlderThan.Should().Contain("Felicity");
            peopleOlderThan.Should().Contain("George");
            peopleOlderThan.Should().Contain("Ismail");
        }
コード例 #25
0
        public void PeopleWithOtherNamesOfOlivia_LotsOfPeople_ReturnsCorrectPeople()
        {
            // Arrange
            const string name = "Olivia";

            var people = TestData.LotsOfPeople;

            //Act
            var peopleWithOtherNames = IntermediateLinq.PeopleWithOtherNameOf(people, name);

            //Assert
            peopleWithOtherNames.Should().HaveCount(2);
            peopleWithOtherNames.Should().BeEquivalentTo(new List <Person>
            {
                new Person("Abby", "Smith", new List <string> {
                    "Olivia"
                }, new DateTime(1990, 1, 5), 29, Colour.Blue, "Leeds"),
                new Person("George", "Hayes", new List <string> {
                    "Olivia"
                }, new DateTime(1925, 10, 5), 74, Colour.Blue, "Leeds")
            });
        }
コード例 #26
0
        public void PeopleWithOtherNames_LotsOfPeople_ReturnsCorrectPeople()
        {
            // Arrange
            var people = TestData.LotsOfPeople;

            //Act
            var peopleWithOtherNames = IntermediateLinq.PeopleWithOtherNames(people);

            //Assert
            peopleWithOtherNames.Should().HaveCount(8);
            peopleWithOtherNames.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("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("Hannah", "Baller", new List <string> {
                    "Nelson", "Hunt", "Reed"
                }, new DateTime(1950, 1, 5), 5, Colour.Blue, "London"),
                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")
            });
        }
コード例 #27
0
        public void FindPeopleWhosFavouriteColourIsBlue_LotsOfPeople_ReturnsCorrectPeople()
        {
            // Arrange
            var favouriteColour = Colour.Blue;

            var people = TestData.LotsOfPeople;

            //Act
            var peopleWithFavouriteColour = IntermediateLinq.FindPeopleWhosFavouriteColourIs(people, favouriteColour);

            //Assert
            peopleWithFavouriteColour.Should().HaveCount(8);
            peopleWithFavouriteColour.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("Hannah", "Baller", new List <string> {
                    "Nelson", "Hunt", "Reed"
                }, new DateTime(1950, 1, 5), 5, Colour.Blue, "London"),
                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")
            });
        }