Esempio n. 1
0
        public void Add_ExecutesOKOnDuplicates()
        {
            Catalog catalog = new Catalog();

            string commandStr = "Add movie: One; James Wong (2001); 969763002; http://www.imdb.com/title/tt0267804/";
            ICommand command = new Command(commandStr);
            ICommandExecutor executor = new CommandExecutor();

            for (int i = 0; i < 3; i++)
            {
                executor.ExecuteCommand(catalog, command, new System.Text.StringBuilder());
            }
        }
Esempio n. 2
0
        public static void Main()
        {
            StringBuilder output = new StringBuilder();
            Catalog catalog = new Catalog();
            ICommandExecutor commandExecutor = new CommandExecutor();

            foreach (ICommand item in GetCommands())
            {
                commandExecutor.ExecuteCommand(catalog, item, output);
            }

            Console.Write(output);
        }
Esempio n. 3
0
        public void GetListContent_MatchedEqualToRequested()
        {
            Catalog catalog = new Catalog();

            string commandStr = "Add movie: One; James Wong (2001); 969763002; http://www.imdb.com/title/tt0267804/";
            ICommand command = new Command(commandStr);
            ICommandExecutor executor = new CommandExecutor();

            for (int i = 0; i < 3; i++)
            {
                executor.ExecuteCommand(catalog, command, new System.Text.StringBuilder());
            }

            IEnumerable<IContent> result = catalog.GetListContent("One", 3);
            Assert.AreEqual(3, result.Count());
        }
Esempio n. 4
0
        public static void Main()
        {
            StringBuilder output = new StringBuilder();
            Catalog catalog = new Catalog();
            ICommandExecutor executor = new CommandExecutor();

            List<ICommand> commandsForExecution = Parse();

            foreach (ICommand item in commandsForExecution)
            {
                executor.ExecuteCommand(catalog, item, output);
            }

            //Console.BackgroundColor = ConsoleColor.DarkGreen;
            Console.Write(output);
        }
Esempio n. 5
0
        public void GetListContent_MatchedLessThanTheRequested()
        {
            string[] commandStrings = { "Add movie: One; James Wong (2001); 969763002; http://www.imdb.com/title/tt0267804/",
                                       "Add song: One; Metallica (2000); 734837437; http://sample.net",
                                       "Add application: Google Chrome; Chrome; 374837837; http://google.com"};

            Catalog catalog = new Catalog();
            ICommandExecutor executor = new CommandExecutor();

            foreach (string commandString in commandStrings)
            {
                ICommand command = new Command(commandString);
                executor.ExecuteCommand(catalog, command, new System.Text.StringBuilder());
            }

            IEnumerable<IContent> result = catalog.GetListContent("One", 6);
            Assert.AreEqual(2, result.Count());
        }
Esempio n. 6
0
        public void UpdateContent_Returns0OnEqualUrlParams()
        {
            Catalog catalog = new Catalog();

            string commandStr = "Add movie: One; James Wong (2001); 969763002; http://www.imdb.com/title/tt0267804/";
            ICommand command = new Command(commandStr);

            ICommandExecutor executor = new CommandExecutor();
            executor.ExecuteCommand(catalog, command, new System.Text.StringBuilder());

            int updated = catalog.UpdateContent("http://www.imdb.com/title/tt0267804/", "http://www.imdb.com/title/tt0267804/");
            Assert.AreEqual(0, updated);
        }
Esempio n. 7
0
        public void UpdateContent_OnSingleMatchingElement()
        {
            string[] commandStrings = { "Add movie: One; James Wong (2001); 969763002; http://www.imdb.com/title/tt0267804/",
                                       "Add song: One; Metallica (2000); 734837437; http://sample.net",
                                       "Add application: Google Chrome; Chrome; 374837837; http://google.com"};

            Catalog catalog = new Catalog();
            ICommandExecutor executor = new CommandExecutor();

            foreach (string commandString in commandStrings)
            {
                ICommand command = new Command(commandString);
                executor.ExecuteCommand(catalog, command, new System.Text.StringBuilder());
            }

            int updated = catalog.UpdateContent("http://google.com", "http://google.bg");
            Assert.AreEqual(1, updated);
        }