예제 #1
0
        public Tests()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IScoreBoardService, ScoreBoardService>();
            _scoreBoardService = serviceCollection.BuildServiceProvider().GetService <IScoreBoardService>();
        }
예제 #2
0
 public WpfEngine(
     IScoreBoardService scoreBoardService, 
     IRenderer renderer, 
     IPlayer player, 
     IWordGenerator wordGenerator, 
     ICommandFactory commandFactory)
     : base(scoreBoardService, renderer, player, wordGenerator, commandFactory)
 {
 }
예제 #3
0
 public ConsoleEngine(
     IScoreBoardService scoreBoardService, 
     IRenderer renderer, 
     IPlayer player, 
     IWordGenerator wordGenerator, 
     ICommandFactory commandFactory, 
     IInputProvider inputProvider)
     : base(scoreBoardService, renderer, player, wordGenerator, commandFactory)
 {
     this.InputProvider = inputProvider;
 }
예제 #4
0
        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);
        }
예제 #5
0
 /// <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;
 }
예제 #6
0
        /// <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);
        }
예제 #7
0
 public ScoreBoardController(IHubContext <ScoreBoardHub> hub, IScoreBoardService scoreBoardService)
 {
     _hub = hub;
     _scoreBoardService = scoreBoardService;
 }
예제 #8
0
        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);
            }
        }
예제 #9
0
 /// <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);