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); }
public Player(IPlayerInteractionService interactionService, IInputParser inputParser, ILogger logger) { _interactionService = interactionService; _inputParser = inputParser; _logger = logger; MoveCount = 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); }
/// <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); }
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")); }
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")); }
public void Init() { var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); _inputFilename = dir + "\\SampleInput.txt"; _inputParser = new InputParser(); }
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")); }
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_; }
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; }
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); }
/// <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); }
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")); }
public CandiesAveragesCalculator( IInputParser inputParser, IOutputWriter outputWriter, ICandiesCalculator candiesCalculator) { _inputParser = inputParser; _outputWriter = outputWriter; _candiesCalculator = candiesCalculator; }
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); }
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); }
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")); }
public Shell( ICommandParser commandParser, IInputParser inputParser, IPrinter printer) { _commandParser = commandParser; _inputParser = inputParser; _printer = printer; _cancellationToken = new Option <CancellationTokenSource>(); _isRunning = true; }
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; }
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)); }
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, "/" } }; }
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); }
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"))); }
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; }
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; }
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); }
public Program(IConsole consoleWrapper, IInputParser parser, IMessageFormaterFactory formaterFactory) { this.formaterFactory = formaterFactory; this.parser = parser; this.consoleWrapper = consoleWrapper; }
public void Init() { parser = new YamlParser (); definition = parser.Parse ("TestDatabase.yml"); }
public Checkout(IInputParser ip, IItemService iss, IDiscountService ds) { _ip = ip; _is = iss; _ds = ds; }
public FormatConverter(IInputParser inputParser, IDocumentSerializer documentSerializer) { this.inputParser = inputParser; this.documentSerializer = documentSerializer; }