Esempio n. 1
0
 public InterGalacticCalculator(string calculatorInput, IInterGalacticMapper interGalacticMapper, IInputRetriever documentRetreiver, IInputParser documentParser)
 {
     _calculatorInput     = calculatorInput;
     _interGalacticMapper = interGalacticMapper;
     _documentRetreiver   = documentRetreiver;
     _documentParser      = documentParser;
 }
 public RoverBusinessLogic(IInputParser inputParser)
 {
     this.m_inputParser = inputParser;
     this.m_Rover = inputParser.Rover;
     this.m_nasaPlatue = inputParser.Platue;
     this.m_instructionList = inputParser.MovementInstructions;
 }
 public void Setup()
 {
     _inputParser = new InputParser();
     _mockGenerateAssetUseCase = new Mock <IGenerateAssetsUseCase>();
     _mockLogger     = new Mock <ILogger <ConsoleAssetGenerator> >();
     _classUnderTest = new ConsoleAssetGenerator(_inputParser, _mockGenerateAssetUseCase.Object, _mockLogger.Object);
 }
Esempio n. 4
0
 public Player(IPlayerInteractionService interactionService, IInputParser inputParser, ILogger logger)
 {
     _interactionService = interactionService;
     _inputParser        = inputParser;
     _logger             = logger;
     MoveCount           = 0;
 }
Esempio n. 5
0
        public Runmode(ILoggerFactory loggerFactory, BaseConfig baseConfig, Func <RunmodeConfig> configLoader)
        {
            RunmodeConfig runmodeConfig = configLoader();

            _logger    = loggerFactory.CreateLogger <Runmode>();
            _stopToken = new StopToken();
            Setups.Databases repos = Setups.SetUpRepositories(_logger, baseConfig);
            (_broadcastServer, _overlayConnection) = Setups.SetUpOverlayServer(loggerFactory);
            _modeBase = new ModeBase(loggerFactory, repos, baseConfig, _stopToken, _overlayConnection, ProcessMessage);
            _modeBase.InstallAdditionalCommand(new Command("reloadinputconfig", _ =>
            {
                ReloadConfig(configLoader().InputConfig);
                return(Task.FromResult(new CommandResult {
                    Response = "input config reloaded"
                }));
            }));

            // TODO felk: this feels a bit messy the way it is done right now,
            //            but I am unsure yet how I'd integrate the individual parts in a cleaner way.
            InputConfig inputConfig = runmodeConfig.InputConfig;

            _inputParser      = inputConfig.ButtonsProfile.ToInputParser();
            _inputBufferQueue = new InputBufferQueue <QueuedInput>(CreateBufferConfig(inputConfig));
            _anarchyInputFeed = CreateInputFeedFromConfig(inputConfig);
            _inputServer      = new InputServer(loggerFactory.CreateLogger <InputServer>(),
                                                runmodeConfig.InputServerHost, runmodeConfig.InputServerPort,
                                                _anarchyInputFeed);
        }
Esempio n. 6
0
        /// <inheritdoc />
        public IDictionary <int, double> DoCalculate(IList <BetDataStruct> betsList, double commissionPercent)
        {
            double totalBetPool = 0;
            double firstWinPool = 0;
            IDictionary <int, double> dividendsCollection = new Dictionary <int, double>();
            IInputParser result = (IInputParser)ProductData.BettingResult;

            if (result == null)
            {
                return(dividendsCollection);
            }

            foreach (var bet in betsList)
            {
                totalBetPool = totalBetPool + bet.BetAmount;
                if (bet.Runners[0] == result.RunnersList[0] &&
                    bet.Runners[1] == result.RunnersList[1])
                {
                    firstWinPool = firstWinPool + bet.BetAmount;
                    continue;
                }
            }

            CommissionAmount = totalBetPool * commissionPercent / 100.0;
            totalBetPool     = totalBetPool - CommissionAmount;
            double dividend = Math.Round(totalBetPool / firstWinPool, 2);

            dividendsCollection.Add(result.RunnersList[0], dividend);
            dividendsCollection.Add(result.RunnersList[1], dividend);
            return(dividendsCollection);
        }
