static void Main(string[] args) { CommandsManager.onMessage += Console.WriteLine; CommandsManager.onExceptionThrown += exception => Console.WriteLine(exception.Message); Configuration configuration = new Configuration(true, "Test", "CommandSystem-Unity"); manager = new CommandsManager(configuration); manager.LoadCommands(); Func <float, float, float> action = (a, b) => { if (a > b) { return(a); } else { return(b); } }; manager.Add(command = new FuncCommand <float, float, float>(action)); manager.Add(command = new FuncCommand <float[], float>(Max)); manager.Add(command = new FuncCommand <int[], float>(Max)); Console.WriteLine(manager.Execute("Max \"(int[])2 3\"")); }
public void Add_Test() { // Arrange Mock <IRemoteCommand> command = new Mock <IRemoteCommand>(); Guid[] ids = { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() }; command.Setup(c => c.Id).Returns(ids[0]); _commands.AddRange(new[] { command.Object }); _commandSettings.Setup(s => s.GetCommandIds(It.IsAny <Type>())).Returns(ids.Take(2).ToArray); Mock <IRemoteCommand> newCommand = new Mock <IRemoteCommand>(); newCommand.Setup(c => c.Id).Returns(ids[ids.Length - 1]); // Act _commandManager = new CommandsManager(_commands, _commandSettings.Object); _commandManager.Add(newCommand.Object); // Assert Assert.AreEqual(ids.Length, _commandManager.Count); }