Exemple #1
0
        public void SetUp()
        {
            //Arrange
            var booksOffer1 = new List <BookStoreBook>
            {
                new BookStoreBook {
                    Book = new Book {
                        Genre = BookGenre.Drama
                    }
                },
                new BookStoreBook {
                    Book = new Book {
                        Genre = BookGenre.Drama
                    }
                },
                new BookStoreBook {
                    Book = new Book {
                        Genre = BookGenre.Bio
                    }
                }
            };

            var booksOffer3 = new List <BookStoreBook>
            {
                new BookStoreBook {
                    Book = new Book {
                        Genre = BookGenre.CrimeStory
                    }
                },
                new BookStoreBook {
                    Book = new Book {
                        Genre = BookGenre.CrimeStory
                    }
                },
                new BookStoreBook {
                    Book = new Book {
                        Genre = BookGenre.CrimeStory
                    }
                }
            };

            _bookStoreServiceMock = new Mock <IBookStoreService>();

            _bookStoreServiceMock
            .Setup(x => x.GetAllBookStoresIds())
            .Returns(new List <int>()
            {
                1, 3
            });

            _bookStoreServiceMock
            .Setup(x => x.GetOffer(1))
            .Returns(booksOffer1);

            _bookStoreServiceMock
            .Setup(x => x.GetOffer(3))
            .Returns(booksOffer3);

            _sut = new StatisticsProvider(_bookStoreServiceMock.Object);
        }
        public void Should_get_character_statistics()
        {
            var provider = new StatisticsProvider();

            var result = provider.GetCharacterStatistics("char_info.php?s=23&char_id=2336");

            Assert.IsTrue(result.IsSuccess);
        }
        public void Should_get_total_statistics()
        {
            var provider = new StatisticsProvider();

            var result = provider.GetTotalStatistics();

            Assert.IsTrue(result.IsSuccess);
        }
Exemple #4
0
        /// <summary>
        /// Post推荐统计分页列表
        /// </summary>
        /// <param name="recommendQuery"></param>
        /// <returns></returns>
        public ActionResult PostRecommendStatistical(RecommendQuery recommendQuery)
        {
            //var criteria=new
            StatisticsProvider statisticsProvider = new StatisticsProvider();
            var pagelist = statisticsProvider.GetRecommendList(recommendQuery);

            return(PartialView("PostRecommendStatistical", pagelist));
            //return View();
        }
Exemple #5
0
        /// <summary>
        /// 推荐统计页面
        /// </summary>
        /// <returns></returns>
        public ActionResult RecommendStatistical()
        {
            RecommendQuery recommendQuery = new RecommendQuery();

            recommendQuery.PageIndex = 1;
            StatisticsProvider statisticsProvider = new StatisticsProvider();
            var pagelist = statisticsProvider.GetRecommendList(recommendQuery);

            return(View(pagelist));
        }
Exemple #6
0
        /// ------------------------------------------------------------------------------------
        public virtual string GetStringValue(string key, string defaultValue)
        {
            string computedValue = null;

            var computedFieldInfo =
                FileType.GetComputedFields().FirstOrDefault(computedField => computedField.Key == key);

            if (computedFieldInfo != null && StatisticsProvider != null)
            {
                var mediaFileInfo = StatisticsProvider.GetFileData(PathToAnnotatedFile);
                if (mediaFileInfo != null)
                {
                    if (mediaFileInfo.Audio == null &&
                        PathToAnnotatedFile.EndsWith(Settings.Default.OralAnnotationGeneratedFileSuffix))
                    {
                        return("Not Generated");
                    }
                    // Get the computed value (if there is one).
                    computedValue = computedFieldInfo.GetFormatedStatProvider(
                        mediaFileInfo, computedFieldInfo.DataItemChooser, computedFieldInfo.Suffix);
                }
            }

            // Get the value from the metadata file.
            var field      = MetaDataFieldValues.FirstOrDefault(v => v.FieldId == key);
            var savedValue = (field == null ? defaultValue : field.ValueAsString);

            if (!string.IsNullOrEmpty(computedValue))
            {
                // If the computed value is different from the value found in the metadata
                // file, then save the computed value to the metadata file.
                if (computedValue != savedValue)
                {
                    // REVIEW: We probably don't want to save the formatted value to the
                    // metadata file, which is what we're doing here. In the future we'll
                    // probably want to change things to save the raw computed value.
                    SetStringValue(key, computedValue);
                    Save();
                    return(computedValue);
                }
            }

            return(savedValue);
        }
Exemple #7
0
 public StatisticsController(StatisticsProvider statisticsProvider, ESUContext context)
 {
     this.statisticsProvider = statisticsProvider;
     this.context            = context;
 }