Beispiel #1
0
        public void CallBullshit_BullshitEventInserted()
        {
            var sessionKey = Guid.NewGuid();
            var fakeSession = new Session()
            {
                Key = sessionKey,
                StartDate = DateTime.Now,
                RoundNumber = 1,
                SetNumber = 1,
            };
            var player1 = new PlayerEntity() { Key = Guid.NewGuid() };
            LogicalHelpers.AttachPlayer(fakeSession, player1);
            LogicalHelpers.SetCurrentPlayer(fakeSession, player1);

            Guid player2Key = Guid.NewGuid();
            var player2 = new PlayerEntity() { Key = player2Key };
            LogicalHelpers.AttachPlayer(fakeSession, player2);
            LogicalHelpers.PlayCardSet(fakeSession, player1, new PlayedSet() { });

            var fakeContext = LogicalHelpers.GetSimpleSessionContext(fakeSession);
            fakeContext.Setup(x => x.Get<PlayerEntity>()).Returns(new[] { player1, player2 }.AsQueryable());
            var layer = new PlayerDetailsLayer(fakeContext.Object, sessionKey, player2Key);

            layer.CallBullshit();

            fakeContext.Verify(x => x.Add<BullshitEvent>(It.Is<BullshitEvent>(y => y.CalledBy == player2)), Times.Once());
            fakeContext.Verify(x => x.SaveChanges(), Times.Once());
            Assert.AreEqual(player2, fakeSession.CurrentPlayer);
        }
Beispiel #2
0
        public void CallBullshit_NoPlayedSet_Fails()
        {
            var sessionKey = Guid.NewGuid();
            var fakeContext = new Mock<IBullshitContext>();

            var layer = new PlayerDetailsLayer(fakeContext.Object, sessionKey, Guid.Empty);
            layer.CallBullshit();
        }
Beispiel #3
0
        public void CallBullshit_FinishedGame_ThrowsException()
        {
            var sessionKey = Guid.NewGuid();
            var session = new Session()
            {
                Key = sessionKey,
                StartDate = DateTime.Now,
                FinishedDate = DateTime.Now,
            };

            Guid player1Key = Guid.NewGuid();
            PlayerEntity player1 = new PlayerEntity()
            {
                Key = player1Key,
            };

            LogicalHelpers.AttachPlayer(session, player1);
            var fakeContext = LogicalHelpers.GetSimpleSessionContext(session);
            var layer = new PlayerDetailsLayer(fakeContext.Object, sessionKey, player1Key);
            layer.CallBullshit();
        }