public void TestJoinWithNull()
 {
     names.Add("Nasko");
     names.Add("Ivan");
     names.Add("Gosho");
     names.JoinWith(null);
 }
        public void TestRemoveValidElementRemovesSelectedOne()
        {
            this.names.Add("Ivan");
            this.names.Add("Nasko");

            this.names.Remove("Ivan");
            var result = names.JoinWith("");

            Assert.AreNotEqual("Nasko", result);
        }
        public override void Execute()
        {
            if (this.Data.Length != 3)
            {
                throw new InvalidCommandException(this.Input);
            }

            string entityToDisplay = this.Data[1];
            string sortType        = this.Data[2];

            if (entityToDisplay.Equals("students", StringComparison.OrdinalIgnoreCase))
            {
                Comparison <Student>        studentComparison = this.CreateStudentComparison(sortType);
                ISimpleOrderedBag <Student> sortedStudents    = this.repository.GetAllStudentsSorted(studentComparison);
                OutputWriter.WriteMessageOnNewLine(sortedStudents.JoinWith(Environment.NewLine));
            }
            else if (entityToDisplay.Equals("courses", StringComparison.OrdinalIgnoreCase))
            {
                Comparison <Course>        courseComparison = this.CreateCourseComparison(sortType);
                ISimpleOrderedBag <Course> sortedCourses    = this.repository.GetAllCoursesSorted(courseComparison);
                OutputWriter.WriteMessageOnNewLine(sortedCourses.JoinWith(Environment.NewLine));
            }
            else
            {
                throw new InvalidCommandException(this.Input);
            }
        }
        public void Execute()
        {
            if (this.data.Length != 3)
            {
                throw new InvalidCommandException(this.input);
            }

            string entityToDisplay = this.data[1];
            string sortType        = this.data[2];

            if (entityToDisplay.Equals("students", StringComparison.OrdinalIgnoreCase))
            {
                IComparer <IStudent>         studentComparator = this.CreateStudentComparator(sortType);
                ISimpleOrderedBag <IStudent> list = this.repository.GetAllStudentsSorted(studentComparator);
                OutputWriter.WriteMessageOnNewLine(list.JoinWith(Environment.NewLine));
            }
            else if (entityToDisplay.Equals("courses", StringComparison.OrdinalIgnoreCase))
            {
                IComparer <ICourse>         courseComparator = this.CreateCourseComparator(sortType);
                ISimpleOrderedBag <ICourse> list             = this.repository.GetAllCoursesSorted(courseComparator);
                OutputWriter.WriteMessageOnNewLine(list.JoinWith(Environment.NewLine));
            }
            else
            {
                throw new InvalidCommandException(this.input);
            }
        }
Example #5
0
        public override void Execute()
        {
            string[] data = this.Data;
            if (data.Length != 3)
            {
                throw new InvalidOperationException(this.Input);
            }

            var entityToDisplay = data[1];
            var sortType        = data[2];

            if (entityToDisplay.Equals("students", StringComparison.OrdinalIgnoreCase))
            {
                IComparer <Student>         studentComparator = this.CreateStudentComparator(sortType);
                ISimpleOrderedBag <Student> list = this.repository.GetAllStudentsSorted(studentComparator);
                OutputWriter.WriteMessageOnNewLine(list.JoinWith(Environment.NewLine));
            }
            else if (entityToDisplay.Equals("courses", StringComparison.OrdinalIgnoreCase))
            {
                IComparer <Course>         courseComparator = this.CreateCourseComparator(sortType);
                ISimpleOrderedBag <Course> list             = this.repository.GetAllCoursesSorted(courseComparator);
                OutputWriter.WriteMessageOnNewLine(list.JoinWith(Environment.NewLine));
            }
            else
            {
                throw new InvalidOperationException(this.Input);
            }
        }
Example #6
0
        public override void Execute()
        {
            if (this.Data.Length != 3)
            {
                throw new InvalidCommandException(this.Input);
            }

            string entityToDisplay = this.Data[1].ToLower();
            string sortType        = this.Data[2].ToLower();

            switch (entityToDisplay)
            {
            case "students":
                IComparer <IStudent>         studentComparator = this.CreateStudentComparator(sortType);
                ISimpleOrderedBag <IStudent> studentList       = this.repository.GetAllStudentsSorted(studentComparator);
                OutputWriter.DisplayStudentMessage(studentList.JoinWith(Environment.NewLine));
                break;

            case "courses":
                IComparer <ICourse>         courseComparator = this.CreateCourseComparator(sortType);
                ISimpleOrderedBag <ICourse> courseList       = this.repository.GetAllCoursesSorted(courseComparator);
                OutputWriter.DisplayCourseMessage(courseList.JoinWith(Environment.NewLine));
                break;

            default:
                throw new InvalidCommandException(this.Input);
            }
        }
        public void JoinWithNull()
        {
            //Arrange
            this.names.AddAll(new string[] { "1", "2", "3" });

            //Act
            names.JoinWith(null);
        }
Example #8
0
        public void TestJoinWorksFine()
        {
            this.names = new SimpleSortedList <string>();
            this.names.AddAll(new string[] { "ivan", "nasko" });
            string joinedNames = names.JoinWith(", ");

            Assert.That(joinedNames, Is.EqualTo("ivan, nasko"));
        }
        public void TestJoinWithNull()
        {
            this.names = new SimpleSortedList <string>();
            string[] input = new string[] { "aaaaa", "cccc", "BBBB", "dd", "eeee" };

            names.AddAll(input);

            Assert.That(() => names.JoinWith(null), Throws.ArgumentNullException);
        }
        public void TestJoinWorksFine(string separator)
        {
            this.names = new SimpleSortedList <string>();
            string[] input = new string[] { "aaaaa", "cccc", "BBBB", "dd", "eeee" };

            names.AddAll(input);
            string result = names.JoinWith(separator);

            Assert.That(result, Is.EqualTo(string.Join(separator, input.OrderBy(n => n))));
        }
Example #11
0
        public void TestJoinWithMethodWorksFine(string joiner)
        {
            string[] allStarsCollection = new string[] { "Ivan", "Nasko", "Blagovest", "Stamat", "Pesho" };

            names.AddAll(allStarsCollection);

            string expectedJoinResult = string.Join(joiner, this.names);

            string namesJoinerResult = names.JoinWith(joiner);

            Assert.AreEqual(expectedJoinResult, namesJoinerResult);
        }
Example #12
0
 public void TestJoinWithNull()
 {
     this.names = new SimpleSortedList <string>();
     this.names.AddAll(new string[] { "ivan", "nasko" });
     Assert.Throws <ArgumentNullException>(() => names.JoinWith(null));
 }
Example #13
0
 public void TestJoinWtihNull()
 {
     Assert.Throws <ArgumentNullException>(() => names.JoinWith(null));
 }