public void CheckOpenShouldStart() { // Arrange var mockUnitOfWork = TestUtils.GetUnitOfWorkMock(); var tournamentRepository = new MockTournamentRepository(); mockUnitOfWork.SetupGet(x => x.Tournaments).Returns(tournamentRepository); var unitOfWork = mockUnitOfWork.Object; var gameServiceMock = new Mock <IGameService>(); var service = new TournamentService(TestUtils.MockUserProvider(), unitOfWork, gameServiceMock.Object, TestUtils.MockMapTemplateProvider()); var openTournament = new Tournament( "Tournament", 8, 3, 3, 3, DateTime.UtcNow.AddDays(-1), DateTime.UtcNow, new Domain.Games.GameOptions { NumberOfPlayersPerTeam = 1 }); tournamentRepository.Add(openTournament); for (int i = 0; i < 8; ++i) { openTournament.AddUser(TestUtils.CreateUser($"User{i}")); } // Act var started = service.CheckOpenTournaments(new TestLogger(), new RandomGen()); // Assert Assert.IsTrue(started); Assert.AreEqual(TournamentState.Groups, openTournament.State); Assert.AreEqual(12, openTournament.Pairings.Count()); }
public void CheckOpenShouldStart() { // Arrange var mockUnitOfWork = TestUtils.GetUnitOfWorkMock(); var tournamentRepository = new MockTournamentRepository(); mockUnitOfWork.SetupGet(x => x.Tournaments).Returns(tournamentRepository); var unitOfWork = mockUnitOfWork.Object; var gameServiceMock = new Mock<IGameService>(); var service = new TournamentService(unitOfWork, gameServiceMock.Object, TestUtils.MockMapTemplateProvider()); var openTournament = new Tournament( "Tournament", 8, 3, 3, 3, DateTime.UtcNow.AddDays(-1), DateTime.UtcNow, new Domain.Games.GameOptions { NumberOfPlayersPerTeam = 1 }); tournamentRepository.Add(openTournament); for (int i = 0; i < 8; ++i) { openTournament.AddUser(TestUtils.CreateUser($"User{i}")); } // Act var started = service.CheckOpenTournaments(); // Assert Assert.IsTrue(started); Assert.AreEqual(TournamentState.Groups, openTournament.State); Assert.AreEqual(12, openTournament.Pairings.Count()); }