public CommandExample ParseExample(CommandFileReader reader, CommandsFile commandsFile, out int skip) { CommandExample result = new CommandExample(); string line = reader.NextLine(); if (Regex.IsMatch(line, RegexExample)) { string[] used = Regex.Match(line, @"\(" + CreateMulitpleRegex(RegexVariable) + @"\)").Value .Trim('(', ')').Split(',').Select(s => s.Trim()).ToArray(); if (used.Length > 0 && used[0] != string.Empty) { commandsFile.Add(result, used); } } while (!reader.IsDone) { line = reader.NextLine(); if (Regex.IsMatch(line, RegexExampleExplanation)) { string value = line.Substring(line.IndexOf(':') + 1).Trim(); result.AddExplanation(value); } else if (Regex.IsMatch(line, RegexExampleLine)) { string value = line.Substring(line.IndexOf(':') + 1).Trim(); result.AddLine(value); } else if (EndsBlock(line)) { break; } else { throw new Exception(); } } skip = reader.Position - reader.Start - 1; return(result); }
static void Main(string[] args) { Assert.AreEqual(args, null); #region Creational Patterns //Abstract Factory; AbstractFactoryExample.AbstractFactory(); #endregion //Adapter AdapterExample.Adapter(); #region beavioural Patterns // Visitor Visitor visitor = new Visitor(); visitor.Main(); //Decorator DecoratorExample.Decorator(); //Command CommandExample.Command(); //Observer ObserverExample.Observer(); #endregion //BusinessDelegate BusinessDelegateExample.BusinessDelegate(); //DataTransferObject DataTransferObjectExample transferObjectExample = new DataTransferObjectExample(); transferObjectExample.StartDemo(); //UnitOfWork UnitOfWorkExample.UnitOfWork(); }
public void Run_RunsExample() { var commandExample = new CommandExample( this.robotMock.Object, this.commandFactoryMock.Object, new CommandExecutionManager()); string outputString; using (var newOut = new StringWriter(CultureInfo.InvariantCulture)) { var previousOut = Console.Out; Console.SetOut(newOut); commandExample.Run(CancellationToken.None); Console.SetOut(previousOut); outputString = newOut.ToString(); } Assert.That(outputString, Does.StartWith("Running command example.")); this.commandMock.Verify(c => c.Execute(), Times.Exactly(6)); this.commandMock.Verify(c => c.Undo(), Times.Exactly(3)); }
public void Command() { CommandExample.Command(); }
internal void Add(CommandExample example, string[] parameters) { exampleParameters.Add(example, parameters); }