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()); } }
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); }
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()); }
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); }
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()); }
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); }
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); }