Esempio n. 7
0
        public void TestRetainCase()
        {
            _inputParser = InputParserBuilder.FromBare()
                           .Buttons("A")
                           .AliasedButtons(("B", "X"))
                           .RemappedButtons(("C", "Y"))
                           .AnalogInputs("UP")
                           .AliasedTouchscreenInput("MOVE1", 10, 20)
                           .LengthRestrictions(maxSetLength: 2, maxSequenceLength: 4)
                           .Build();

            Assert.AreEqual(
                Seq(new InputSet(new[] { new Input("A", "A", "a") })),
                _inputParser.Parse("a"));
            Assert.AreEqual(
                Seq(new InputSet(new[] { new Input("B", "X", "b") })),
                _inputParser.Parse("b"));
            Assert.AreEqual(
                Seq(new InputSet(new[] { new Input("Y", "Y", "c") })),
                _inputParser.Parse("c"));
            Assert.AreEqual(
                Seq(new InputSet(new[] { new AnalogInput("UP", "UP", "up.2", 0.2f) })),
                _inputParser.Parse("up.2"));
            Assert.AreEqual(
                Seq(new InputSet(new[] { new TouchscreenInput("MOVE1", "touchscreen", "move1", 10, 20) })),
                _inputParser.Parse("move1"));
        }
Esempio n. 8
0
        public void TestMultitouch()
        {
            // multitouch enabled
            _inputParser = InputParserBuilder.FromBare()
                           .LengthRestrictions(maxSetLength: 2, maxSequenceLength: 4)
                           .Touchscreen(width: 240, height: 160, multitouch: true, allowDrag: true)
                           .Build();

            Assert.AreEqual(Seq(new InputSet(new List <Input>
            {
                new TouchscreenInput("234,123", "touchscreen", "234,123", 234, 123),
                new TouchscreenInput("11,22", "touchscreen", "11,22", 11, 22),
            })
                                ), _inputParser.Parse("234,123+11,22"));
            Assert.AreEqual(Seq(new InputSet(new List <Input>
            {
                new TouchscreenInput("234,123", "touchscreen", "234,123", 234, 123),
                new TouchscreenDragInput("11,22>33,44", "touchscreen", "11,22>33,44", 11, 22, 33, 44),
            })
                                ), _inputParser.Parse("234,123+11,22>33,44"));

            // multitouch disabled
            _inputParser = InputParserBuilder.FromBare()
                           .LengthRestrictions(maxSetLength: 2, maxSequenceLength: 4)
                           .Touchscreen(width: 240, height: 160, multitouch: false, allowDrag: true)
                           .Build();

            Assert.IsNull(_inputParser.Parse("234,123+11,22"));
            Assert.IsNull(_inputParser.Parse("234,123+11,22>33,44"));
            Assert.IsNull(_inputParser.Parse("234,123>0,0+11,22>33,44"));
        }
Esempio n. 9
0
        public void Init()
        {
            var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            _inputFilename = dir + "\\SampleInput.txt";
            _inputParser   = new InputParser();
        }
Esempio n. 10
0
        public void TestTouchscreenAlias()
        {
            _inputParser = InputParserBuilder.FromBare()
                           .Buttons("a")
                           .Touchscreen(width: 240, height: 160, multitouch: false, allowDrag: false)
                           .AliasedTouchscreenInput("move1", x: 42, y: 69)
                           .LengthRestrictions(maxSetLength: 2, maxSequenceLength: 4)
                           .Build();

            Assert.AreEqual(Seq(
                                new InputSet(new List <Input> {
                new Input("a", "a", "a")
            }),
                                new InputSet(new List <Input> {
                new TouchscreenInput("move1", "touchscreen", "move1", 42, 69)
            }),
                                new InputSet(new List <Input> {
                new TouchscreenInput("move1", "touchscreen", "move1", 42, 69)
            }),
                                new InputSet(new List <Input> {
                new Input("a", "a", "a")
            })
                                ), _inputParser.Parse("amove12a"));
            Assert.AreEqual(Seq(
                                new InputSet(new List <Input> {
                new TouchscreenInput("234,123", "touchscreen", "234,123", 234, 123)
            }),
                                new InputSet(new List <Input> {
                new TouchscreenInput("move1", "touchscreen", "move1", 42, 69)
            })
                                ), _inputParser.Parse("234,123move1"));
            Assert.IsNull(_inputParser.Parse("234,123+move1"));
        }
Esempio n. 11
0
 public SortQueryProcessor(
     IInputParser inputParser,
     LambdaExpressionFactory expressionFactory)
 {
     _inputParser       = inputParser;
     _expressionFactory = expressionFactory;
 }
 public InputHandler(ICommandParser commandParser_, IInputParser inputParser_, ICommandExecuter[] commandExecuters_, ILogger logger_)
 {
     commandParser    = commandParser_;
     inputParser      = inputParser_;
     commandExecuters = commandExecuters_;
     logger           = logger_;
 }
