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


C# Game.PlayCard方法代码示例

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


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

示例1: PlayCard_throws_InvalidOperationException_when_user_does_not_have_card

        public void PlayCard_throws_InvalidOperationException_when_user_does_not_have_card()
        {
            // Arrange.
            const int seed = 42;
            var userId = Guid.NewGuid();
            var card = new Card(Suit.Hearts, Rank.King);
            var sut = new Game().Initialize(Guid.NewGuid(), 2)
                                .AddUser(Guid.NewGuid())
                                .AddUser(userId)
                                .Start(seed);

            // Act.
            TestDelegate test = () => sut.PlayCard(userId, 2, 5, card);

            // Assert.
            Assert.That(test, Throws.InvalidOperationException.With.Message.EqualTo("User does not have that card."));
        }
开发者ID:jbfp,项目名称:Sequence_old,代码行数:17,代码来源:GameTests.cs

示例2: PlayCard_throws_InvalidOperationException_when_user_is_not_in_game

        public void PlayCard_throws_InvalidOperationException_when_user_is_not_in_game()
        {
            // Arrange.
            var sut = new Game().Initialize(Guid.NewGuid(), 2)
                                .AddUser(Guid.NewGuid())
                                .AddUser(Guid.NewGuid());

            // Act.
            TestDelegate test = () => sut.PlayCard(Guid.NewGuid(), 1, 1, Card.Empty);

            // Assert.
            Assert.That(test, Throws.InvalidOperationException);
        }
开发者ID:jbfp,项目名称:Sequence_old,代码行数:13,代码来源:GameTests.cs

示例3: PlayCard_throws_InvalidOperationException_when_trying_to_remove_nonexisting_chip

        public void PlayCard_throws_InvalidOperationException_when_trying_to_remove_nonexisting_chip()
        {
            // Arrange.
            var userId = Guid.NewGuid();
            var jack = new Card(Suit.Spades, Rank.Jack);
            var sut = new Game().Initialize(Guid.NewGuid(), 2)
                                .AddUser(Guid.NewGuid())
                                .AddUser(userId)
                                .Start(1);

            // Act.
            TestDelegate test = () => sut.PlayCard(userId, 1, 1, jack);

            // Assert.
            Assert.That(test, Throws.InvalidOperationException.With.Message.EqualTo("Tile is empty."));
        }
开发者ID:jbfp,项目名称:Sequence_old,代码行数:16,代码来源:GameTests.cs

示例4: PlayCard_throws_InvalidOperationException_when_coordinate_is_shared

        public void PlayCard_throws_InvalidOperationException_when_coordinate_is_shared()
        {
            // Arrange.
            var sut = new Game().Initialize(Guid.NewGuid(), 2)
                                .AddUser(Guid.NewGuid())
                                .AddUser(Guid.NewGuid());

            // Act.
            TestDelegate test = () => sut.PlayCard(sut.Users[0], 0, 0, Card.Empty);

            // Assert.
            Assert.That(test, Throws.InvalidOperationException);
        }
开发者ID:jbfp,项目名称:Sequence_old,代码行数:13,代码来源:GameTests.cs

示例5: PlayCard_throws_InvalidOperationException_when_coordinate_is_part_of_a_sequence

        public void PlayCard_throws_InvalidOperationException_when_coordinate_is_part_of_a_sequence()
        {
            // Arrange.
            const int seed = 42;
            var user1 = Guid.NewGuid();
            var user2 = Guid.NewGuid();
            var card = new Card(Suit.Hearts, Rank.King);
            var sequence = new Sequence(1, 1, 5, SequenceDirection.Horizontal, Team.B);
            var sequences = new List<Sequence> { sequence }.AsReadOnly();
            var boardMock = new Mock<IGameBoard>();
            boardMock.Setup(gb => gb.GetSequences())
                     .Returns(sequences);
            var sut = new Game(_deck, boardMock.Object).Initialize(Guid.NewGuid(), 2)
                                                           .AddUser(user1)
                                                           .AddUser(user2)
                                                           .Start(seed);

            // Act.
            TestDelegate test = () => sut.PlayCard(user2, 1, 1, card);

            // Assert.
            Assert.That(test, Throws.InvalidOperationException);
        }
开发者ID:jbfp,项目名称:Sequence_old,代码行数:23,代码来源:GameTests.cs

示例6: PlayCard_throws_InvalidOperationException_when_card_does_not_match_tile

        public void PlayCard_throws_InvalidOperationException_when_card_does_not_match_tile()
        {
            // Arrange.
            const int seed = 42;
            const int row = 1;
            const int column = 1;
            var userId = Guid.NewGuid();
            var card = new Card(Suit.Hearts, Rank.King);
            var sut = new Game().Initialize(Guid.NewGuid(), 2)
                                .AddUser(Guid.NewGuid())
                                .AddUser(userId)
                                .Start(seed);

            // Act.
            TestDelegate test = () => sut.PlayCard(userId, row, column, card);

            // Assert.
            Assert.That(GameBoard.GetCard(row, column), Is.Not.EqualTo(card));
            Assert.That(test, Throws.InvalidOperationException.With.Message.EqualTo("Card does not match tile."));
        }
开发者ID:jbfp,项目名称:Sequence_old,代码行数:20,代码来源:GameTests.cs

示例7: PlayCard_throws_ArgumentNullException_when_card_is_null

        public void PlayCard_throws_ArgumentNullException_when_card_is_null()
        {
            // Arrange.
            var userId = Guid.NewGuid();
            var sut = new Game().Initialize(Guid.NewGuid(), 2)
                                .AddUser(Guid.NewGuid())
                                .AddUser(userId)
                                .Start();

            // Act.
            TestDelegate test = () => sut.PlayCard(userId, 1, 1, null);

            // Assert.
            Assert.That(test, Throws.TypeOf<ArgumentNullException>());
        }
开发者ID:jbfp,项目名称:Sequence_old,代码行数:15,代码来源:GameTests.cs


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