Exemplo 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());
            }
        }
Exemplo n.º 2
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());
        }
Exemplo n.º 3
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());
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        private void Parse()
        {
            this.commandNameEndIndex = this.GetCommandNameEndIndex();

            this.Name = this.ParseName();
            this.Parameters = this.ParseParameters();
            this.TrimParams();

            this.Type = this.ParseCommandType(this.Name);
        }