예제 #1
0
        public void InvokeIPartialCircleSvgPathProvider_GetSvgPathMethodAsManyTimesAsAvailableOutputPerSecondViewModels()
        {
            // Arrange
            var outputPerSecondViewModelDataProvider = new Mock <IOutputPerSecondViewModelDataProvider>();
            var partialCircleSvgPathProvider         = new Mock <IPartialCircleSvgPathProvider>();
            var leaderboardViewModelFactory          = new Mock <ILeaderboardViewModelFactory>();

            var leaderboardService = new LeaderboardService(outputPerSecondViewModelDataProvider.Object, partialCircleSvgPathProvider.Object, leaderboardViewModelFactory.Object);

            var outputPerSecondViewModels = new List <OutputPerSecondViewModel>()
            {
                new OutputPerSecondViewModel(),
                new OutputPerSecondViewModel(),
                new OutputPerSecondViewModel(),
                new OutputPerSecondViewModel(),
                new OutputPerSecondViewModel(),
            };

            outputPerSecondViewModelDataProvider.Setup(p => p.GetTopHealingOnPageInDescendingOrder(It.IsAny <int>(), It.IsAny <int>())).Returns(outputPerSecondViewModels);

            var pageNumber = 0;

            var expectedInvocationsCount = outputPerSecondViewModels.Count;

            // Act
            leaderboardService.GetTopHealingOnPage(pageNumber);

            // Assert
            partialCircleSvgPathProvider.Verify(p => p.GetSvgPath(It.IsAny <int>(), 75, 300), Times.Exactly(expectedInvocationsCount));
        }
예제 #2
0
 public System(CommandService commandService, ListService systemService, CooldownService cooldownService, LeaderboardService lbService)
 {
     _commandService  = commandService;
     _systemService   = systemService;
     _cooldownService = cooldownService;
     _lbService       = lbService;
 }
예제 #3
0
        private void SceneCreated(Scene scene)
        {
            var pluginName = scene.GetHostMetadata("stormancer.leaderboard");

            if (!string.IsNullOrEmpty(pluginName))
            {
                var leaderboardService = new LeaderboardService(scene);
                scene.DependencyResolver.RegisterComponent(leaderboardService);
            }
        }
예제 #4
0
        public void CreateCorrectInstance_WhenParametersAreValid()
        {
            // Arrange
            var outputPerSecondViewModelDataProvider = new Mock <IOutputPerSecondViewModelDataProvider>();
            var partialCircleSvgPathProvider         = new Mock <IPartialCircleSvgPathProvider>();
            var leaderboardViewModelFactory          = new Mock <ILeaderboardViewModelFactory>();

            // Act
            var actualInstance = new LeaderboardService(outputPerSecondViewModelDataProvider.Object, partialCircleSvgPathProvider.Object, leaderboardViewModelFactory.Object);

            // Assert
            Assert.That(actualInstance, Is.Not.Null);
            Assert.That(actualInstance, Is.InstanceOf <ILeaderboardService>());
        }
예제 #5
0
        private StatsManager()
        {
            this.userDocumentMap = new Dictionary <string, StatsValueDocument>();
            this.eventList       = new List <StatEvent>();

            this.statTimer            = new CallBufferTimer <XboxLiveUser>(TimePerCall);
            this.statTimer.Completed += this.TimerCompleteCallback;

            this.statPriorityTimer            = new CallBufferTimer <XboxLiveUser>(TimePerCall);
            this.statPriorityTimer.Completed += this.TimerCompleteCallback;

            this.statsService       = new StatsService();
            this.leaderboardService = new LeaderboardService();

            RunFlushTimer();
        }
예제 #6
0
        public void InvokeIOutputPerSecondViewModelDataProvider_GetTopHealingOnPageInDescendingOrderAsManyTimesAsRequestedPages(int pageNumber)
        {
            // Arrange
            var outputPerSecondViewModelDataProvider = new Mock <IOutputPerSecondViewModelDataProvider>();
            var partialCircleSvgPathProvider         = new Mock <IPartialCircleSvgPathProvider>();
            var leaderboardViewModelFactory          = new Mock <ILeaderboardViewModelFactory>();

            var leaderboardService = new LeaderboardService(outputPerSecondViewModelDataProvider.Object, partialCircleSvgPathProvider.Object, leaderboardViewModelFactory.Object);

            var outputPerSecondViewModels = new List <OutputPerSecondViewModel>();

            outputPerSecondViewModelDataProvider.Setup(p => p.GetTopHealingOnPageInDescendingOrder(It.IsAny <int>(), It.IsAny <int>())).Returns(outputPerSecondViewModels);

            // Act
            leaderboardService.GetTopHealingOnPage(pageNumber);

            // Assert
            outputPerSecondViewModelDataProvider.Verify(p => p.GetTopHealingOnPageInDescendingOrder(It.IsAny <int>(), It.IsAny <int>()), Times.Exactly(pageNumber + 1));
        }
