Exemplo n.º 1
0
 public void AddTest()
 {
     var target = new Catalog();
     var content = new Content(ContentTypes.Book, "Intro C#; S.Nakov; 12763892; http://www.introprogramming.info".Split(';'));
     target.Add(content);
     Assert.AreEqual(1, target.Count);
 }
Exemplo n.º 2
0
        public void TestMethodAddSingleItem()
        {
            Catalog catalog = new Catalog();
            string[] parameters = new string[] { "Academy", "Telerik", "3", "http://telerikacademy.com/" };
            CatalogContent item = new CatalogContent(ContentTypes.Movie, parameters);
            catalog.Add(item);
            var result = catalog.GetTitlesList();

            Assert.AreEqual(result.Count(), 1);
        }
 public void ExecuteAddBookCommandTest()
 {
     var target = new CommandExecutor();
     var catalog = new Catalog();
     var command = new Command("Add book: Intro C#; S.Nakov; 12763892; http://www.introprogramming.info");
     var output = new StringBuilder();
     var expected = "Book added" + Environment.NewLine;
     target.ExecuteCommand(catalog, command, output);
     Assert.AreEqual(expected, output.ToString());
 }
 public void ExecuteAddApplicationCommandTest()
 {
     var target = new CommandExecutor();
     var catalog = new Catalog();
     var command = new Command("Add application: Firefox v.11.0; Mozilla; 16148072; http://www.mozilla.org");
     var output = new StringBuilder();
     var expected = "Application added" + Environment.NewLine;
     target.ExecuteCommand(catalog, command, output);
     Assert.AreEqual(expected, output.ToString());
 }
 public void ExecuteAddMovieCommandTest()
 {
     var target = new CommandExecutor();
     var catalog = new Catalog();
     var command = new Command("Add movie: The Secret; Drew Heriot, Sean Byrne & others (2006); 832763834; http://t.co/dNV4d");
     var output = new StringBuilder();
     var expected = "Movie added" + Environment.NewLine;
     target.ExecuteCommand(catalog, command, output);
     Assert.AreEqual(expected, output.ToString());
 }
Exemplo n.º 6
0
        public void TestConstructor()
        {
            Catalog catalog = new Catalog();
            string[] parameters = new string[4];
            parameters[0] = null;
            parameters[1] = null;
            parameters[2] = "3";
            parameters[3] = null;

            CatalogContent catalogContent = new CatalogContent(ContentTypes.Application, parameters);
        }
Exemplo n.º 7
0
        public void TestMethodAddMultipleItems2()
        {
            Catalog catalog = new Catalog();
            string[] parameters1 = new string[] { "Academy", "Telerik", "3", "http://telerikacademy.com/" };

            CatalogContent item1 = new CatalogContent(ContentTypes.Movie, parameters1);
            catalog.Add(item1);
            catalog.Add(item1);

            var result = catalog.GetTitlesList().KeyValuePairs;

            Assert.AreEqual(result.Count, 2);
        }
Exemplo n.º 8
0
        public static void Main()
        {
            StringBuilder output = new StringBuilder();
            Catalog catalog = new Catalog();
            ICommandExecutor ce = new CommandExecutor();

            foreach (ICommand command in Utilities.ListOfCommands())
            {
                ce.ExecuteCommand(catalog, command, output);
            }

            Console.Write(output);
        }
Exemplo n.º 9
0
 public void TestMethodAddSingleItem()
 {
     var catalog = new Catalog();
     string[] item = {
                        "Intro C#", 
                        "S.Nakov", 
                        "12763892", 
                        "http://www.introprogramming.info"
                        };
     var book = new ContentItem(ContentItemType.Book, item);
     catalog.Add(book);
     Assert.AreEqual(catalog.Count(), 1);
 }
Exemplo n.º 10
0
        public static void Main()
        {
            var output = new StringBuilder();
            var cat = new Catalog();
            var commandExecutor = new CommandExecutor();

            foreach (var item in Parse())
            {
                commandExecutor.ExecuteCommand(cat, item, output);
            }

            Console.Write(output);
        }
        public static void Main()
        {
            StringBuilder output = new StringBuilder(); 
            Catalog catalog = new Catalog();
            ICommandExecutor catalogExecutor = new CommandExecutor();

            var commands = ReadInputCommands();
            foreach (ICommand cmd in commands)
            {
                catalogExecutor.ExecuteCommand(catalog, cmd, output);
            }

            Console.Write(output);
        }
