public void PlayCardSet_WaitingForBullshit_Fails() { var sessionKey = Guid.NewGuid(); var session = new Session() { Key = sessionKey, StartDate = DateTime.Now, }; var player1 = new PlayerEntity() { Key = Guid.NewGuid() }; LogicalHelpers.AttachPlayer(session, player1); var player2 = new PlayerEntity() { Key = Guid.NewGuid(), }; LogicalHelpers.AttachPlayer(session, player2); session.RoundNumber = 1; session.SetNumber = 1; LogicalHelpers.PlayCardSet(session, player1, new PlayedSet() { PresumedType = CardType.Club, PresumedTypeId = CardType.ClubId, PlayedHand = "H1", }); LogicalHelpers.AddBullshit(session, new BullshitEvent()); LogicalHelpers.SetCurrentPlayer(session, player2); var fakeContext = LogicalHelpers.GetSimpleSessionContext(session); var layer = new PlayerDetailsLayer(fakeContext.Object, sessionKey, player2.Key); layer.PlayCardSet(new PlayedSet() { PresumedType = CardType.Club, PresumedTypeId = CardType.ClubId, PlayedHand = "D1", }); }
public void PlayCardSet_CorrectPlayer_RemovesCardFromCurrentUser() { var sessionKey = Guid.NewGuid(); var session = new Session() { Id = 1, Key = sessionKey, StartDate = DateTime.Now, }; var player1 = new PlayerEntity() { Id = 1, Key = Guid.NewGuid() }; LogicalHelpers.AttachPlayer(session, player1); var player2 = new PlayerEntity() { Id = 2, Key = Guid.NewGuid(), }; LogicalHelpers.AttachPlayer(session, player2); session.RoundNumber = 1; session.SetNumber = 1; LogicalHelpers.PlayCardSet(session, player1, new PlayedSet() { PresumedType = CardType.Club, PresumedTypeId = CardType.ClubId, PlayedHand = "H1", }); LogicalHelpers.SetCurrentPlayer(session, player2); var fakeContext = LogicalHelpers.GetSimpleSessionContext(session); var layer = new PlayerDetailsLayer(fakeContext.Object, sessionKey, player2.Key); var playerHand = new PlayerSesssionHand { SessionId = session.Id, PlayerId = player2.Id, CurrentHand = "D1", }; fakeContext.Setup(x => x.Get<PlayerSesssionHand>()).Returns(new[] { playerHand }.AsQueryable()); fakeContext.Setup(x => x.Get<PlayerEntity>()).Returns(new[] { player1, player2 }.AsQueryable()); string playedHand = "D1"; var hand = new PlayedSet() { PlayedHand = playedHand, PresumedTypeId = CardType.ClubId, PresumedType = CardType.Club }; layer.PlayCardSet(hand); CollectionAssert.Contains((ICollection)session.PlayedSet, hand); fakeContext.Verify(x => x.SaveChanges(), Times.Once()); Assert.IsTrue(String.IsNullOrEmpty(playerHand.CurrentHand)); }