Esempio n. 1
0
        public void StartGame_NotEnoughPlayers_ThrowsException()
        {
            Guid sessionKey = Guid.NewGuid();
            var basicPlayer = new PlayerEntity() { Name = "Hello" };
            var fakeContext = LogicalHelpers.GetSimpleSessionContext(new Session()
            {
                Key = sessionKey,
                Players = new List<PlayerEntity>(),
            });

            GameSetupLayer layer = new GameSetupLayer(fakeContext.Object);

            layer.StartGame(sessionKey);
        }
Esempio n. 2
0
        public void StartGame_AlreadyStartedGame_StartsGame()
        {
            Guid sessionKey = Guid.NewGuid();
            var session = new Session()
            {
                StartDate = DateTime.Now,
                Key = sessionKey,
                ExpirationDate = DateTime.Now,
            };

            var fakeContext = LogicalHelpers.GetSimpleSessionContext(session);
            LogicalHelpers.AttachPlayer(session, new PlayerEntity());
            LogicalHelpers.AttachPlayer(session, new PlayerEntity());
            GameSetupLayer layer = new GameSetupLayer(fakeContext.Object);
            layer.StartGame(sessionKey);
        }
Esempio n. 3
0
        public void StartGame_ExpiredGame_ThrowsException()
        {
            Guid sessionKey = Guid.NewGuid();
            var session = new Session()
            {
                Key = sessionKey,
                ExpirationDate = DateTime.Now.AddMilliseconds(-1),
            };

            var fakeContext = LogicalHelpers.GetSimpleSessionContext(session);
            LogicalHelpers.AttachPlayer(session, new PlayerEntity());
            LogicalHelpers.AttachPlayer(session, new PlayerEntity());
            GameSetupLayer layer = new GameSetupLayer(fakeContext.Object);
            layer.StartGame(sessionKey);
        }
Esempio n. 4
0
        public void StartGame_AllRequirements_StartsGame()
        {
            Guid sessionKey = Guid.NewGuid();
            var session = new Session()
            {
                Key = sessionKey,
                ExpirationDate = DateTime.MaxValue,
            };

            var fakeContext = LogicalHelpers.GetSimpleSessionContext(session);
            LogicalHelpers.AttachPlayer(session, new PlayerEntity());
            LogicalHelpers.AttachPlayer(session, new PlayerEntity());
            LogicalHelpers.AttachPlayer(session, new PlayerEntity());
            GameSetupLayer layer = new GameSetupLayer(fakeContext.Object);
            layer.StartGame(sessionKey);

            Assert.AreEqual(1, session.RoundNumber);
            Assert.AreEqual(1, session.SetNumber);
            Assert.IsNotNull(session.StartDate);
            Assert.IsFalse(session.CanStartGame);
            Assert.IsNotNull(session.CurrentPlayer);
            Assert.IsNotNull(session.CurrentPlayerId);

            fakeContext.Verify(x => x.SaveChanges(), Times.Once());
            Assert.AreEqual(52, session.PlayerSesssionHands.SelectMany(x => x.CurrentCards).Distinct().Count());
        }