Esempio n. 13
0
        public void TestPerformance()
        {
            _inputParser = InputParserBuilder.FromBare()
                           .Buttons("a", "b", "start", "select", "wait")
                           .DPad()
                           .RemappedDPad(up: "n", down: "s", left: "w", right: "e", mapsToPrefix: "")
                           .AnalogStick(prefix: "c", allowSpin: true)
                           .RemappedButtons(("p", "wait"), ("xp", "wait"), ("exp", "wait"))
                           .AliasedButtons(("honk", "y"))
                           .Touchscreen(width: 240, height: 160, multitouch: true, allowDrag: true)
                           .LengthRestrictions(maxSetLength: 2, maxSequenceLength: 4)
                           .HoldEnabled(true)
                           .Build();

            var stopwatch = Stopwatch.StartNew();

            for (int i = 0; i < 100; i++)
            {
                _inputParser.Parse("a");
                _inputParser.Parse("A");
                _inputParser.Parse("aa");
                _inputParser.Parse("123,234");
                _inputParser.Parse("11,22>33,44");
                _inputParser.Parse("a+b2startSelect");
                _inputParser.Parse("cupupcup.2up");
                _inputParser.Parse("p");
                _inputParser.Parse("phonk+left-");
                _inputParser.Parse("start9");
            }
            stopwatch.Stop();
            // check for 1k inputs per second. I get around 30k inputs per second on an i5-7600k @ 3.80GHz,
            // but this test should only fail if something got horribly slow.
            Assert.Less(stopwatch.Elapsed, TimeSpan.FromSeconds(1));
        }
 public ConsoleImporter(IImportAssetsUseCase importAssetsUseCase, IInputParser <ImportAssetConsoleInput> inputParser, IFileReader <string> fileReader, ITextSplitter textSplitter, ILogger <IConsoleImporter> logger)
 {
     _importAssetsUseCase = importAssetsUseCase;
     _inputParser         = inputParser;
     _fileReader          = fileReader;
     _textSplitter        = textSplitter;
     _logger = logger;
 }
Esempio n. 15
0
 public CalculatorClient(ICalculator calculator, IInputParser parser,
                         IInputValidator validator, IOperatorProvider operatorProvider)
 {
     _calculator       = calculator ?? throw new System.ArgumentNullException(nameof(calculator));
     _parser           = parser ?? throw new System.ArgumentNullException(nameof(parser));
     _validator        = validator ?? throw new System.ArgumentNullException(nameof(validator));
     _operatorProvider = operatorProvider ?? throw new System.ArgumentNullException(nameof(operatorProvider));
 }
 /// <summary>
 /// Method to initialize the private variables.
 /// </summary>
 /// <param name="filePath">Source File Path.</param>
 private static void GeneratePreRecs(string filePath)
 {
     _fileReader             = new FileReader(filePath);
     _romanToIntConverter    = new RomanToIntConverter();
     _inputParser            = new InputParser(_romanToIntConverter);
     _answerGenerator        = new AnswerGenerator(_romanToIntConverter);
     _communicationProcessor = new CommunicationProcessor(_fileReader, _inputParser, _answerGenerator);
 }
Esempio n. 17
0
 /// <summary>
 /// Constructor to assign private variables
 /// </summary>
 public CommunicationProcessorTests()
 {
     _fileReader             = new MockFileReader();
     _romanToIntConverter    = new RomanToIntConverter();
     _inputParser            = new InputParser(_romanToIntConverter);
     _answerGenerator        = new AnswerGenerator(_romanToIntConverter);
     _communicationProcessor = new CommunicationProcessor(_fileReader, _inputParser, _answerGenerator);
 }