Exemplo n.º 12
0
        public static void StartInteraction()
        {
            StringBuilder output = new StringBuilder();
            Catalog catalog = new Catalog();
            ICommandExecutor command = new CommandExecutor();
            IList<ICommand> commandForExecution = ReadCommands();

            foreach (ICommand item in commandForExecution)
            {
                command.ExecuteCommand(catalog, item, output);
            }

            Console.Write(output);
        }
Exemplo n.º 13
0
        public static void Main()
        {
            var output = new StringBuilder();
            var catalog = new Catalog();
            ICommandExecutor c = new CommandExecutor();

            var commands = ParseCommands();
            foreach (var command in commands)
            {
                c.ExecuteCommand(catalog, command, output);
            }

            Console.Write(output);
        }
        public void TestMethod_AddSingleItemAndCheckContent()
        {
            Catalog catalog = new Catalog();

            Content book = new Content(ContentType.Book,
                new string[] {"Intro C#", "S.Nakov", 
                    "12763892", "http://www.introprogramming.info"});

            catalog.Add(book);

            var result = catalog.GetListContent("Intro C#", 1);
            
            Assert.AreEqual(result.Count(), 1);
            Assert.AreSame(result.First(), book);
        }
Exemplo n.º 15
0
 public void TestMethodAddAndCheckContent()
 {
     var catalog = new Catalog();
     string[] book = {
                        "Intro C#", 
                        "S.Nakov", 
                        "12763892", 
                        "http://www.introprogramming.info"
                        };
     var item = new ContentItem(ContentItemType.Book, book);
     catalog.Add(item);
     var restult = catalog.GetListContent("Intro C#", 1);
     Assert.AreEqual(restult.Count(), 1);
     Assert.AreSame(restult.First(), item);
 }
Exemplo n.º 16
0
        public void TestMethodAddDuplicatedItemsWithSameValues()
        {
            var catalog = new Catalog();
            string[] book = {
                               "Intro C#", 
                               "S.Nakov", 
                               "12763892", 
                               "http://www.introprogramming.info"
                               };

            var item1 = new ContentItem(ContentItemType.Book, book);
            catalog.Add(item1);
            catalog.Add(item1);
            var restult = catalog.GetListContent("Intro C#", 5);
            Assert.AreEqual(restult.Count(), 2);

        }
Exemplo n.º 17
0
        public void TestMethodAddMultipleItems()
        {
            var catalog = new Catalog();
            var book = new ContentItem(ContentItemType.Book, new string[] {
                               "Intro C#","S.Nakov","12763892","http://www.introprogramming.info"});


            var movie = new ContentItem(ContentItemType.Movie, new string[] {
                               "The Secret","Sean Byrne & others (2006)","832763834","http://thesecret/movies/avi"});


            var song = new ContentItem(ContentItemType.Song, new string[] {
                               "The Secret Song","Sean Byrne & others (2006)","832763834","http://thesecret/songs/mp3"});

            catalog.Add(book);
            catalog.Add(movie);
            catalog.Add(song);
            Assert.AreEqual(catalog.Count(), 3);
        }
        public void TestMethod_AddDuplicatedItem()
        {
            Catalog catalog = new Catalog();

            Content book1 = new Content(ContentType.Book,
                new string[] {"Intro C#", "S.Nakov", 
                    "12763892", "http://www.introprogramming.info"});
            catalog.Add(book1);
            catalog.Add(book1);

            Content book2 = new Content(ContentType.Book,
                new string[] {"Intro C#", "S.Nakov", 
                    "12763892", "http://www.introprogramming.info"});

            
            catalog.Add(book2);

            Assert.AreEqual(3, catalog.Count);
        }
        public void TestMethod_AddMultipleItem()
        {
            Catalog catalog = new Catalog();

            Content book1 = new Content(ContentType.Book,
                new string[] {"Intro C#", "S.Nakov", 
                    "12763892", "http://www.introprogramming.info"});
            catalog.Add(book1);

            Content movie = new Content(ContentType.Book,
                new string[] {"Java Movie", "S.sssss", 
                    "12755892", "http://www.introprogramming.com"});

            catalog.Add(movie);

            Content song = new Content(ContentType.Book,
                new string[] {"Java song", "S.sssss", 
                    "12755892", "http://www.introprogramming.bg"});

            catalog.Add(song);

            Assert.AreEqual(3, catalog.Count);
        }
