Ejemplo n.º 1
0
        public void WhenExecuteCommandWithoutText_CommandManager_ShouldThrowException()
        {
            var storedDataService = new StoredDataServiceMock();
            var commandDefinition = new EchoCommand();

            var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock);

            instance.RegisterCommand(commandDefinition);

            var inputRequest = new InputRequest(
                commandDefinition.GetInvocationCommandName());

            Assert.Throws <InvalidParamsException>(() =>
            {
                instance.ExecuteInputRequest(inputRequest);
            });
        }
Ejemplo n.º 2
0
        public void WhenExecuteCommandText_CommandManager_ShouldLogText()
        {
            var cmd = "hellomoto";
            var storedDataService = new StoredDataServiceMock();
            var commandDefinition = new EchoCommand();

            var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock);

            instance.RegisterCommand(commandDefinition);
            instance.OnLog += Instance_OnLog;
            var inputRequest = new InputRequest(
                commandDefinition.GetInvocationCommandName(),
                commandDefinition.CommandTextParameter.GetInvokeName(),
                cmd);

            instance.ExecuteInputRequest(inputRequest);

            var expected = cmd;
            var actual   = _loggerServiceMock.Logs.First();

            Assert.Equal(expected, actual);
        }