public JoinMatchCommandHandler( AppDbContext ctx, MatchDoorman matchDoorman, INotificationQueue notification) { _ctx = ctx; _matchDoorman = matchDoorman; _notification = notification; }
public void ThrowsCantJoinMatchException_WhenTryingToJoinYourOwnMatch() { var settings = MatchMockCreator.CreateSettings(); settings.Host = _host; var match = settings.CreateMatch(); var manager = new MatchDoorman(_opponentCheckerMock.Object); Assert.Throws <CantJoinMatchException>(() => { manager.AddOpponent(match, _host); }); }
public void ThrowsCantJoinMatchException_WhenAlreadyBattlingOpponent() { var settings = MatchMockCreator.CreateSettings(); settings.Host = _host; var match = settings.CreateMatch(); var checker = OpponentCheckerMock.Create(_host.Id, _opponent.Id, true); var manager = new MatchDoorman(checker.Object); Assert.Throws <CantJoinMatchException>(() => { manager.AddOpponent(match, _opponent); }); }
public void ThrowsCantJoinMatchException_WhenJoinLimitReached() { var settings = MatchMockCreator.CreateSettings(); settings.Host = _host; var match = settings.CreateMatch(); var manager = new MatchDoorman(_opponentCheckerMock.Object); _opponent.Joined = 1; Assert.Throws <CantJoinMatchException>(() => { manager.AddOpponent(match, _opponent); }); }
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); }
public JoinMatchCommandHandler( AppDbContext ctx, MatchDoorman matchDoorman, INotificationQueue notification, ITranslator translator) { _ctx = ctx; _matchDoorman = matchDoorman; _notification = notification; _translator = translator; }
public void UserCanJoinMatch_WithRoleOpponent() { var settings = MatchMockCreator.CreateSettings(); settings.Host = _host; var match = settings.CreateMatch(); var manager = new MatchDoorman(_opponentCheckerMock.Object); manager.AddOpponent(match, _opponent); Assert.Contains(match.MatchUsers, x => x.UserId == _opponent.Id && x.Role == MatchRole.Opponent); }
public void InformationAsExpected_WhenModeIsCopyCat() { var settings = MatchMockCreator.CreateSettings(Mode.CopyCat); settings.Host = _host; 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.False(match.GetOpponent().CanGo); Assert.Equal(_host.DisplayName, match.Turn); }
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); }
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)); } }