示例#1
0
    public AndConstraint <MovementAssertions> HaveMoves(InitialHiveBuilder initial, ExpectedMovementBuilder expected)
    {
        var expectedCoords = expected.ExpectedMoves();

        Execute.Assertion.Given(() => Subject(initial))
        .ForCondition(coords => coords.SetEquals(expectedCoords))
        .FailWith("\nResulting " + Identifier + "s did not match expected\n\nInitial:\n{1}\n\nActual - Expected:\n{2}\n",
                  _ => initial.OriginCell.Coords, _ => new StringBuilder(initial.ToColoredString(initial.ToString())),
                  actual => new StringBuilder(expected.GetMovementDiff(actual)));

        return(new AndConstraint <MovementAssertions>(this));
    }
示例#2
0
    public AndConstraint <AiAssertions> BeetleOnToQueen(InitialHiveBuilder initialBuilder, ExpectedAiBuilder expected)
    {
        var queenCell  = initialBuilder.AllCells.Where(c => !c.IsEmpty() && c.Tiles.Any(t => t.Creature.Name == Creatures.Queen.Name));
        var beetleCell = initialBuilder.AllCells.Where(c => !c.IsEmpty() && c.Tiles.Any(t => t.Creature.Name == Creatures.Beetle.Name))
                         .Select(c => c.TopTile());

        Execute.Assertion.Given(() => Subject())
        .ForCondition(result => queenCell.Any(c => c.Coords == result.Coords) && beetleCell.Any(t => t.Id == result.Tile.Id))
        .FailWith(
            "\nResulting " + Identifier + "s did not match expected\n\nInitial:\n{1}\n\nActual - Expected:\n{2}\n",
            _ => initialBuilder.OriginCells.Count,
            _ => new StringBuilder(initialBuilder.ToColoredString(initialBuilder.ToString())),
            actual => new StringBuilder(expected.GetMoveDiff(new HashSet <(Coords Coords, Tile Tile)>(), actual))
            );

        return(new AndConstraint <AiAssertions>(this));
    }
示例#3
0
    public AndConstraint <AiAssertions> MatchHive(InitialHiveBuilder initialBuilder, ExpectedAiBuilder expected)
    {
        var expectedMoves = expected.ExpectedMoves();
        var expectedTiles = initialBuilder.AllCells.Where(c => expected.OriginCells.Contains(c))
                            .Select(c => (c.Coords, Tile: c.TopTile()))
                            .ToHashSet();

        expectedTiles.UnionWith(expected.PlayerTrayMoves);

        Execute.Assertion.Given(() => Subject())
        .ForCondition(result => expectedTiles.Any(t => t.Tile.Id == result.Tile.Id) && expectedMoves.Contains(result.Coords))
        .FailWith(
            "\nResulting " + Identifier + "s did not match expected\n\nInitial:\n{1}\n\nActual - Expected:\n{2}\n",
            _ => initialBuilder.OriginCells.Count,
            _ => new StringBuilder(initialBuilder.ToColoredString(initialBuilder.ToString())),
            actual => new StringBuilder(expected.GetMoveDiff(expectedTiles, actual))
            );

        return(new AndConstraint <AiAssertions>(this));
    }