public void SetGifts_OneNonAvailablePath33() { Service = new GiftsService(Maze.Object, Player.Object); List <Path> listPath = new List <Path> { new Path(1, 1), new Path(2, 1), new Path(3, 1), new Path(1, 2), new Path(1, 3), new Path(3, 3)/// }; Maze.SetupGet(x => x.Paths).Returns(listPath); GameCore.EnumsAndConstant.GameConstants.PacmanRespointRow = 1; GameCore.EnumsAndConstant.GameConstants.PacmanRespointCell = 1; Service.SetGifts(); int countAvailablePath = 0; foreach (var p in Maze.Object.Paths) { if ((p.Row == 3) & (p.Cell == 3)) { Assert.IsTrue(p.HaveGift == false); } else { countAvailablePath++; Assert.IsTrue(p.HaveGift); } } Assert.IsTrue(Service.GiftsCount == countAvailablePath); }
public void GiftsService_MazeNull_ArgumentNullException() { IMaze maze = null; try { Service = new GiftsService(maze, Player.Object); } catch (ArgumentNullException ex) { Assert.AreEqual("Maze", ex.ParamName); } }
public void EnemyService_TimeServiceNull_ArgumentNullException() { IPlayer player = null; try { Service = new GiftsService(Maze.Object, player); } catch (ArgumentNullException ex) { Assert.AreEqual("Player", ex.ParamName); } }
public void Inject() { Log.Information("ChatManager initializing"); this.config = DI.Get <Configuration>(); this.nameValidator = DI.Get <NameValidator>(); this.userRoomService = DI.Get <UserRoomService>(); this.giftService = DI.Get <GiftsService>(); this.dispatcher = DI.Get <EventDispatcher>(); this.services = new IDIService[] { this.userRoomService, this.giftService, DI.Get <ChatActionsAuthenticator>(), DI.Get <ServerPromptService>(), DI.Get <GroupService>(), DI.Get <LobbyService>(), DI.Get <LoginService>(), DI.Get <CharacterService>(), }; this.nameValidator.ServerName = this.Monogram; this.World = new World(); Log.Information("Loading permanent rooms ({count} total)", this.config.PermanentRooms.Count); this.userRoomService.LoadPermanentRooms(); CIOReactor.Spawn("playerTimeoutWatchdog", () => { while (true) { Thread.Sleep(TimeSpan.FromSeconds(this.config.PlayerInactivityTimeout)); lock (this) { Log.Verbose("Checking players timeouts"); try { var players = this.World.Players.ToArray(); foreach (var handle in players) { this.CheckPlayerTimedOut(handle); } } catch (Exception e) { Log.Error("Caught exception in playerTimeoutWatchdog: {ex}", e); } } } }); CIOReactor.Spawn("excelRecordsWatchdog", () => { Log.Debug("Cleaning up expel records"); while (true) { #if !DEBUG var duration = TimeSpan.FromMinutes(10); #else var duration = TimeSpan.FromSeconds(30); #endif Thread.Sleep(duration); try { this.userRoomService.CleanupExpelRecords(); } catch (Exception e) { Log.Error("Caught exception in excelRecordsWatchdog: {ex}", e); } } }); CIOReactor.Spawn("danglingRoomWatchdog", () => { while (true) { #if !DEBUG var duration = TimeSpan.FromMinutes(3); #else var duration = TimeSpan.FromSeconds(30); #endif Thread.Sleep(duration); if (!this.config.DanglingRoom.Enabled) { continue; } Log.Debug("Cleaning up dangling rooms"); try { this.userRoomService.CleanupDanglingRooms(); } catch (Exception e) { Log.Error("Caught exception in danglingRoomWatchdog: {ex}", e); } } }); }