Example #1
0
        public void PersonNameConverter_ConvertsToRawStringCorrectly(string givenNames, string lastName, string expected)
        {
            // init the objects
            PersonNameConverter converter  = new PersonNameConverter();
            PersonName          personName = new PersonName();

            // perform the operation that is being tested.
            personName.givenNames = givenNames;
            personName.lastName   = lastName;

            // if the input and the result are equal both methods worked.
            Assert.Equal(expected, converter.PersonNameToString(personName));
        }
Example #2
0
        public void PersonNameConverter_ConvertsToPersonNameCorrectly(string givenNames, string lastName)
        {
            // init the objects
            PersonNameConverter converter  = new PersonNameConverter();
            PersonName          personName = new PersonName();

            // perform the operation that is being tested.
            personName = converter.StringToPersonName(givenNames + ' ' + lastName);

            // if the input and the result are equal both methods worked.
            Assert.Equal(personName.givenNames, givenNames);
            Assert.Equal(personName.lastName, lastName);
        }
Example #3
0
        private void AddChildExecute(object obj)
        {
            var child = new Person
            {
                FirstName = "Child of",
                LastName  = PersonNameConverter.GetFullNameOfPerson(Person)
            };
            var ok = EditAction != null && EditAction(child);

            if (!ok)
            {
                return;
            }
            // Ask the user about the name of the new child and her/his data
            LocalDataStorage.Instance.AddChild(Person, child);
        }
Example #4
0
        public void PersonNameConverter_PerformSortCorrectly( )
        {
            PersonNameConverter converter = new PersonNameConverter();
            NameSorter          sorter    = new NameSorter();

            // Define the test input and expected result
            string[] rawNames       = { "Homer Jay Simpson", "Bart Simpson", "Ned Flanders", "Milhouse Van Houten" };
            string[] expectedResult = { "Ned Flanders", "Milhouse Van Houten", "Bart Simpson", "Homer Jay Simpson" };

            // create the list of PersonNames to sort
            List <PersonName> personNames = converter.StringArrayToPersonNameList(rawNames);

            // perfome the operation that is being tested. The sort operation.
            personNames = sorter.SortByLastNameThenFirstName(personNames);

            // if the input and the result are equal both methods worked.
            Assert.Equal(expectedResult, converter.PersonNameListToStringArray(personNames));
        }