public void CommandTestText() { //Set up the model Model model = new Model(); //Set up the shape element Label label = new Label("Hello world"); //Set up the controller Controller controller = new Controller(model); //Set up the command, this stores any values of the shape in a momento TextCommand command = controller.CommandFactory.CreateTextCommand(); command.CommandText = "bold"; command.Labels.Add(label); //Execute the command command.Execute(); Assert.IsTrue(label.Bold, "Text command not executed correctly."); command.Undo(); Assert.IsTrue(!label.Bold, "Textcommand undo not executed correctly."); command.Redo(); Assert.IsTrue(label.Bold, "Text command redo not executed correctly."); }
/// <summary> /// Decide which command will be executed /// </summary> /// <param name="packet"></param> public static void Handler(string packet) { bool isValidPacket = Validator.ValidatePacket(packet); if (isValidPacket) { switch (packet[1]) { case 'T': TextCommand text = new TextCommand(); text.Execute(packet); break; case 'S': SoundCommand sound = new SoundCommand(); sound.Execute(packet); break; } } else { Console.WriteLine("\n" + Helper.badRequest + "\n"); } }