public Tests() { var serviceCollection = new ServiceCollection(); serviceCollection.AddScoped <IScoreBoardService, ScoreBoardService>(); _scoreBoardService = serviceCollection.BuildServiceProvider().GetService <IScoreBoardService>(); }
public WpfEngine( IScoreBoardService scoreBoardService, IRenderer renderer, IPlayer player, IWordGenerator wordGenerator, ICommandFactory commandFactory) : base(scoreBoardService, renderer, player, wordGenerator, commandFactory) { }
public ConsoleEngine( IScoreBoardService scoreBoardService, IRenderer renderer, IPlayer player, IWordGenerator wordGenerator, ICommandFactory commandFactory, IInputProvider inputProvider) : base(scoreBoardService, renderer, player, wordGenerator, commandFactory) { this.InputProvider = inputProvider; }
public void Initialize() { List <Game> games = new List <Game>(); games.Add(new Game { Id = 1, HomeTeam = new TeamGame { Team = new Team { TeamName = "Spain" }, Score = 0 }, AwayTeam = new TeamGame { Team = new Team { TeamName = "Netherlands" }, Score = 0 }, StartDate = DateTime.Now }); games.Add(new Game { Id = 2, HomeTeam = new TeamGame { Team = new Team { TeamName = "Brazil" }, Score = 0 }, AwayTeam = new TeamGame { Team = new Team { TeamName = "Germany" }, Score = 0 }, StartDate = DateTime.Now }); games.Add(new Game { Id = 3, HomeTeam = new TeamGame { Team = new Team { TeamName = "Argentina" }, Score = 0 }, AwayTeam = new TeamGame { Team = new Team { TeamName = "Italy" }, Score = 0 }, StartDate = DateTime.Now }); _scoreBoard = new ScoreBoardService(games); }
/// <summary> /// Initializes a new instance of the <see cref="GameEngine"/> class. /// </summary> /// <param name="scoreBoardService">Instance of IScoreBoardService</param> /// <param name="renderer">Instance of IRenderer</param> /// <param name="player">Instance of IPlayer</param> /// <param name="wordGenerator">Instance of IWordGenerator</param> /// <param name="commandFactory">Instance of ICommandFactory</param> protected GameEngine( IScoreBoardService scoreBoardService, IRenderer renderer, IPlayer player, IWordGenerator wordGenerator, ICommandFactory commandFactory) { this.ScoreBoardService = scoreBoardService; this.Renderer = renderer; this.Player = player; this.WordGenerator = wordGenerator; this.CommandFactory = commandFactory; }
/// <summary> /// Reads the result from the database and restores them as a C# objects. /// </summary> /// <param name="scoreBoardService"> /// The current ScoreBoardService. /// </param> /// <param name="filePath"> /// The path to the file, which acts as a database. /// </param> public override void RestoreResults(IScoreBoardService scoreBoardService, string filePath) { IList<string> allResults = this.ReadAllResults(filePath); IList<IPersonalScore> restoredResults = new List<IPersonalScore>(); foreach (var result in allResults) { string[] record = result.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); string name = record[0]; int score = int.Parse(record[1]); IPersonalScore newRecord = new PersonalScore(name, score); restoredResults.Add(newRecord); } scoreBoardService.RestoreScores(restoredResults); }
public ScoreBoardController(IHubContext <ScoreBoardHub> hub, IScoreBoardService scoreBoardService) { _hub = hub; _scoreBoardService = scoreBoardService; }
public async Task ExcuteAsync(CancellationToken stoppingToken, IHubContext <ScoreBoardHub> hub, IScoreBoardService scoreBoardService) { while (!stoppingToken.IsCancellationRequested) { executionCount++; var scores = await scoreBoardService.GetScoreAsync(); List <ScoreViewModel> model = new List <ScoreViewModel>(); foreach (var item in scores) { var temp = new ScoreViewModel { Name = item.Name, Point = item.Point, SignalStamp = Guid.NewGuid().ToString() }; model.Add(temp); } await hub.Clients.All.SendAsync("SignalMessageRecieved", model); await Task.Delay(10000, stoppingToken); } }
/// <summary> /// Reads the result from the database and restores them as a C# objects. /// </summary> /// <param name="scoreBoardService"> /// The current ScoreBoardService. /// </param> /// <param name="filePath"> /// The path to the file, which acts as a database. /// </param> public abstract void RestoreResults(IScoreBoardService scoreBoardService, string filePath);