public void Test_AddTheatre_ShouldAddTheTheatre() { string theatreName = "Theatre Sofia"; theatreDatabase.AddTheatre(theatreName); string[] expectedOutput = new[] { "Theatre Sofia" }; var actualOutput = theatreDatabase.ListTheatres().ToList(); CollectionAssert.AreEqual(expectedOutput, actualOutput); }
private static string ExecutePrintAllTheatresCommand() { var theatresCount = PerformanceDatabase.ListTheatres().Count(); if (theatresCount > 0) { var resultTheatres = PerformanceDatabase.ListTheatres().ToList(); return(string.Join(", ", resultTheatres)); } return("No theatres"); }
private static string ExecutePrintAllTheatresCommand() { var theatresCount = performanceDatabase.ListTheatres().Count(); if (theatresCount > 0) { var resultTheatres = new LinkedList <string>(); performanceDatabase.ListTheatres().ToList().ForEach(t => resultTheatres.AddLast(t)); return(String.Join(", ", resultTheatres)); } return(Constants.NoTheatresMsg); }
public static string ExecutePrintAllTheatresCommand() { var theatresCount = PerformanceDatabase.ListTheatres().Count(); if (theatresCount > 0) { var resultTheatres = new List <string>(); foreach (var theatre in PerformanceDatabase.ListTheatres()) { resultTheatres.Add(theatre); } return(String.Join(", ", resultTheatres)); } return(Constants.NoTheatresMessage); }
public void Test_AddTheatre_ShouldAddTheatreCorrectly() { performanceDb.AddTheatre("Ivan Vazov National Theatre"); var expextedTheatres = new[] { "Ivan Vazov National Theatre" }; var actualTheatres = performanceDb.ListTheatres().ToList(); CollectionAssert.AreEqual(expextedTheatres, actualTheatres); }
public static string ExecutePrintAllTheatresCommand(IPerformanceDatabase database) { var theatresCount = database.ListTheatres().Count(); if (theatresCount == 0) { return "No theatres"; } var resultTheatres = new LinkedList<string>(); database.ListTheatres() .ToList() .ForEach(t => resultTheatres.AddLast(t)); // PERFORMANCE: Useless iteration with foreach loop, which removes elements from Linkedlist // a slow operation return string.Join(", ", resultTheatres); }
public static string ExecutePrintAllTheatresCommand(IPerformanceDatabase database) { var theatresCount = database.ListTheatres().Count(); if (theatresCount > 0) { //var resultTheatres = new LinkedList<string>(); //for (int i = 0; i < theatresCount; i++) //{ // database.ListTheatres().Skip(i).ToList().ForEach(t => resultTheatres.AddLast(t)); // foreach (var t in database.ListTheatres().Skip(i + 1)) // { // resultTheatres.Remove(t); // } //} return String.Join(", ", database.ListTheatres()); } return "No theatres"; }
private static string ExecutePrintAllTheatresCommand() { var theatres = performanceDb.ListTheatres().ToList(); if (theatres.Any()) { return(string.Join(", ", theatres)); } return(Constants.NoTheatresMsg); }
private static string ExecutePrintAllTheatresCommand() { var theatres = performanceDB.ListTheatres().ToList(); if (theatres.Any()) { return(string.Join(", ", theatres)); } return("No theatres"); }
public static string ExecutePrintAllTheatresCommand(IPerformanceDatabase database) { var theatresCount = database.ListTheatres().Count(); if (theatresCount > 0) { //var resultTheatres = new LinkedList<string>(); //for (int i = 0; i < theatresCount; i++) //{ // database.ListTheatres().Skip(i).ToList().ForEach(t => resultTheatres.AddLast(t)); // foreach (var t in database.ListTheatres().Skip(i + 1)) // { // resultTheatres.Remove(t); // } //} return(String.Join(", ", database.ListTheatres())); } return("No theatres"); }
public static void ExecutePrintAllTheatresCommand() { var theatresNames = theatresDatabase.ListTheatres(); if (theatresNames.Any()) { string theatreResult = FormatTheatresForPrinting(theatresNames); PrintOutput(theatreResult); } else { Console.WriteLine(Constants.NoTheatresMessage); } }
private string ExecutePrintAllTheatresCommand() { string result = String.Empty; var theatresCount = database.ListTheatres().Count(); var theatres = this.database.ListTheatres(); if (theatresCount > 0) { result = String.Join(", ", theatres); } else { result = "No theatres"; } return(result); }
private static string ExecutePrintAllTheatresCommand() { var theatresCount = Universal.ListTheatres().Count(); return(theatresCount <= 0 ? "No theatres" : string.Join(", ", Universal.ListTheatres())); }
protected static void Main() { while (true) { var input = Console.ReadLine(); if (input == null) { return; } if (input != string.Empty) { var tokens = input.Split(new[] { '(', ',', ')' }, StringSplitOptions.RemoveEmptyEntries); var command = tokens[0]; var parameters = tokens.Skip(1).Select(p => p.Trim()).ToArray(); string message; try { switch (command) { case "AddTheatre": var theatreName = parameters[0]; Database.AddTheatre(theatreName); message = "Theatre added"; break; case "PrintAllTheatres": var theatres = Database.ListTheatres().ToList(); message = string.Join(", ", theatres); break; case "AddPerformance": theatreName = parameters[0]; var performanceTitle = parameters[1]; var startDateTime = DateTime.ParseExact( parameters[2], "dd.MM.yyyy HH:mm", CultureInfo.InvariantCulture); var duration = TimeSpan.Parse(parameters[3]); var price = decimal.Parse(parameters[4], NumberStyles.Float); Database.AddPerformance(theatreName, performanceTitle, startDateTime, duration, price); message = "Performance added"; break; case "PrintAllPerformances": var performances = Database.ListAllPerformances().ToList(); message = string.Join(", ", performances); break; case "PrintPerformances": theatreName = parameters[0]; var performancesPerTheatre = Database.ListPerformances(theatreName).ToList(); message = string.Join(", ", performancesPerTheatre); break; default: message = "Invalid command!"; break; } } catch (Exception ex) { message = "Error: " + ex.Message; } Console.WriteLine(message); } } }