public void TestProcessDeleteExistingEvents()
        {
            CommandExecutor cmdExecutor = new CommandExecutor(new EventsManagerFast());
            Command addCommand = new Command
            {
                CommandName = "AddEvent",
                Parameters = new string[]
                {
                    "2001-01-01T10:30:03",
                    "party Lora"
                }
            };
            cmdExecutor.ProcessCommand(addCommand);

            Command deleteCommand = new Command
            {
                CommandName = "DeleteEvents",
                Parameters = new string[]
                {
                    "party Lora",
                }
            };
            string result = cmdExecutor.ProcessCommand(deleteCommand);
            Assert.AreEqual("1 events deleted", result);
        }
        internal static void Main()
        {
            var           eventsManager   = new EventsManagerFast();
            var           commandExecutor = new CommandExecutor(eventsManager);
            StringBuilder resultOutput    = new StringBuilder();

            while (true)
            {
                string inputLine = Console.ReadLine();
                if (inputLine == "End" || inputLine == null)
                {
                    break;
                }

                try
                {
                    Command parsedCommand       = Command.Parse(inputLine);
                    string  outputCommandResult = commandExecutor.ProcessCommand(parsedCommand);
                    resultOutput.AppendLine(outputCommandResult);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            Console.WriteLine(resultOutput);
        }
        internal static void Main()
        {
            var eventsManager = new EventsManagerFast();
            var commandExecutor = new CommandExecutor(eventsManager);
            StringBuilder resultOutput = new StringBuilder();

            while (true)
            {
                string inputLine = Console.ReadLine();
                if (inputLine == "End" || inputLine == null)
                {
                    break;
                }

                try
                {
                    Command parsedCommand = Command.Parse(inputLine);
                    string outputCommandResult = commandExecutor.ProcessCommand(parsedCommand);
                    resultOutput.AppendLine(outputCommandResult);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            Console.WriteLine(resultOutput);
        }
Пример #4
0
        public static void Main()
        {
            var eventManager = new EventManager();

            CommandExecutor cmdExecutor = new CommandExecutor(eventManager);

            var commands = ReadUserInput();
            foreach (var command in commands)
            {

                Console.WriteLine(cmdExecutor.ProcessCommand(command));
            }
        }
 public void TestProcessDeleteEventsCommandWithTwoParameters()
 {
     CommandExecutor cmdExecutor = new CommandExecutor(new EventsManagerFast());
     Command cmd = new Command
     {
         CommandName = "DeleteEvents",
         Parameters = new string[]
         {
             "Rock party",
         }
     };
     string result = cmdExecutor.ProcessCommand(cmd);
     Assert.AreEqual("No events found", result);
 }
 public void TestProcessAddEventCommandWithTwoParameters()
 {
     CommandExecutor cmdExecutor = new CommandExecutor(new EventsManagerFast());
     Command cmd = new Command
     {
         CommandName = "AddEvent",
         Parameters = new string[]
         {
             "2001-01-01T10:30:03",
             "party Lora"
         }
     };
     string result = cmdExecutor.ProcessCommand(cmd);
     Assert.AreEqual("Event added", result);
 }
 public void TestProcessAddEventCommandWithThreeParameters()
 {
     CommandExecutor cmdExecutor = new CommandExecutor(new EventsManagerFast());
     Command cmd = new Command
     {
         CommandName = "AddEvent",
         Parameters = new string[]
         {
             "2001-01-01T12:00:00",
             "Chalga party - 406733",
             "telerik academy"
         }
     };
     string result = cmdExecutor.ProcessCommand(cmd);
     Assert.AreEqual("Event added", result);
 }
Пример #8
0
        public static void Main()
        {
            // Console.SetIn(new StreamReader("../../../CalendarSystem.Tests/Tests/test.010.in.txt"));
            // Console.SetIn(new StreamReader("../../input.txt"));

            // IEventsManager eventsManager = new EventsManager();
            IEventsManager eventsManager = new EventsManagerFast();

            CommandExecutor commandExecutor = new CommandExecutor(eventsManager);
            StringBuilder output = new StringBuilder();

            for (string line = null; (line = ReadCommand()) != "End"; )
            {
                Command command = Command.Parse(line);
                string result = commandExecutor.ProcessCommand(command);
                output.AppendLine(result);
                // Console.WriteLine(result);
            }

            Console.Write(output);
        }
Пример #9
0
        public static void Main()
        {
            // Console.SetIn(new StreamReader("../../../CalendarSystem.Tests/Tests/test.010.in.txt"));
            // Console.SetIn(new StreamReader("../../input.txt"));

            // IEventsManager eventsManager = new EventsManager();
            IEventsManager eventsManager = new EventsManagerFast();

            CommandExecutor commandExecutor = new CommandExecutor(eventsManager);
            StringBuilder   output          = new StringBuilder();

            for (string line = null; (line = ReadCommand()) != "End";)
            {
                Command command = Command.Parse(line);
                string  result  = commandExecutor.ProcessCommand(command);
                output.AppendLine(result);
                // Console.WriteLine(result);
            }

            Console.Write(output);
        }
Пример #10
0
        internal static void Main()
        {
            var eventsManager = new EventsManagerFast();
            var commandExecutor = new CommandExecutor(eventsManager);

            bool shouldReadCommands = true;

            while (shouldReadCommands)
            {
                string command = Console.ReadLine();
                if (command == "End" || string.IsNullOrEmpty(command))
                {
                    shouldReadCommands = false;
                }
                else
                {
                    Command parsedCommand = Command.Parse(command);
                    string commandResult = commandExecutor.ProcessCommand(parsedCommand);
                    Console.WriteLine(commandResult);
                }
            }
        }
Пример #11
0
        internal static void Main()
        {
            var eventsManager   = new EventsManagerFast();
            var commandExecutor = new CommandExecutor(eventsManager);

            bool shouldReadCommands = true;

            while (shouldReadCommands)
            {
                string command = Console.ReadLine();
                if (command == "End" || string.IsNullOrEmpty(command))
                {
                    shouldReadCommands = false;
                }
                else
                {
                    Command parsedCommand = Command.Parse(command);
                    string  commandResult = commandExecutor.ProcessCommand(parsedCommand);
                    Console.WriteLine(commandResult);
                }
            }
        }
Пример #12
0
        public static void Main()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();
            CommandExecutor commandExecutor = new CommandExecutor(eventsManager);
            StringBuilder outputResult = new StringBuilder();

            while (true)
            {
                string commandType = Console.ReadLine();
                if (commandType == "End" || commandType == null)
                {
                    break;
                }

                // using StringBuilder and one Console.WriteLine instead of Console.WriteLine every time
                // because print on console is very slow operation
                Command currentCommand = Command.Parse(commandType);
                outputResult.AppendLine(commandExecutor.ProcessCommand(currentCommand));
            }

            Console.WriteLine(outputResult.ToString().Trim());
        }
Пример #13
0
        public static void Main()
        {
            EventsManagerFast eventsManager   = new EventsManagerFast();
            CommandExecutor   commandExecutor = new CommandExecutor(eventsManager);
            StringBuilder     outputResult    = new StringBuilder();

            while (true)
            {
                string commandType = Console.ReadLine();
                if (commandType == "End" || commandType == null)
                {
                    break;
                }

                // using StringBuilder and one Console.WriteLine instead of Console.WriteLine every time
                // because print on console is very slow operation
                Command currentCommand = Command.Parse(commandType);
                outputResult.AppendLine(commandExecutor.ProcessCommand(currentCommand));
            }

            Console.WriteLine(outputResult.ToString().Trim());
        }
Пример #14
0
        public static void StartIteraction()
        {
            var eventManager = new EventsManager();
            var commandExecutor = new CommandExecutor(eventManager);

            while (true)
            {
                string currentLineCommand = Console.ReadLine();
                if (currentLineCommand == "End" || currentLineCommand == null)
                {
                    break;
                }

                try
                {
                    Console.WriteLine(commandExecutor.ProcessCommand(Command.Parse(currentLineCommand)));
                }
                catch (ArgumentException ex)
                {
                    throw new ArgumentException("Command cannot be executed.\n{0}", ex);
                }
            }
        }
        public static void Main()
        {
            var eventManager = new EventsManagerFast();
            var cmdExecutor = new CommandExecutor(eventManager);

            while (true)
            {
                string inputLine = Console.ReadLine();
                if (inputLine == "End" || inputLine == null)
                {
                    break;
                }

                try
                {
                    Console.WriteLine(cmdExecutor.ProcessCommand(Command.Parse(inputLine)));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
 public void TestProcesListEventsCommandWithoutEvents()
 {
     CommandExecutor cmdExecutor = new CommandExecutor(new EventsManagerFast());
     Command listCmd = new Command
     {
         CommandName = "ListEvents",
         Parameters = new string[]
         {
             "2012-03-31T23:59:57",
             "5"
         }
     };
     string result = cmdExecutor.ProcessCommand(listCmd);
     Assert.AreEqual("No events found", result);
 }