public static void ReadingFromEmptyStore(IScoreStore store)
        {
            var tasks = new List <Task <IEnumerable <LeaderboardEntry> > >()
            {
                Task.Run(() => store.GetLeaderboardAsync(GameTypes.TicTacToe, Scopes.AllTime)),
                Task.Run(() => store.GetLeaderboardAsync(GameTypes.TicTacToe, Scopes.Weekly)),
                Task.Run(() => store.GetLeaderboardAsync(GameTypes.TicTacToe, Scopes.Daily))
            };

            Task.WaitAll(tasks.ToArray());

            Assert.IsFalse(tasks[0].Result.Any() || tasks[1].Result.Any() || tasks[2].Result.Any());
        }
        public static void GetAllTimeLeaders(IScoreStore store)
        {
            var entries = Mocks.Older.Concat(Mocks.Today).Concat(Mocks.Yesterday);

            foreach (var mock in entries)
            {
                Task.Run(() => store.AddLeaderboardEntryAsync(mock)).Wait();
            }

            var leaders = Task.Run(() => store.GetLeaderboardAsync(GameTypes.TicTacToe, Scopes.AllTime));

            leaders.Wait();
            Assert.IsTrue(leaders.Result.ToList().SequenceEqual(entries.ToList().OrderByDescending(l => l.Score), new LeaderboardEntryCsvComparer()));
        }
Example #3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            using (var container = new UnityContainer().LoadConfiguration())
            {
                this._store = container.Resolve <IScoreStore>();
            }

            _viewmodel = new CoreViewModel();
            _window    = new MainWindow();

            _viewmodel.LaunchGame     += LaunchNewGame;
            _viewmodel.showScoreEvent += showScore;

            _window.DataContext = _viewmodel;
            _window.Show();
        }
Example #4
0
 public ScoreList(IScoreStore <T> store) =>
 (_store, _scores) = (store, store.LoadScores());
Example #5
0
 public void GetDailyLeadersFromFileStore()
 {
     _store = new FileScoreStore(_filePath);
     StoreTestMethods.GetDailyLeaders(_store);
 }
Example #6
0
 public void ReadingFromEmptyFileStore()
 {
     _store = new FileScoreStore(_filePath);
     StoreTestMethods.ReadingFromEmptyStore(_store);
 }
 public void GetDailyLeadersFromMemoryStore()
 {
     _store = new MemoryScoreStore();
     StoreTestMethods.GetDailyLeaders(_store);
 }
 public void ReadingFromEmptyMemoryStore()
 {
     _store = new MemoryScoreStore();
     StoreTestMethods.ReadingFromEmptyStore(_store);
 }
Example #9
0
 public ScoresController(IGameManager gameManager, IScoreStore scoreStore, ILoggerFactory loggerFactory)
 {
     _logger      = loggerFactory.CreateLogger <ScoresController>();
     _gameManager = gameManager;
     _scoreStore  = scoreStore;
 }
Example #10
0
 public StateLogic(IScoreStore <PlayerScore> scoreStore)
 {
     _level.Reset();
     _scoreList = new ScoreList <PlayerScore>(scoreStore);
 }
Example #11
0
 /*
  *      boardSize.X is the number of columns on the Tetris board and boardSize.Y is the row count.
  *
  *      The score store is responsible for loading and saving player scores between instances/sessions.
  *      The library provides the implementation PlayerScoreFile, but it's a possible customization point.
  *      Some front end might want to store the player score in a database on the internet and thus use another score store.
  */
 public TetrisGame(Vec2i boardSize, IScoreStore <PlayerScore> scoreStore)
 {
     _stateLogic = new StateLogic(scoreStore);
     _boardLogic = new BoardLogic(boardSize, _stateLogic);
 }
Example #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LeaderboardsController"/> class.
 /// </summary>
 /// <param name="store">Resolved store to be used.</param>
 public LeaderboardsController(IScoreStore store)
 {
     this._store = store;
 }
Example #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScoreDepedentClass"/> class.
 /// </summary>
 /// <param name="store">Resolved store object.</param>
 public ScoreDepedentClass(IScoreStore store)
 {
     this._store = store;
 }