当前位置: 首页>>代码示例>>C#>>正文


C# Solver.SolvePuzzle方法代码示例

本文整理汇总了C#中Solver.SolvePuzzle方法的典型用法代码示例。如果您正苦于以下问题:C# Solver.SolvePuzzle方法的具体用法?C# Solver.SolvePuzzle怎么用?C# Solver.SolvePuzzle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Solver的用法示例。


在下文中一共展示了Solver.SolvePuzzle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Board

        public void SolvePuzzle_GivenAPieceFeederThatFeedsAWrongPermutationThenACorrectPermutation_SolvesThePuzzleOnTheSecondPermutation()
        {
            // Arrange
            var board = new Board(TestBoardSize);
            var solver = new Solver();
            var mockPieceFeeder = new Mock<IPieceFeeder>();

            mockPieceFeeder.SetupGet(x => x.Permutations).Returns(
                new[]
                    {
                        new[]
                            {
                                new RotatedPiece(Piece.TestPieceA, Orientation.North),
                                new RotatedPiece(Piece.TestPieceB, Orientation.North),
                                new RotatedPiece(Piece.TestPieceC, Orientation.North),
                                new RotatedPiece(Piece.TestPieceD, Orientation.North)
                            },
                        new[]
                            {
                                new RotatedPiece(Piece.TestPieceA, Orientation.North),
                                new RotatedPiece(Piece.TestPieceC, Orientation.North),
                                new RotatedPiece(Piece.TestPieceD, Orientation.North),
                                new RotatedPiece(Piece.TestPieceB, Orientation.North)
                            }
                    });
            mockPieceFeeder.SetupGet(x => x.Pieces).Returns(new[] {Piece.TestPieceA, Piece.TestPieceB, Piece.TestPieceC, Piece.TestPieceD});

            // Act
            var actual = solver.SolvePuzzle(board, mockPieceFeeder.Object);

            // Assert
            Assert.That(actual.Solved, Is.True);
            Assert.That(actual.Iterations, Is.EqualTo(2));
            Assert.That(board.IsSolved(), Is.True);
            mockPieceFeeder.Verify(x => x.Permutations, Times.Once());
        }
开发者ID:taylorjg,项目名称:DraughtBoardPuzzle,代码行数:36,代码来源:SolverTests.cs

示例2: SolvePuzzle_GivenASinglePermutationOfPiecesNotInTheCorrectOrderAndOrientation_DoesNotSolveThePuzzle

        public void SolvePuzzle_GivenASinglePermutationOfPiecesNotInTheCorrectOrderAndOrientation_DoesNotSolveThePuzzle()
        {
            // Arrange
            var board = new Board(TestBoardSize);
            var solver = new Solver();
            var mockPieceFeeder = new Mock<IPieceFeeder>();

            mockPieceFeeder.SetupGet(x => x.Permutations).Returns(
                new[]
                    {
                        new[]
                            {
                                new RotatedPiece(Piece.TestPieceA, Orientation.North),
                                new RotatedPiece(Piece.TestPieceB, Orientation.North),
                                new RotatedPiece(Piece.TestPieceC, Orientation.North),
                                new RotatedPiece(Piece.TestPieceD, Orientation.North)
                            }
                    });
            mockPieceFeeder.SetupGet(x => x.Pieces).Returns(new[] { Piece.TestPieceA, Piece.TestPieceB, Piece.TestPieceC, Piece.TestPieceD });

            // Act
            var actual = solver.SolvePuzzle(board, mockPieceFeeder.Object);

            // Assert
            Assert.That(actual.Solved, Is.False);
            Assert.That(actual.Iterations, Is.EqualTo(1));
            Assert.That(board.IsSolved(), Is.False);
        }
开发者ID:taylorjg,项目名称:DraughtBoardPuzzle,代码行数:28,代码来源:SolverTests.cs

示例3: SolvePuzzle_GivenInsaneData_ThrowsException

        public void SolvePuzzle_GivenInsaneData_ThrowsException()
        {
            // Arrange
            var board = new Board(TestBoardSize);
            var solver = new Solver();
            var pieceFeeder = new PieceFeeder(Piece.TestPieceA, Piece.TestPieceB, Piece.TestPieceC);

            // Act, Assert
            Assert.Throws<InvalidOperationException>(() => solver.SolvePuzzle(board, pieceFeeder));
        }
开发者ID:taylorjg,项目名称:DraughtBoardPuzzle,代码行数:10,代码来源:SolverTests.cs

示例4: SolvePuzzle_GivenAPieceFeederThatIncludesTheCorrectPermutation_ReturnsTheCorrectPermutation

        public void SolvePuzzle_GivenAPieceFeederThatIncludesTheCorrectPermutation_ReturnsTheCorrectPermutation()
        {
            // Arrange
            var board = new Board(TestBoardSize);
            var solver = new Solver();
            var mockPieceFeeder = new Mock<IPieceFeeder>();

            mockPieceFeeder.SetupGet(x => x.Permutations).Returns(
                new[]
                    {
                        new[]
                            {
                                new RotatedPiece(Piece.TestPieceA, Orientation.North),
                                new RotatedPiece(Piece.TestPieceB, Orientation.North),
                                new RotatedPiece(Piece.TestPieceC, Orientation.North),
                                new RotatedPiece(Piece.TestPieceD, Orientation.North)
                            },
                        new[]
                            {
                                new RotatedPiece(Piece.TestPieceA, Orientation.North),
                                new RotatedPiece(Piece.TestPieceC, Orientation.North),
                                new RotatedPiece(Piece.TestPieceD, Orientation.North),
                                new RotatedPiece(Piece.TestPieceB, Orientation.North)
                            }
                    });
            mockPieceFeeder.SetupGet(x => x.Pieces).Returns(new[] { Piece.TestPieceA, Piece.TestPieceB, Piece.TestPieceC, Piece.TestPieceD });

            // Act
            var actual = solver.SolvePuzzle(board, mockPieceFeeder.Object);
            var solution = actual.Solution.ToArray();

            // Assert
            Assert.That(solution[0].Piece, Is.SameAs(Piece.TestPieceA));
            Assert.That(solution[0].Orientation, Is.EqualTo(Orientation.North));

            Assert.That(solution[1].Piece, Is.SameAs(Piece.TestPieceC));
            Assert.That(solution[1].Orientation, Is.EqualTo(Orientation.North));

            Assert.That(solution[2].Piece, Is.SameAs(Piece.TestPieceD));
            Assert.That(solution[2].Orientation, Is.EqualTo(Orientation.North));

            Assert.That(solution[3].Piece, Is.SameAs(Piece.TestPieceB));
            Assert.That(solution[3].Orientation, Is.EqualTo(Orientation.North));
        }
开发者ID:taylorjg,项目名称:DraughtBoardPuzzle,代码行数:44,代码来源:SolverTests.cs


注:本文中的Solver.SolvePuzzle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。