コード例 #1
0
        public void CreatesOneUp_WhenModeSetToOneUp(Mode mode, TurnType type)
        {
            var match = MatchMockCreator.CreateSettingsWithHost(mode, type)
                        .CreateMatch();

            Assert.Equal(mode, match.Mode);
        }
コード例 #2
0
        public void ThrowsHostingLimitReachedException_WhenHostingLimitReached()
        {
            var settings = MatchMockCreator.CreateSettingsWithHost();

            settings.Host.Hosting = 1;
            Assert.Equal(settings.Host.Hosting, settings.Host.HostingLimit);
            Assert.Throws <HostingLimitReachedException>(() => settings.CreateMatch());
        }
コード例 #3
0
        public void Match_HasOnlyHostUserWithId_WhenCreated()
        {
            var match = MatchMockCreator.CreateSettingsWithHost()
                        .CreateMatch();

            Assert.True(match.MatchUsers.Count == 1);
            Assert.Contains(match.MatchUsers, x =>
                            x.Role == MatchRole.Host && !string.IsNullOrEmpty(x.UserId));
        }
コード例 #4
0
        public void CreatesMatch_WithSelectedSurface(Surface surface)
        {
            var settings = MatchMockCreator.CreateSettingsWithHost();

            settings.Surface = surface;
            var match = settings.CreateMatch();

            Assert.Equal(surface, match.Surface);
        }
コード例 #5
0
        public void UserJoinCountIncremented_WhenJoinedMatch()
        {
            Assert.True(_opponent.Joined == 0);

            var settings = MatchMockCreator.CreateSettingsWithHost();
            var match    = settings.CreateMatch();
            var manager  = new MatchDoorman(_opponentCheckerMock.Object);

            manager.AddOpponent(match, _opponent);
            Assert.Equal(1, _opponent.Joined);
        }
コード例 #6
0
        public void InformationAsExpected_WhenModeIsThreeRoundPass_AndTurnTypeIsBlitz()
        {
            var settings = MatchMockCreator.CreateSettingsWithHost(Mode.ThreeRoundPass);

            settings.TurnType = TurnType.Blitz;
            var match   = settings.CreateMatch();
            var manager = new MatchDoorman(_opponentCheckerMock.Object);

            manager.AddOpponent(match, _opponent);

            Assert.Equal(Status.Active, match.Status);
            Assert.True(match.GetHost().CanGo);
            Assert.True(match.GetOpponent().CanGo);
            Assert.Equal("", match.Turn);
        }
コード例 #7
0
        public void ThrowsCantJoinMatchException_WhenMatchNotOpenOrInvitation()
        {
            var settings = MatchMockCreator.CreateSettingsWithHost();
            var match    = settings.CreateMatch();

            var failMatchStates = new[]
            {
                Status.Active,
                Status.Closed,
                Status.Complete,
                Status.Pending,
            };

            foreach (var status in failMatchStates)
            {
                match.Status = status;
                var doorman = new MatchDoorman(_opponentCheckerMock.Object);
                Assert.Throws <CantJoinMatchException>(() => doorman.AddOpponent(match, _opponent));
            }
        }