예제 #1
0
        private Statistic GetStatistic(_Command command)
        {
            var pathCommand     = $"{command.ExecutedCommand} {command.Args}";
            var commits         = powerShellExecutor.Execute(pathCommand, statsCommand);
            var statisticParser = new StatisticParser(commits);

            return(statisticParser.Parse());
        }
예제 #2
0
        public async Task ExecuteAsync(ImageEntity imageEntity, ImageContext context, CancellationToken ct)
        {
            var request = new ImageByUrlRequest(context.User.Cookies, context.CurrentImageUrl);
            var parser  = new StatisticParser();

            var response =
                await Gate.SendAsync <ImageByUrlRequest, StatisticModel, StatisticParser>(request, parser);

            await _repository.AddOrUpdateAsync(CreateStatistic(response, imageEntity.Id), ct);
        }
예제 #3
0
        public void StatisticParser(string page)
        {
            //Arrange
            const int expectedViews     = 106;
            const int expectedComments  = 0;
            const int expectedFavorites = 7;
            var       parser            = new StatisticParser();
            var       text = File.ReadAllText(page);

            //Act
            var actual = parser.Parse(text);

            //Assert
            Assert.Equal(expectedViews, actual.Views);
            Assert.Equal(expectedComments, actual.Comments);
            Assert.Equal(expectedFavorites, actual.Favorites);
        }