public async Task Provision_Ensures_Type_Is_Set() { var input = new MockInput(); var server = new MockServer(); input.provision = (obj) => { var interop = (DevicePayload)obj; var json = JObject.Parse(interop.Properties); Assert.That(json.GetValue("type").ToString(), Is.EqualTo("led")); return(Task.Run(() => (object)null)); }; server.find = (i) => { return(Task.Run(() => (object)"[{\"id\":\"123\"}]")); }; server.prepare = (i) => { return(Task.Run(() => (object)i)); }; input.server = server; var loader = ScoutLoader.Create(input); await loader.Use(new LEDScout()); }
public void SetUp() { _input = new MockInput(); _output = new MockOutput(); _menu = new SelectEnemyFighterMenu(_input, _output, false); }
public async Task Use_Sets_Discover_Function_From_Loader() { var input = new MockInput(); var server = new MockServer(); var hasRun = false; server.find = (i) => { return(Task.Run(() => (object)"[]")); }; input.server = server; input.discover = (obj) => Task.Run(() => { hasRun = true; return((object)null); }); input.provision = (obj) => Task.Run(() => { return((object)null); }); var loader = ScoutLoader.Create(input); var scout = new LEDScout(); await loader.Use(scout); await scout.Discover(Device.Create <LED>()).ContinueWith((obj) => { Assert.That(hasRun, Is.True); }); }
public void SetUp() { _menuInput = new MockInput(); _menuOutput = new MockOutput(); _menuManager = new SelectEnemyTeamMenuManager(_menuInput, _menuOutput); }
public void Setup() { _fighter = new TestHumanFighter("Hero", 1); _fighter.SetHealth(FighterHealth); _fighter.SetMana(FighterMana); _fighter.SetStrength(FighterAttack); _fighter.SetDefense(FighterDefense); _fighter.SetSpeed(FighterSpeed); _fighter.SetEvade(FighterEvade); _fighter.SetLuck(FighterLuck); _factoryFighter = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "Ted"); _factoryFighter.AddSpell(SpellFactory.GetSpell(MagicType.Fire, 1)); _enemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "enemy"); _armoredEnemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "armored"); _superArmoredEnemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "super armored"); _input = new MockInput(); _output = new MockOutput(); _menuManager = new TestMenuManager(_input, _output); _chanceService = new MockChanceService(); _battleManager = new TestBattleManager(_chanceService, _input, _output); var humanTeam = new Team(_menuManager, _fighter); _battleManager.SetHumanTeam(humanTeam); var enemyTeam = new Team(_menuManager, _enemy); _battleManager.SetEnemyTeam(enemyTeam); _battleManager.SetConfig(new BattleManagerBattleConfiguration()); }
public void SetUp() { _input = new MockInput(); _output = new MockOutput(); _menu = new NumberInputMenu("foo", _input, _output, MinValue, MaxValue); }
public void SetUp() { _menuInput = new MockInput(); _menuOutput = new MockOutput(); _menuManager = new TestMenuManager(_menuInput, _menuOutput); SetUpAndBuildMenu(false); }
public void SetUp() { _input = new MockInput(); _output = new MockOutput(); _menuFactory = new MenuFactory(); _manager = new MenuManager(_input, _output, _menuFactory); _logger = new EventLogger(); _playerOne = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "swordsman"); Spell fireSpell = SpellFactory.GetSpell(MagicType.Fire, 1); _playerOne.AddSpell(fireSpell); _playerOne.SetMana(fireSpell.Cost); _playerTwo = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "mage"); _playerThree = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "alchemist"); _playerTeam = new Team(_manager, _playerOne, _playerTwo, _playerThree); _enemyTeam = new Team(_manager, new List <IFighter> { FighterFactory.GetFighter(FighterType.Goblin, 1), FighterFactory.GetFighter(FighterType.Goblin, 1), FighterFactory.GetFighter(FighterType.Goblin, 1) }); _manager.InitializeForBattle(_playerTeam, _enemyTeam); }
public void Setup() { _input = new MockInput(); _output = new MockOutput(); _menuManager = new TestMenuManager(_input, _output); _logger = new EventLogger(); _mockChanceService = new MockChanceService(); TestFighterFactory.SetChanceService(_mockChanceService); _battleManager = new BattleManager(_mockChanceService, _input, _output); _humanPlayer1 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "Ted"); _humanPlayer2 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "Jed"); _humanPlayer2.AddSpell(_fireball); _humanPlayer2.SetMana(_fireball.Cost); _humanPlayer2.TurnEnded += TurnEndedEvents.RestoreManaOnTurnEnd; _enemyPlayer1 = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "Enemy"); _enemyPlayer2 = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "Enemy"); _humanTeam = new TestTeam(_menuManager, _humanPlayer1, _humanPlayer2); _enemyTeam = new Team(_menuManager, _enemyPlayer1, _enemyPlayer2); }
public void SetUp() { _input = new MockInput(); _output = new MockOutput(); _menu = new NameInputMenu(_input, _output); }
public void When_projecting_a_successful_result() { var input = new MockInput<int>(); var childParser = new MockSuccessfulParser<int, double>(1.0); var parser = new ProjectionParser<int, double, decimal>(childParser, d => (decimal) d + 3.0m); var actualResult = parser.Parse(input); ParseResultAssert.IsSuccess(actualResult); ParseResultAssert.AreEqual(4.0m, actualResult); }
public void When_projecting_a_failure_result() { var input = new MockInput<int>(); var childParser = new MockFailureParser<int, double>(); var parser = new ProjectionParser<int, double, decimal>(childParser, d => (decimal) d + 3.0m); var actualResult = parser.Parse(input); ParseResultAssert.IsFailure(actualResult); Assert.AreEqual(input, actualResult.FirstInput); }
public void TearDown() { _menu = null; _menuInput = null; _menuOutput = null; _enemyTeam = null; _player = null; _playerTeam = null; }
public void SetUp() { _menuInput = new MockInput(); _menuOutput = new MockOutput(); _menuManager = new TestMenuManager(_menuInput, _menuOutput); _player = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); Spell fireball = SpellFactory.GetSpell(MagicType.Fire, 1); Spell earthSpell = SpellFactory.GetSpell(MagicType.Earth, 1); _player.AddSpell(fireball); _player.AddSpell(earthSpell); _player.SetMana(fireball.Cost); _playerTeam = new Team(_menuManager, _player); _enemyTeam = new Team(_menuManager, (EnemyFighter)FighterFactory.GetFighter(FighterType.Goblin, 1)); _menu = (Menu)Globals.MenuFactory.GetMenu(MenuType.ChooseAttackTypeMenu, _menuInput, _menuOutput); _menu.Build(_player, _playerTeam, _enemyTeam, null); _fullSpellMenuPrompt = new List <string> { $"Which spell would you like to cast?\n{_player.DisplayName} currently has {_player.CurrentMana} / {_player.MaxMana} Mana\n", }; var spellMenu = (SpellSelectionMenu)Globals.MenuFactory.GetMenu(MenuType.ChooseSpellMenu); spellMenu.Build(_player, _playerTeam, _enemyTeam, null); var spellMenuActions = spellMenu.MenuActions; for (var i = 0; i < spellMenuActions.Count; ++i) { _fullSpellMenuPrompt.Add((i + 1) + ". " + spellMenuActions[i].DisplayText + "\n"); } _fullSpellMenuPrompt.Add(StatusPrompt); _fullSpellMenuPrompt.Add(HelpPrompt); _fullMenuPrompt = new List <string> { "How would you like to fight?\n", "1. attack\n", "2. magic\n", StatusPrompt, HelpPrompt }; _fullTargetMenuPrompt = new List <string> { "Who will you target for this action?\n", "1. " + _enemyTeam.Fighters[0].DisplayName + "\n", StatusPrompt, BackPrompt, HelpPrompt }; }
public void TearDown() { _input = null; _output = null; _fighter = null; _fighterTeam = null; _enemy = null; _enemyTeam = null; }
public void TearDown() { _input = null; _output = null; _chanceService = null; _humanFighter = null; _humanTeam = null; _enemyTeam = null; }
public void TearDown() { _input = null; _output = null; _playerOne = null; _playerTwo = null; _playerThree = null; _playerTeam = null; _enemyTeam = null; _manager = null; }
public void SetUp() { _input = new MockInput(); _output = new MockOutput(); _menu = new KeysOffOwnerNumberInputMenu("foo", _input, _output); _owner = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); _ownerTeam = new TestTeam(_owner); _enemyTeam = new TestTeam((TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1)); }
public void Cast_called_on_a_successful_result() { var firstInput = new MockInput<int>(); var remainingInput = new MockInput<int>(); var originalResult = ParseResult.Success(firstInput, firstInput, 1.0); var actualResult = originalResult.Cast<int, double, decimal>(); Assert.AreEqual(originalResult.FirstInput, actualResult.FirstInput); Assert.AreEqual(originalResult.RemainingInput, actualResult.RemainingInput); ParseResultAssert.IsSuccess(actualResult); ParseResultAssert.AreEqual(1.0m, actualResult); }
public void SetUp() { _input = new MockInput(); _output = new MockOutput(); _fighter = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); _fighterTeam = new TestTeam(_fighter); _enemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1); _enemyTeam = new TestTeam(_enemy); }
public void Cast_called_on_a_failed_result() { var firstInput = new MockInput<int>(); var remainingInput = new MockInput<int>(); var mockParser = new MockFailureParser<int, double>(); var originalResult = ParseResult.Failure<int, double>(firstInput, mockParser); var actualResult = originalResult.Cast<int, double, decimal>(); Assert.AreEqual(originalResult.FirstInput, actualResult.FirstInput); Assert.AreEqual(originalResult.RemainingInput, actualResult.RemainingInput); ParseResultAssert.IsFailure(actualResult); }
public void When_no_items_match_but_were_required() { var input = new MockInput<int>(); var parser = new RepetitionParser<int, int>( minimumCount: 1, parser: new MockSequenceParser<int, int> { p => ParseResult.Failure<int, int>(input, p) } ); var actualResult = parser.Parse(input); ParseResultAssert.IsFailure(actualResult); }
public void SetUp() { _output = new MockOutput(); _input = new MockInput(); _chanceService = new MockChanceService(); _relationshipManager = new GodRelationshipManager(); FighterFactory.SetGodRelationshipManager(_relationshipManager); _menuFactory = new MockMenuFactory(); _decisionManager = new DecisionManager(_relationshipManager, null, _menuFactory, _input, _output); }
public void Setup() { _input = new MockInput(); _output = new MockOutput(); _menuManager = new TestMenuManager(_input, _output); _mockChanceService = new MockChanceService(); TestFighterFactory.SetChanceService(_mockChanceService); FighterFactory.SetInput(_input); FighterFactory.SetOutput(_output); _fighter = (HumanControlledEnemyFighter)FighterFactory.GetFighter(FighterType.HumanControlledEnemy, 1, "hero"); _enemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "enemy"); }
public void SetUp() { _menuInput = new MockInput(); _menuOutput = new MockOutput(); _menuManager = new TestMenuManager(_menuInput, _menuOutput); _enemyTeam = new Team(_menuManager, FighterFactory.GetFighter(FighterType.Goblin, 1)); _player = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); _playerTeam = new Team(_menuManager, _player); _menu = (SpecialMoveSelectionMenu)Globals.MenuFactory.GetMenu(MenuType.ChooseSpecialAttackMenu, _menuInput, _menuOutput); _menu.Build(_player, _playerTeam, _enemyTeam, null); }
public void When_a_single_item_matches() { var input = new MockInput<int>(); var parser = new RepetitionParser<int, int>( new MockSequenceParser<int, int> { p => ParseResult.Success(input, input, 1), p => ParseResult.Failure<int, int>(input, p) } ); var actualResult = parser.Parse(input); var actualCollection = ParseResultAssert.IsSuccess(actualResult); CollectionAssert.AreElementsEqual(new[] { 1 }, actualCollection); }
public void Setup() { pozo = GameObject.Instantiate(pozoPref); pozo.transform.position = Vector3.zero; gc = GameObject.Instantiate(gcPref); GameController gameController = gc.GetComponent <GameController>(); im = gc.AddComponent <MockInput>(); InteractArea ia = pozo.GetComponentInChildren <InteractArea>(); ia.gameController = gameController; }
public void SetUp() { _chanceService = new MockChanceService(); _output = new MockOutput(); _input = new MockInput(); _team1Fighter = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1); _team2Fighter = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1); _team1 = new Team(TestMenuManager.GetTestMenuManager(), _team1Fighter); _team2 = new Team(TestMenuManager.GetTestMenuManager(), _team2Fighter); _battleManager = new TestBattleManager(_chanceService, _input, _output); }
public void When_no_items_match_but_were_not_required() { var input = new MockInput<int>(); var parser = new RepetitionParser<int, int>( minimumCount: 0, parser: new MockSequenceParser<int, int> { p => ParseResult.Failure<int, int>(input, p) } ); var actualResult = parser.Parse(input); var actualCollection = ParseResultAssert.IsSuccess(actualResult); CollectionAssert.AreElementsEqual(new int[] { }, actualCollection); }
public void Setup() { _input = new MockInput(); _output = new MockOutput(); _menuManager = new TestMenuManager(_input, _output); _chanceService = new MockChanceService(); _battleManager = new TestBattleManager(_chanceService, _input, _output); _logger = new EventLogger(); _humanFighter = new TestHumanFighter("foo", 1); _humanTeam = new TestTeam(_humanFighter); _enemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1); _enemyTeam = new Team(_menuManager, _enemy); }
public IEnumerator Third_person_camera_doesnt_phase_through_walls() { //Creating a bunch of vector2 noise to see if we can cause the player cam to clip through a collider's surface set at z = 5; var movementsPerFrame = getRandomVector2s(2500, -12, 12); List <float> allCameraZPositions = new List <float>(); for (int i = 0; i < movementsPerFrame.Count; i++) { allCameraZPositions.Add(avatarCamera.transform.position.z); var input = new MockInput(movementsPerFrame[i], Vector2.zero); scriptableInput.input = input; yield return(null); // Yield return null allows the next frame to render. } Assert.IsFalse(allCameraZPositions.Where(p => p > 5).Any()); }
public void Setup() { _input = new MockInput(); _output = new MockOutput(); _chanceService = new MockChanceService(); _menuManager = new TestMenuManager(_input, _output); TestFighterFactory.SetChanceService(_chanceService); _humanFighter = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); _humanTeam = new Team(_menuManager, _humanFighter); _level1Warrior = (Warrior)FighterFactory.GetFighter(FighterType.Warrior, 1); _level3Warrior = (Warrior)FighterFactory.GetFighter(FighterType.Warrior, 3); _warriorTeam = new Team(_menuManager, _level1Warrior); }
public void IfFailure_called_on_a_failed_result() { var firstInput = new MockInput<int>(); var remainingInput = new MockInput<int>(); var expectedResult = new MockParseResult<int, double>(); var mockParser = new MockFailureParser<int, double>(); var originalResult = ParseResult.Failure<int, double>(firstInput, mockParser); var actualResult = originalResult.IfFailure( successfulResult => { Assert.AreEqual(originalResult, successfulResult); return expectedResult; } ); Assert.AreEqual(expectedResult, actualResult); }
public void Setup() { _input = new MockInput(); _output = new MockOutput(); _menuManager = new TestMenuManager(_input, _output); _mockChanceService = new MockChanceService(); TestFighterFactory.SetChanceService(_mockChanceService); _fighter = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "hero"); _enemy1 = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1, "enemy"); _enemy2 = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1, "enemy"); _ownTeam = new Team(_menuManager, _fighter); _singleEnemyTeam = new Team(_menuManager, _enemy1); _doubleEnemyTeam = new Team(_menuManager, _enemy1, _enemy2); }
public void SetUp() { _input = new MockInput(); _output = new MockOutput(); _menuManager = new TestMenuManager(_input, _output); _chanceService = new MockChanceService(); _battleManager = new BattleManager(_chanceService, _input, _output); _human = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); _humanTeam = new TestTeam(_menuManager, _human); _enemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1); _enemyTeam = new Team(_menuManager, _enemy); _doNothingMove = (DoNothingMove)MoveFactory.Get(BattleMoveType.DoNothing); }
public void Setup() { _logger = new EventLogger(); _input = new MockInput(); _output = new MockOutput(); _menuManager = new TestMenuManager(_input, _output); _chanceService = new MockChanceService(); TestFighterFactory.SetChanceService(_chanceService); _shade1 = (Shade)FighterFactory.GetFighter(FighterType.Shade, 1); _shade2 = (Shade)FighterFactory.GetFighter(FighterType.Shade, 1); _shade3 = (Shade)FighterFactory.GetFighter(FighterType.Shade, 1); _shades = new List <Shade> { _shade1, _shade2, _shade3 }; _shadeGrouping = new ShadeFighterGrouping(_chanceService, _shades.ToArray()); _shadeTeam = new Team(TestMenuManager.GetTestMenuManager(), _shadeGrouping); _humanFighter = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); _humanFighter.SetSpeed(_shade1.Speed + 1); _humanTeam = new Team(_menuManager, _humanFighter); List <BattleMove> executableMoves = _shade1.GetExecutableMoves(_humanTeam); _absorptionMoveIndex = executableMoves.FindIndex(bm => bm.MoveType == BattleMoveType.AbsorbShade); _malevolenceChargeIndex = executableMoves.FindIndex(bm => bm.MoveType == BattleMoveType.Special); _malevolenceAttackIndex = executableMoves.FindIndex(bm => bm.MoveType == BattleMoveType.ConditionalPowerAttack); _darkFogIndex = executableMoves.FindIndex(bm => bm is StatusMove); _malevolenceChargeMove = executableMoves[_malevolenceChargeIndex]; _malevolenceAttackMove = executableMoves[_malevolenceAttackIndex]; _shadeAbsorbingMove = executableMoves[_absorptionMoveIndex]; Shade fooShade = new Shade(1, _chanceService, 1); Team fooTeam = new Team(TestMenuManager.GetTestMenuManager(), fooShade); fooShade.SetTeam(fooTeam); List <BattleMove> fooExecutableAttacks = fooShade.GetExecutableMoves(_humanTeam); _malevolenceAttackNoAbsorptionMoveIndex = fooExecutableAttacks.FindIndex(bm => bm.MoveType == BattleMoveType.ConditionalPowerAttack); _malevolenceChargeNoAbsorptionMoveIndex = fooExecutableAttacks.FindIndex(bm => bm.MoveType == BattleMoveType.Special); _battleManager = new TestBattleManager(_chanceService, _input, _output); }
public void TearDown() { _logger = null; _input = null; _output = null; _menuManager = null; _chanceService = null; _shade1 = null; _shade2 = null; _shade3 = null; _shadeGrouping = null; _shadeTeam = null; _humanFighter = null; _humanTeam = null; }
public void Setup() { _input = new MockInput(); _output = new MockOutput(); _chanceService = new MockChanceService(); _menuManager = new TestMenuManager(_input, _output); _battleManager = new TestBattleManager(_chanceService, _input, _output); TestFighterFactory.SetChanceService(_chanceService); _humanFighter = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); _humanTeam = new Team(_menuManager, _humanFighter); _level1ShieldGuy = (ShieldGuy)FighterFactory.GetFighter(FighterType.ShieldGuy, 1); _ally1 = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1); _ally2 = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1); _shieldGuyTeam = new Team(_menuManager, _level1ShieldGuy, _ally1, _ally2); }
public void When_both_parts_fail() { var input = new MockInput<int>(); var parser = new ConcatenationParser<int, char, char, string>( new MockFailureParser<int, char>(), (first) => { Assert.Fail(); return new MockFailureParser<int, char>(); }, (a, b) => { Assert.Fail(); return "x"; }); var result = parser.Parse(input); ParseResultAssert.IsFailure(result); }
public void When_both_parts_match() { var input = new MockInput<int>(); var parser = new ConcatenationParser<int, char, char, string>( new MockSuccessfulParser<int, char>('s'), (first) => { Assert.AreEqual('s', first); return new MockSuccessfulParser<int, char>('d'); }, (a, b) => { Assert.AreEqual('s', a); Assert.AreEqual('d', b); return "x"; }); var result = parser.Parse(input); ParseResultAssert.IsSuccess(result); ParseResultAssert.AreEqual("x", result); }
public void When_the_first_part_matches_but_the_second_fails() { var input = new MockInput<int>(); var parser = new ConcatenationParser<int, char, char, string>( new MockSuccessfulParser<int, char>('s'), new MockFailureParser<int, char>(), (a, b) => { Assert.Fail(); return ""; }); var result = parser.Parse(input); ParseResultAssert.IsFailure(result); }
public void IfSuccess_called_on_a_failed_result() { var firstInput = new MockInput<int>(); var mockParser = new MockFailureParser<int, double>(); var originalResult = ParseResult.Failure<int, double>(firstInput, mockParser); var actualResult = originalResult.IfSuccess( successfulResult => { Assert.Fail("IfSuccess called the action, somehow"); return originalResult; } ); Assert.AreEqual(originalResult.FirstInput, actualResult.FirstInput); Assert.AreEqual(originalResult.RemainingInput, actualResult.RemainingInput); ParseResultAssert.IsFailure(actualResult); }
public void IfSuccess_called_on_a_successful_result() { var firstInput = new MockInput<int>(); var remainingInput = new MockInput<int>(); var expectedResult = new MockParseResult<int, double>(); var originalResult = ParseResult.Success(firstInput, remainingInput, 123); var actualResult = originalResult.IfSuccess( successfulResult => { Assert.AreEqual(originalResult, successfulResult); return expectedResult; } ); Assert.AreEqual(expectedResult, actualResult); }
public void IfFailure_called_on_a_successful_result() { var firstInput = new MockInput<int>(); var remainingInput = new MockInput<int>(); var originalResult = ParseResult.Success(firstInput, remainingInput, 123); var actualResult = originalResult.IfFailure( successfulResult => { Assert.Fail("IfFailure called the action, somehow"); return originalResult; } ); Assert.AreEqual(originalResult.FirstInput, actualResult.FirstInput); Assert.AreEqual(originalResult.RemainingInput, actualResult.RemainingInput); ParseResultAssert.IsSuccess(actualResult); }
public void When_three_items_match_but_required_four() { var input = new MockInput<int>(); var parser = new RepetitionParser<int, int>( minimumCount: 4, parser: new MockSequenceParser<int, int> { ParseResult.Success(input, input, 1), ParseResult.Success(input, input, 2), ParseResult.Success(input, input, 3), p => ParseResult.Failure<int, int>(input, p) } ); var actualResult = parser.Parse(input); ParseResultAssert.IsFailure(actualResult); }