Esempio n. 18
0
        public void TestTouchscreenDrag()
        {
            // drag enabled
            _inputParser = InputParserBuilder.FromBare()
                           .Buttons("a")
                           .Touchscreen(width: 240, height: 160, multitouch: false, allowDrag: true)
                           .LengthRestrictions(maxSetLength: 2, maxSequenceLength: 4)
                           .Build();

            Assert.AreEqual(Seq(
                                new InputSet(new List <Input> {
                new Input("a", "a", "a")
            }),
                                new InputSet(new List <Input>
            {
                new TouchscreenDragInput("234,123>222,111", "touchscreen", "234,123>222,111", 234, 123, 222, 111)
            }),
                                new InputSet(new List <Input> {
                new Input("a", "a", "a")
            })
                                ), _inputParser.Parse("a234,123>222,111a"));
            Assert.AreEqual(Seq(
                                new InputSet(new List <Input>
            {
                new TouchscreenDragInput("239,159>0,0", "touchscreen", "239,159>0,0", 239, 159, 0, 0)
            })
                                ), _inputParser.Parse("239,159>0,0"));
            // allow leading zeroes
            Assert.AreEqual(Seq(
                                new InputSet(new List <Input>
            {
                new TouchscreenDragInput("000,000>000,000", "touchscreen", "000,000>000,000", 0, 0, 0, 0)
            })
                                ), _inputParser.Parse("000,000>000,000"));
            Assert.AreEqual(Seq(
                                new InputSet(new List <Input>
            {
                new TouchscreenDragInput("012,023>0,0", "touchscreen", "012,023>0,0", 12, 23, 0, 0)
            })
                                ), _inputParser.Parse("012,023>0,0"));
            // out of bounds
            Assert.IsNull(_inputParser.Parse("240,159>0,0"));
            Assert.IsNull(_inputParser.Parse("239,160>0,0"));
            Assert.IsNull(_inputParser.Parse("0,0>239,160"));
            Assert.IsNull(_inputParser.Parse("0,0>239,160"));
            // reject non-ascii decimal number symbols
            Assert.IsNull(_inputParser.Parse("১২৩,꧑꧒꧓>৪৫,꧔꧕"));

            // drag disabled
            _inputParser = InputParserBuilder.FromBare()
                           .Buttons("a")
                           .Touchscreen(width: 240, height: 160, multitouch: false, allowDrag: false)
                           .LengthRestrictions(maxSetLength: 2, maxSequenceLength: 4)
                           .Build();

            Assert.IsNull(_inputParser.Parse("a234,123>222,111a"));
            Assert.IsNull(_inputParser.Parse("239,159>0,0"));
        }
Esempio n. 19
0
 public CandiesAveragesCalculator(
     IInputParser inputParser,
     IOutputWriter outputWriter,
     ICandiesCalculator candiesCalculator)
 {
     _inputParser       = inputParser;
     _outputWriter      = outputWriter;
     _candiesCalculator = candiesCalculator;
 }
Esempio n. 20
0
 public void Setup()
 {
     _mockLogger             = new Mock <ILogger <IConsoleImporter> >();
     _mockImportAssetUseCase = new Mock <IImportAssetsUseCase>();
     _inputParser            = new ImportAssetInputParser();
     _mockFileReader         = new Mock <IFileReader <string> >();
     _textSplitter           = new TextSplitter();
     _classUnderTest         = new ConsoleImporter(_mockImportAssetUseCase.Object, _inputParser, _mockFileReader.Object, _textSplitter, _mockLogger.Object);
 }
        public CalculatorClientShould()
        {
            _calculator       = A.Fake <ICalculator>();
            _inputParser      = A.Fake <IInputParser>();
            _inputValidator   = A.Fake <IInputValidator>();
            _operatorProvider = A.Fake <IOperatorProvider>();

            _calculatorClient = new CalculatorClient(_calculator, _inputParser, _inputValidator, _operatorProvider);
        }
Esempio n. 22
0
        public InputParserShould()
        {
            var configuration         = A.Fake <IConfiguration>();
            var customDelimiterParser = A.Fake <ICustomDelimiterParser>();

            A.CallTo(() => configuration.Delimiters).Returns(new string[] { ",", @"\n" });

            parser = new InputParser(configuration, customDelimiterParser);
        }
Esempio n. 23
0
        public void TestConflictWithWait()
        {
            _inputParser = InputParserBuilder.FromBare()
                           .Buttons("a", "wait")
                           .LengthRestrictions(maxSetLength: 2, maxSequenceLength: 4)
                           .Build();

            Assert.AreEqual(Seq(Set("a"), Set("wait")), _inputParser.Parse("await"));
            Assert.IsNull(_inputParser.Parse("a+wait"));
        }
Esempio n. 24
0
 public Shell(
     ICommandParser commandParser,
     IInputParser inputParser,
     IPrinter printer)
 {
     _commandParser     = commandParser;
     _inputParser       = inputParser;
     _printer           = printer;
     _cancellationToken = new Option <CancellationTokenSource>();
     _isRunning         = true;
 }
Esempio n. 25
0
 public InputChecker(IPuzzleInput puzzleInput, [Dependency(nameof(CycleRunner3D))] ICycleRunner cycleRunner3,
                     [Dependency(nameof(InputParser3D))] IInputParser inputParser3,
                     [Dependency(nameof(CycleRunner4D))] ICycleRunner cycleRunner4,
                     [Dependency(nameof(InputParser4D))] IInputParser inputParser4)
 {
     _puzzleInput  = puzzleInput;
     _cycleRunner3 = cycleRunner3;
     _inputParser3 = inputParser3;
     _cycleRunner4 = cycleRunner4;
     _inputParser4 = inputParser4;
 }
