示例#1
0
 public void UpdateContent_ThrowsExceptionOnNullParameter()
 {
     Catalog catalog = new Catalog();
     catalog.UpdateContent(null, "new url");
 }
示例#2
0
        public void UpdateContent_Returns0OnNonExistingKeyEntry()
        {
            Catalog catalog = new Catalog();
            int updated = catalog.UpdateContent("non-existing", "another");

            Assert.AreEqual(0, updated);
        }
示例#3
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);
        }
示例#4
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);
        }
        public void DoubleUpdateAnEntry()
        {
            Catalog catalog = new Catalog();
            string[] entryParams = { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" };
            CatalogEntry entry = new CatalogEntry(Content.Book, entryParams);
            catalog.Add(entry);

            int updated = catalog.UpdateContent("http://www.introprogramming.info", "http://www.introprogramming.info/en/");
            Assert.AreEqual(1, updated);

            updated = catalog.UpdateContent("http://www.introprogramming.info", "http://www.introprogramming.info/en/");
            Assert.AreEqual(0, updated);
        }
        public void UpdateWithNoMatches()
        {
            Catalog catalog = new Catalog();
            string[] entryParams = { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" };
            CatalogEntry entry = new CatalogEntry(Content.Book, entryParams);
            catalog.Add(entry);
            AddSomeEntries(catalog, ref entryParams, ref entry);

            int updated = catalog.UpdateContent("http://www.lalala.info", "http://www.introprogramming.info/en/");
            Assert.AreEqual(0, updated);
        }