Example #1
0
        public void TestMethod1()
        {
            // ordena conjunto Título ascendente
            var bsv = _ol.OrderBooksToVerbose("title ASC");

            Assert.AreEqual(bsv, "Livros 3, 4, 1, 2");
        }
Example #2
0
        static void Main(string[] args)
        {
            OrdenacaoLivros ol = new OrdenacaoLivros();

            Console.WriteLine("default:");

            foreach (var book in ol.livros)
            {
                Console.WriteLine("{0} {1} {2} {3}", book.Id.ToString(), book.Title, book.Author, book.Edition);
            }
            Console.WriteLine(ol.OrderBooksToVerbose());

            ol.OrderBooks("title ASC");
            Console.WriteLine("\ntitle ASC:");

            foreach (var book in ol.livros)
            {
                Console.WriteLine("{0} {1} {2} {3}", book.Id.ToString(), book.Title, book.Author, book.Edition);
            }
            Console.WriteLine(ol.OrderBooksToVerbose());

            ol.OrderBooks("author ASC, title DESC");
            Console.WriteLine("\nauthor ASC, title DESC:");

            foreach (var book in ol.livros)
            {
                Console.WriteLine("{0} {1} {2} {3}", book.Id.ToString(), book.Title, book.Author, book.Edition);
            }
            Console.WriteLine(ol.OrderBooksToVerbose());

            ol.OrderBooks("edition DESC, author DESC, title ASC");
            Console.WriteLine("\nedition DESC, author DESC, title ASC:");

            foreach (var book in ol.livros)
            {
                Console.WriteLine("{0} {1} {2} {3}", book.Id.ToString(), book.Title, book.Author, book.Edition);
            }
            Console.WriteLine(ol.OrderBooksToVerbose());

            ol.livros = new List <Livro> {
            };
            ol.OrderBooks();
            Console.WriteLine("\nConjunto vazio:");

            foreach (var book in ol.livros)
            {
                Console.WriteLine("{0} {1} {2} {3}", book.Id.ToString(), book.Title, book.Author, book.Edition);
            }
            Console.WriteLine(ol.OrderBooksToVerbose());

            Console.WriteLine("\nAperte qualquer tecla para enviar conjunto nulo:");
            Console.ReadKey();

            // throw exception
            ol.livros = null;
            ol.OrderBooks("nulo");
        }