Exemplo n.º 20
0
        public static void Main()
        {
            StringBuilder output = new StringBuilder();
            Catalog catalog = new Catalog();
            ICommandExecutor command = new CommandExecutor();

            foreach (ICommand cmd in ParseCommand())
            {
                command.ExecuteCommand(catalog, cmd, output);
            }

            Console.Write(output);
        }
        public void TestMethod_Add10000Item()
        {
            Catalog catalog = new Catalog();

            for (int i = 0; i < 10000; i++)
            {
                Content book1 = new Content(ContentType.Book,
                new string[] {"Intro C#" + (i%5), "S.Nakov", 
                    "12763892", "http://www.introprogramming.info"});
                catalog.Add(book1);
            }

            Assert.AreEqual(10000, catalog.Count);
        }
Exemplo n.º 22
0
 public void ExecuteDefaultCommandTest()
 {
     var target = new CommandExecutor();
     var catalog = new Catalog();
     var command = new Command("Add car: Intro C#; S.Nakov; 12763892; http://www.introprogramming.info");
     var output = new StringBuilder();
     target.ExecuteCommand(catalog, command, output);
 }
Exemplo n.º 23
0
        public void TestMethodGetListContentCheckOrder()
        {
            var catalog = new Catalog();

            var book1 = new ContentItem(ContentItemType.Book, new string[] {
                               "Intro C#" ,"S.Nakov","12763892","http://www.introprogramming.info"});
            var book2 = new ContentItem(ContentItemType.Book, new string[] {
                               "Intro C#" ,"Author","12763892","http://www.introprogramming.info"});
            var book3 = new ContentItem(ContentItemType.Book, new string[] {
                               "Intro C#" ,"Xray","12763892","http://www.introprogramming.info"});
            var book4 = new ContentItem(ContentItemType.Book, new string[] {
                               "Intro C#" ,"Author","127623892","http://www.introprogramming.info"});

            catalog.Add(book1);
            catalog.Add(book2);
            catalog.Add(book3);
            catalog.Add(book4);

            var result = catalog.GetListContent("Intro C#", 10);
            Assert.AreEqual(result.Count(), 4);

            var expected = new string[] {"Book: Intro C#; Author; 127623892; http://www.introprogramming.info",
"Book: Intro C#; Author; 12763892; http://www.introprogramming.info",
"Book: Intro C#; S.Nakov; 12763892; http://www.introprogramming.info",
"Book: Intro C#; Xray; 12763892; http://www.introprogramming.info"};

            var actual = new string[]{
                result.First().ToString(),
                result.Skip(1).First().ToString(), 
                 result.Skip(2).First().ToString(), 
                result.Skip(3).First().ToString()
            };

            CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 24
0
        public void TestMethodGetListContentManyMatchingItemsGetFirstOnly()
        {
            var catalog = new Catalog();

            var book1 = new ContentItem(ContentItemType.Book, new string[] {
                               "Intro C#" ,"S.Nakov","12763892","http://www.introprogramming.info"});
            var book2 = new ContentItem(ContentItemType.Book, new string[] {
                               "Intro C++" ,"S.Nakov","12763892","http://www.introprogramming.info"});
            var book3 = new ContentItem(ContentItemType.Book, new string[] {
                               "Intro Java" ,"S.Nakov","12763892","http://www.introprogramming.info"});
            var book4 = new ContentItem(ContentItemType.Book, new string[] {
                               "Intro C#" ,"Author","127623892","http://www.introprogramming.info"});

            catalog.Add(book1);
            catalog.Add(book2);
            catalog.Add(book3);
            catalog.Add(book4);

            var result = catalog.GetListContent("Intro C#", 1);
            Assert.AreEqual(result.Count(), 1);
        }
Exemplo n.º 25
0
        public void ExecuteFindManyCommandTest()
        {
            var target = new CommandExecutor();
            var catalog = new Catalog();
            var output = new StringBuilder();
            var expected = new StringBuilder();

            var command = new Command("Add book: Intro C#; S.Nakov; 12763892; http://www.introprogramming.info");
            target.ExecuteCommand(catalog, command, output);
            expected.AppendLine("Book added");

            command = new Command("Add book: Intro C#; S.Nakovvvvvvv; 3453454535433224; http://www.introprogramming.bg");
            target.ExecuteCommand(catalog, command, output);
            expected.AppendLine("Book added");

            command = new Command("Add movie: Movie C#; Sssssssssssss.Nakov; 5435353333; http://www.introprogramming.info");
            target.ExecuteCommand(catalog, command, output);
            expected.AppendLine("Movie added");

            command = new Command("Find: Intro C#; 1");
            target.ExecuteCommand(catalog, command, output);
            expected.AppendLine("Book: Intro C#; S.Nakov; 12763892; http://www.introprogramming.info");

            Assert.AreEqual(expected.ToString(), output.ToString());
        }
Exemplo n.º 26
0
        public void TestMethodAdd50kItems()
        {
            var catalog = new Catalog();
            for (int i = 0; i < 10000; i++)
            {
                var book = new ContentItem(ContentItemType.Book, new string[] {
                               "Intro C#" + i,"S.Nakov","12763892","http://www.introprogramming.info"});
                catalog.Add(book);
            }

            Assert.AreEqual(catalog.Count(), 10000);
        }
Exemplo n.º 27
0
        public void ExecuteUpdateCommandTest()
        {
            var target = new CommandExecutor();
            var catalog = new Catalog();
            var output = new StringBuilder();
            var expected = new StringBuilder();

            var command = new Command("Add book: Intro C#; S.Nakov; 12763892; http://www.introprogramming.info");
            target.ExecuteCommand(catalog, command, output);
            expected.AppendLine("Book added");

            command = new Command("Add book: Intro C# 2; S.Nakov; 12763892; http://www.introprogramming.bg");
            target.ExecuteCommand(catalog, command, output);
            expected.AppendLine("Book added");

            command = new Command("Update: http://www.introprogramming.info; http://introprograming.info/en/");
            target.ExecuteCommand(catalog, command, output);
            expected.AppendLine("1 items updated");

            Assert.AreEqual(expected.ToString(), output.ToString());
        }
        public void TestMethod_GetListContentCheckOrder()
        {
            Catalog catalog = new Catalog();

            Content book = new Content(ContentType.Book,
                new string[] {"Intro movie", "S.fdr", 
                    "12763892", "http://www.introprogramming.bg"});

            catalog.Add(book);

            Content movie = new Content(ContentType.Movie,
                new string[] {"Intro movie", "S.fd", 
                    "12763892", "http://www.bg.info"});

            catalog.Add(movie);

            Content app = new Content(ContentType.Application,
                new string[] {"Intro movie", "Sfdv", 
                    "12763892", "http://www.bg.info"});

            catalog.Add(app);

            Content book1 = new Content(ContentType.Book,
                new string[] {"Intro movie", "dd", 
                    "12763892", "http://www.introprogramming.bg"});

            catalog.Add(book1);

            var result = catalog.GetListContent("Intro movie", 10);

            Assert.AreEqual(result.Count(), 4);

            string[] expected = 
            {
                "Application: Intro movie; Sfdv; 12763892; http://www.bg.info",
                "Book: Intro movie; dd; 12763892; http://www.introprogramming.bg",
                "Book: Intro movie; S.fdr; 12763892; http://www.introprogramming.bg",
                "Movie: Intro movie; S.fd; 12763892; http://www.bg.info"
            };
            string[] actual = new string[]
            {
                result.First().ToString(),
                result.Skip(1).First().ToString(),
                result.Skip(2).First().ToString(),
                result.Skip(3).First().ToString()
            };

            CollectionAssert.AreEqual(expected, actual);
        }
        public void TestMethod_GetListContentMissingItem()
        {
            Catalog catalog = new Catalog();

            Content book = new Content(ContentType.Book,
                new string[] {"Intro C#", "S.Nakov", 
                    "12763892", "http://www.introprogrammi ng.bg"});

            catalog.Add(book);

            Content movie = new Content(ContentType.Movie,
                new string[] {"Intro movie", "S.Nakov", 
                    "12763892", "http://www.bg.info"});

            catalog.Add(movie);

            Content app = new Content(ContentType.Application,
                new string[] {"Intro movie", "S.Nakov", 
                    "12763892", "http://www.bg.info"});

            catalog.Add(app);

            var result = catalog.GetListContent("Missing item", 10);

            Assert.AreEqual(result.Count(), 0);
        }
Exemplo n.º 30
0
 public void ExecuteAddSongCommandTest()
 {
     var target = new CommandExecutor();
     var catalog = new Catalog();
     var command = new Command("Add song: One; Metallica; 8771120; http://goo.gl/dIkth7gs");
     var output = new StringBuilder();
     var expected = "Song added" + Environment.NewLine;
     target.ExecuteCommand(catalog, command, output);
     Assert.AreEqual(expected, output.ToString());
 }