public TrainingWordSuiteModel Map(WordSuite WordSuite)
 {
     TrainingWordSuiteModel wordSuiteModel = new TrainingWordSuiteModel();
     wordSuiteModel.Id = WordSuite.Id;
     wordSuiteModel.OwnerId = WordSuite.OwnerId;
     wordSuiteModel.QuizResponseTime = WordSuite.QuizResponseTime;
     wordSuiteModel.QuizStartTime = WordSuite.QuizStartTime;
     wordSuiteModel.Name = WordSuite.Name;
     wordSuiteModel.WordTranslations = new List<WordTranslationModel>();
     wordSuiteModel.WordTranslations.AddRange(WordSuite.WordProgresses.Select(x => _mapper.Map(x.WordTranslation)).ToList());
     return wordSuiteModel;
 }
Example #2
0
 public TrainingWordSuiteModel Map(WordSuite WordSuite)
 {
     TrainingWordSuiteModel wordSuiteModel = new TrainingWordSuiteModel();
     wordSuiteModel.Id = WordSuite.Id;
     wordSuiteModel.OwnerId = WordSuite.OwnerId;
     wordSuiteModel.QuizResponseTime = WordSuite.QuizResponseTime;
     wordSuiteModel.QuizStartTime = WordSuite.QuizStartTime;
     wordSuiteModel.Name = WordSuite.Name;
     wordSuiteModel.WordTranslations = new List<WordTranslationModel>();
     wordSuiteModel.WordTranslations.AddRange(WordSuite.WordProgresses.Select(x => _mapper.Map(x.WordTranslation)).ToList());
     return wordSuiteModel;
 }
        public TrainingWordSuiteModel Map(WordSuite WordSuite)
        {
            TrainingWordSuiteModel wordSuiteModel = new TrainingWordSuiteModel();
            wordSuiteModel.Id = WordSuite.Id;
            wordSuiteModel.OwnerId = WordSuite.OwnerId;
            wordSuiteModel.QuizResponseTime = WordSuite.QuizResponseTime;
            wordSuiteModel.QuizStartTime = WordSuite.QuizStartTime;
            wordSuiteModel.Name = WordSuite.Name;
            wordSuiteModel.LanguageId = WordSuite.LanguageId;
            wordSuiteModel.Threshold = WordSuite.Threshold;
            wordSuiteModel.WordTranslations = new List<WordTranslationModel>();
            wordSuiteModel.WordTranslations.AddRange(WordSuite.WordProgresses.Select(x => _mapper.Map(x.WordTranslation)).ToList());
            for (int i = 0; i < wordSuiteModel.WordTranslations.Count; i++)
            {
                wordSuiteModel.WordTranslations[i].Progress = (int)(WordSuite.WordProgresses.ToList())[i].Progress;

            }
            return wordSuiteModel;
        }
