Exemple #1
0
    public void SortNamesTest()
    {
        List <PersonDetail> sortedTestList = new List <PersonDetail>();

        sortedTestList.Add(new PersonDetail {
            GivenName = "Jeff", LastName = "Bezos"
        });
        sortedTestList.Add(new PersonDetail {
            GivenName = "Bill", LastName = "Gates"
        });
        sortedTestList.Add(new PersonDetail {
            GivenName = "Elon", LastName = "Musk"
        });
        NameSorter nameSorter = new NameSorter();

        nameSorter._nameList.Add(new PersonDetail {
            GivenName = "Elon", LastName = "Musk"
        });
        nameSorter._nameList.Add(new PersonDetail {
            GivenName = "Bill", LastName = "Gates"
        });
        nameSorter._nameList.Add(new PersonDetail {
            GivenName = "Jeff", LastName = "Bezos"
        });

        nameSorter.SortNames();
        sortedTestList.Should().BeEquivalentTo(nameSorter.GetNames());
    }
Exemple #2
0
        public void TestValidNameSort(IName[] unsortedNames, IName[] expectedResult)
        {
            // Quick check to make sure that the test is valid (unsorted and expected result are same length)
            Assert.Equal(unsortedNames.Length, expectedResult.Length);

            // Arrange
            var nameSorter = new NameSorter();

            // Act
            var sortedNames = nameSorter.SortNames(unsortedNames.ToList(), stringComparer);

            // Assert
            Assert.Equal(expectedResult, sortedNames);
        }
Exemple #3
0
        public void GivenNothingReturnsNothing()
        {
            var nobody = new string[0];

            Assert.Equal("", String.Join(" ", _nameSorter.SortNames(nobody)));
        }