예제 #7
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity   = await result as IMessageActivity;
            var playerName = Utils.SanitizeText(activity.Text);

            if (await LeaderboardService.IsNewPlayer(playerName))
            {
                context.ConversationData.SetValue(Constants.PLAYER_NAME_KEY, playerName);
                await context.PostAsync($"Let's play and earn some coins!");

                await context.Forward(new WhoIsDialog(), AfterWhoIsDialog, activity);
            }
            else
            {
                await context.PostAsync("This address has already been used.");

                context.Wait(MessageReceivedAsync);
            }
        }
예제 #8
0
        private async Task AfterWhoIsDialog(IDialogContext context, IAwaitable <double> result)
        {
            var score      = await result;
            var playerName = context.ConversationData.GetValue <string>(Constants.PLAYER_NAME_KEY);

            await LeaderboardService.SaveScoreAsync(playerName, score);

            await context.PostAsync($"💯 You are done! Your final score is: **{score}**.");

            await Utils.SendEventAsync(context, Constants.END_GAME_EVENT, score);

            // cleanup
            context.ConversationData.RemoveValue(Constants.LAST_PERSON_KEY);
            context.ConversationData.RemoveValue(Constants.RECENT_PEOPLE_KEY);
            context.ConversationData.RemoveValue(Constants.PLAYER_NAME_KEY);
            context.ConversationData.RemoveValue(Constants.SCORE_KEY);

            context.Done(true);
        }
        private void generateLeaderboard()
        {
            var heros       = LeaderboardService.GenerateLeaderboard();
            var leaderboard = "<table class='table table-striped'>";

            leaderboard += "<tr><th>Place</th><th>Credits</th><th>Hero</th></tr>";
            var rank = 0;

            foreach (var hero in heros)
            {
                rank++;
                leaderboard += string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>",
                                             rank,
                                             hero.Credits,
                                             hero.Name);
            }
            leaderboard            += "</table>";
            leaderboardLiteral.Text = leaderboard;
        }
예제 #10
0
        public void InvokeILeaderboardViewModelFactory_CreateLeaderboardViewModelMethodOnce()
        {
            // Arrange
            var outputPerSecondViewModelDataProvider = new Mock <IOutputPerSecondViewModelDataProvider>();
            var partialCircleSvgPathProvider         = new Mock <IPartialCircleSvgPathProvider>();
            var leaderboardViewModelFactory          = new Mock <ILeaderboardViewModelFactory>();

            var leaderboardService = new LeaderboardService(outputPerSecondViewModelDataProvider.Object, partialCircleSvgPathProvider.Object, leaderboardViewModelFactory.Object);

            var outputPerSecondViewModels = new List <OutputPerSecondViewModel>();

            outputPerSecondViewModelDataProvider.Setup(p => p.GetTopHealingOnPageInDescendingOrder(It.IsAny <int>(), It.IsAny <int>())).Returns(outputPerSecondViewModels);

            var pageNumber = 1;

            // Act
            leaderboardService.GetTopHealingOnPage(pageNumber);

            // Assert
            leaderboardViewModelFactory.Verify(f => f.CreateLeaderboardViewModel(It.IsAny <int>(), It.IsAny <IList <OutputPerSecondViewModel> >()), Times.Once);
        }
예제 #11
0
 public void Save()
 {
     LeaderboardService.SavePlayer(Player);
 }
예제 #12
0
 public LeaderboardController(AccountService accountService, CategoryService categoryService, LeaderboardService leaderboardService)
     : base(accountService, categoryService)
 {
     _leaderboardService = leaderboardService;
 }
 public LeaderboardModel(SqlManager sql)
 {
     sqlManager  = sql;
     leaderboard = new LeaderboardService(sql);
 }
예제 #14
0
 public AdminController(AccountService accountService, CategoryService categoryService, LeaderboardService leaderboardService, WebContentService webContentService)
     : base(accountService, categoryService)
 {
     _leaderboardService = leaderboardService;
     _webContentService  = webContentService;
 }
예제 #15
0
 public IEnumerable <LeaderboardRow> GetLeaderboardForWeek(int week, int year)
 {
     return(LeaderboardService.GetLeaderboardForWeek(week, year).OrderBy(x => x.Rank));
 }
예제 #16
0
 public LeaderboardController()
 {
     _leaderboardService = new LeaderboardService(UserToken);
 }
예제 #17
0
 // DI via constructor
 public LeaderboardController(LeaderboardService service)
 {
     this._service = service;
 }
 public LeaderboardController()
 {
     _context            = new ApplicationDbContext();
     _leaderboardService = new LeaderboardService(_context);
 }
예제 #19
0
 public override void TestInitialize()
 {
     base.TestInitialize();
     MockXboxLiveData.Load(Environment.CurrentDirectory + "\\Leaderboards\\MockDataForLeaderboardTests.json");
     this.leaderboardService = new LeaderboardService();
 }
예제 #20
0
파일: Reputation.cs 프로젝트: Lunerr/FFA
 public Reputation(ReputationService repService, LeaderboardService lbService, IMongoCollection <User> dbUsers)
 {
     _repService = repService;
     _lbService  = lbService;
     _dbUsers    = dbUsers;
 }
예제 #21
0
 public LeaderboardController(LeaderboardService leaderboardService)
 {
     _leaderboardService = leaderboardService;
 }