Esempio n. 26
0
        public void TestInit()
        {
            //resolve command parser
            IInputParser inputParser = Container.Resolve <IInputParser>();

            //resolve board and robot
            board = Container.Resolve <IBoard>(new NamedParameter("Rows", rows),
                                               new NamedParameter("Columns", columns));
            robot = Container.Resolve <IRobot>(new NamedParameter("Board", board),
                                               new NamedParameter("InputParser", inputParser));
        }
Esempio n. 27
0
 public MathService(IInputParser parser)
 {
     _parser           = parser ?? throw new ArgumentNullException(nameof(parser));
     _negativeNumbers  = new List <int>();
     _operationStrings = new Dictionary <Operation, string>
     {
         { Operation.Add, "+" },
         { Operation.Sub, "-" },
         { Operation.Mul, "*" },
         { Operation.Div, "/" }
     };
 }
Esempio n. 28
0
        public void SetUp()
        {
            SystemTime.Now = () => new DateTime(2000, 1, 1);

            this.consoleMock         = Substitute.For <IConsole>();
            this.repositoryMock      = Substitute.For <IRepository <IUser> >();
            this.userWallMock        = Substitute.For <IWall>();
            this.parserMock          = Substitute.For <IInputParser>();
            this.brokerMock          = Substitute.For <IMessageBroker>();
            this.formaterFactoryMock = Substitute.For <IMessageFormaterFactory>();

            this.bob = new User("Bob", this.userWallMock);
        }
Esempio n. 29
0
        public void TestConflicts()
        {
            _inputParser = InputParserBuilder.FromBare()
                           .Buttons("a")
                           .DPad()
                           .LengthRestrictions(maxSetLength: 2, maxSequenceLength: 4)
                           .Build();

            AssertInput("aupdown", Seq(Set("a"), Set("up"), Set("down")));
            AssertInput("aup+down", null);
            AssertInput("adown+up", null);
            AssertInput("aupleft", Seq(Set("a"), Set("up"), Set("left")));
            AssertInput("aup+left", Seq(Set("a"), Set("up", "left")));
        }
Esempio n. 30
0
        public App(IInputParser inputParser, ICollection <ICommand> commands)
        {
            if (null == inputParser)
            {
                throw new ArgumentNullException(nameof(inputParser));
            }

            if (null == commands)
            {
                throw new ArgumentNullException(nameof(commands));
            }

            this._inputParser = inputParser;
            this._commands    = commands;
        }
Esempio n. 31
0
        static void Main(string[] args)
        {
            serviceProvider = DependecyResolver.RegisterServices();
            inputParser     = serviceProvider.GetService <IInputParser>();

            try
            {
                Start();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            serviceProvider.DisposeServices();
        }
 public Simulator(IToyRobot toyRobot, ISquareBoard squareBoard, IInputParser inputParser)
 {
     this.ToyRobot = toyRobot;
     this.SquareBoard = squareBoard;
     this.InputParser = inputParser;
 }
Esempio n. 33
0
        public void SetUp()
        {
            SystemTime.Now = () => new DateTime(2000, 1, 1);

            this.consoleMock = Substitute.For<IConsole>();
            this.repositoryMock = Substitute.For<IRepository<IUser>>();
            this.userWallMock = Substitute.For<IWall>();
            this.parserMock = Substitute.For<IInputParser>();
            this.brokerMock = Substitute.For<IMessageBroker>();
            this.formaterFactoryMock = Substitute.For<IMessageFormaterFactory>();

            this.bob = new User("Bob", this.userWallMock);
        }
Esempio n. 34
0
 public Program(IConsole consoleWrapper, IInputParser parser, IMessageFormaterFactory formaterFactory)
 {
     this.formaterFactory = formaterFactory;
     this.parser = parser;
     this.consoleWrapper = consoleWrapper;
 }
Esempio n. 35
0
 public void Init()
 {
     parser = new YamlParser ();
     definition = parser.Parse ("TestDatabase.yml");
 }
Esempio n. 36
0
 public Checkout(IInputParser ip, IItemService iss, IDiscountService ds)
 {
     _ip = ip;
     _is = iss;
     _ds = ds;
 }
Esempio n. 37
0
 public FormatConverter(IInputParser inputParser, IDocumentSerializer documentSerializer)
 {
     this.inputParser = inputParser;
     this.documentSerializer = documentSerializer;
 }