Example #4
0
        public TrainingWordSuiteModel Map(WordSuite WordSuite)
        {
            TrainingWordSuiteModel wordSuiteModel = new TrainingWordSuiteModel();

            wordSuiteModel.Id               = WordSuite.Id;
            wordSuiteModel.OwnerId          = WordSuite.OwnerId;
            wordSuiteModel.QuizResponseTime = WordSuite.QuizResponseTime;
            wordSuiteModel.QuizStartTime    = WordSuite.QuizStartTime;
            wordSuiteModel.Name             = WordSuite.Name;
            wordSuiteModel.LanguageId       = WordSuite.LanguageId;
            wordSuiteModel.Threshold        = WordSuite.Threshold;
            wordSuiteModel.WordTranslations = new List <WordTranslationModel>();
            wordSuiteModel.WordTranslations.AddRange(WordSuite.WordProgresses.Select(x => _mapper.Map(x.WordTranslation)).ToList());
            for (int i = 0; i < wordSuiteModel.WordTranslations.Count; i++)
            {
                wordSuiteModel.WordTranslations[i].Progress = (int)(WordSuite.WordProgresses.ToList())[i].Progress;
            }
            return(wordSuiteModel);
        }
        public void TrainingWordSuiteController_GetTest()
        {
            //Arrange
            var initial = new WordSuite()
            {
                Id = 1,
                Name = "Days of the week"
            };

            var expected = new TrainingWordSuiteModel()
            {
                Id = 1,
                Name = "Days of the week",
                WordTranslations = new List<WordTranslationModel>()
                        {
                            new WordTranslationModel
                            {
                                Id = 1, OriginalWord = "sunday"
                            },
                            new WordTranslationModel
                            {
                                Id = 1, OriginalWord = "monday"
                            }
                        }
            };
            //Action
            Mock<IQuizWordSuiteMapper> testWordSuiteMapper = new Mock<IQuizWordSuiteMapper>();
            Mock<ITrainingWordSuiteMapper> trainingWordSuiteMapper = new Mock<ITrainingWordSuiteMapper>();
            Mock<IWordSuiteService> wordSuiteService = new Mock<IWordSuiteService>();
            Mock<IWordProgressService> progressService = new Mock<IWordProgressService>();
            Mock<IWordProgressMapper> progressMapper = new Mock<IWordProgressMapper>();
            GenerateData("1", new[] { "NoRoles" });
            TrainingWordSuiteController Controller = new TrainingWordSuiteController(testWordSuiteMapper.Object,
                trainingWordSuiteMapper.Object,
                wordSuiteService.Object,
                progressService.Object,
                progressMapper.Object);
            wordSuiteService.Setup(x => x.GetWithNotStudiedWords(1)).Returns(initial);
            testWordSuiteMapper
                   .Setup(x => x.Map(initial))
                    .Returns(expected);
            var actual = Controller.GetTask(1);

            //Assert
            //Assert.AreEqual(expected, actual);
        }
        public void TrainingWordSuiteController_Check()
        {
            //Arrange
            var initial = new WordSuite()
            {
                Id = 1,
                Name = "Days of the week",
            };

            var data = new TrainingWordSuiteModel()
            {
                Id = 1,
                Name = "Days of the week",
                QuizStartTime = DateTime.Now,
                QuizResponseTime = 10,
                WordTranslations = new List<WordTranslationModel>()
                {
                            new WordTranslationModel
                            {
                                Id = 1, OriginalWord = "sunday", TranslationWord = "sunday"
                            },
                            new WordTranslationModel
                            {
                                Id = 1, OriginalWord = "monday", TranslationWord = "monday"
                            }
                        }
            };

            var expected = new TrainingWordSuiteModel()
            {
                Id = 1,
                Name = "Days of the week",
                QuizStartTime = DateTime.Now,
                QuizResponseTime = 10,
                WordTranslations = new List<WordTranslationModel>()
                        {
                            new WordTranslationModel
                            {
                                Id = 1, OriginalWord = "sunday", TranslationWord = "неділя"
                            },
                            new WordTranslationModel
                            {
                                Id = 1, OriginalWord = "monday", TranslationWord = "понеділок"
                            }
                        }
            };

            //Action
            Mock<IQuizWordSuiteMapper> testWordSuiteMapper = new Mock<IQuizWordSuiteMapper>();
            Mock<ITrainingWordSuiteMapper> trainingWordSuiteMapper = new Mock<ITrainingWordSuiteMapper>();
            Mock<IWordSuiteService> wordSuiteService = new Mock<IWordSuiteService>();
            Mock<IWordProgressService> progressService = new Mock<IWordProgressService>();
            Mock<IWordProgressMapper> progressMapper = new Mock<IWordProgressMapper>();
            GenerateData("1", new[] { "NoRoles" });
            TrainingWordSuiteController Controller = new TrainingWordSuiteController(testWordSuiteMapper.Object,
                trainingWordSuiteMapper.Object,
                wordSuiteService.Object,
                progressService.Object,
                progressMapper.Object);
              wordSuiteService.Setup(x => x.GetWithNotStudiedWords(1)).Returns(initial);
            trainingWordSuiteMapper
                   .Setup(x => x.Map(initial))
                    .Returns(expected);
            progressService.Setup(x => x.IncrementProgress(It.IsAny<int>(), It.IsAny<int>())).Returns(true);

            var actual = Controller.CheckTask(data);

            //Assert
            Assert.IsInstanceOf(typeof(OkNegotiatedContentResult<TrainingWordSuiteModel>), actual);
        }