public async Task <GeneralStatistic> GetByUserId(Guid userId)
        {
            var completedEnglishMultimedias = await _completedEnglishMultimediaRepository.FindAllByUserId(userId);

            var completedEnglishTasks = await _completedEnglishTaskRepository.FindAllByUserId(userId);

            var domainMultimedias = _mapper.Map <IReadOnlyList <CompletedEnglishMultimedia> >(completedEnglishMultimedias);
            var domainTasks       = _mapper.Map <IReadOnlyList <CompletedEnglishTask> >(completedEnglishTasks);

            var generalStatistic = new GeneralStatistic(domainMultimedias, domainTasks);

            return(generalStatistic);
        }
Exemplo n.º 2
0
        public void GetPerDayForLastMonthStatistic_ReturnExpectedResult(
            IReadOnlyList <CompletedEnglishMultimedia> allMultimedia,
            IReadOnlyList <CompletedEnglishTask> allTasks,
            IReadOnlyList <PerDayStatistic> expectedModels)
        {
            // Arrange
            var generalStatistic = new GeneralStatistic(allMultimedia, allTasks);

            // Act
            IReadOnlyList <PerDayStatistic> perDayStatistics = generalStatistic.GetPerDayForLastMonthStatistic();

            // Arrange
            perDayStatistics.Should().BeEquivalentTo(expectedModels);
        }
Exemplo n.º 3
0
        public void GetAllCompleted_ReturnExpectedResult(
            IReadOnlyList <CompletedEnglishMultimedia> allMultimedia,
            IReadOnlyList <CompletedEnglishTask> allTasks,
            IReadOnlyList <GroupedCompletedStatistic> expectedModels)
        {
            // Arrange
            var generalStatistic = new GeneralStatistic(allMultimedia, allTasks);

            // Act
            IReadOnlyList <GroupedCompletedStatistic> groupedModels = generalStatistic.GetAllCompleted();

            // Arrange
            groupedModels.Should().BeEquivalentTo(expectedModels);
        }
        public static IEnumerable <object[]> GetFullStatistic_ReturnExpectedResult_Data()
        {
            var userId = Guid.NewGuid();
            var completedEnglishTask       = CompletedEnglishTaskFactory.GetSimpleModels(_random.Next(15, 25), userId);
            var completedEnglishMultimedia = CompletedEnglishMultimediaFactory.GetSimpleModels(_random.Next(15, 25), userId);

            var englishTaskStatistic       = new EnglishTaskStatistic(completedEnglishTask);
            var englishMultimediaStatistic = new EnglishMultimediaStatistic(completedEnglishMultimedia);
            var generalStatistic           = new GeneralStatistic(completedEnglishMultimedia, completedEnglishTask);

            var expectedFullStatistic = new FullStatistic
            {
                GroupedCompletedStatistic           = generalStatistic.GetAllCompleted(),
                PerDayStatistic                     = generalStatistic.GetPerDayForLastMonthStatistic(),
                PerTasksEnglishLevelsStatistic      = englishTaskStatistic.GetTasksPerEnglishLevelStatistic(),
                TasksCorrectnessStatistic           = englishTaskStatistic.GetTasksCorrectnessStatistic(),
                PerMultimediaEnglishLevelsStatistic = englishMultimediaStatistic.GetMultimediaPerEnglishLevelStatistic(),
                PerTextTypeStatistic                = englishMultimediaStatistic.GetPerTextTypeStatistic(),
                PerVideoTypeStatistic               = englishMultimediaStatistic.GetPerVideoTypeStatistic(),
            };

            yield return(new object[] { userId, englishMultimediaStatistic, englishTaskStatistic, expectedFullStatistic });
        }