Esempio n. 1
0
        public CommandInterpreterTests(ITestOutputHelper output)
        {
            _output = output;
            //Set URL of the WS

            _settings = new Settings()
            {
                QueueUrl = "localhost", StockWebServiceUrl = "https://stooq.com/q/l/?s={stock_code}&f=sd2t2ohlcv&h&e=csv"
            };
            _options            = Options.Create(_settings);
            _commandInterpreter = new CommandInterpreterService(_options);
        }
Esempio n. 2
0
        public QueueConsumerService(IOptions <Settings> settings)
        {
            _settings = settings.Value;
            var factory = new ConnectionFactory()
            {
                HostName = _settings.QueueUrl
            };
            var connection = factory.CreateConnection();

            _channel = connection.CreateModel();
            _command = new CommandInterpreterService(settings);
        }
Esempio n. 3
0
        public async Task ShouldSucceedValidCommandsAsync(string commandStr, Command command)
        {
            Mock <ICommandService> mock = new Mock <ICommandService>();

            mock.Setup(x => x.Left()).Returns(Task.FromResult(true));
            mock.Setup(x => x.Right()).Returns(Task.FromResult(true));
            mock.Setup(x => x.Move()).Returns(Task.FromResult(true));

            Mock <ICommandInterpreter> commandInterpreterMock = new Mock <ICommandInterpreter>();
            Tuple <Command, IPosition> interpreterResult      = new Tuple <Command, IPosition>(command, null);

            commandInterpreterMock.Setup(x => x.Interpret(commandStr)).Returns(interpreterResult);

            var service = new CommandInterpreterService(commandInterpreterMock.Object, mock.Object);

            var result = await service.Execute(commandStr);

            result.Succeeded.ShouldBe(true);
            result.HasPoistionOutput.ShouldBe(false);
        }