Example #1
0
        public void GetLicense_StateLevel5_ReturnLevel5()
        {
            WordLeo word  = CreateWordLeo(LicenseLevels.Level_5);
            var     level = word.GetLicense();

            Assert.AreEqual(level, LicenseLevels.Level_5);
        }
Example #2
0
    void IObserver.OnNotify(object parametr, GAME_EVENTS notificationName)
    {
        switch (notificationName)
        {
        case GAME_EVENTS.ButtonHandlerLoaded:
            StartBehaviour();
            break;

        case GAME_EVENTS.WordsEnded:
            print("ScoreValue = " + GetCorrectAnswers());
            WordsEndedBehaviour();
            break;

        case GAME_EVENTS.CorrectAnswer:
            AddWorkoutProgress(currentWord, subWorkout);
            if (currentWord.AllWorkoutDone())
            {
                currentWord.AddLicenseLevel();
            }
            break;

        case GAME_EVENTS.BuildTask:
            IWorkout workout = parametr as IWorkout;
            subWorkout  = workout.WorkoutName;
            currentWord = workout.GetCurrentWord();
            break;
        }
    }
Example #3
0
        public void AllWorkoutDone(bool workoutIsDone)
        {
            WordLeo word   = CreateWordLeo(LicenseLevels.Level_5, workoutIsDone);
            bool    result = word.AllWorkoutDone();

            Assert.AreEqual(result, workoutIsDone);
        }
Example #4
0
    private void FillSamleText(ButtonComponent button)
    {
        WordToTranslate wordToTranslate = FindObjectOfType <WordToTranslate>();

        if (!button || !wordToTranslate)
        {
            Debug.LogWarning("Не найден WordToTranslate");
            return;
        }

        QuestionLeo quest = wordToTranslate.GetCurrentQuest();
        WordLeo     word  = null;

        foreach (var item in quest.answers)
        {
            if (button.text.text == item.translations ||
                button.text.text == item.wordValue)
            {
                word = item;
                break;
            }
        }
        if (word == null)
        {
            return;
        }
        if (button.text.text == word.translations)
        {
            SampleText.text = word.translations + " → " + word.wordValue;
        }
        else
        {
            SampleText.text = word.wordValue + " → " + word.translations;
        }
    }
Example #5
0
    public WordLeo GetRandomWordFromGroup()
    {
        int randomIndex = random.Next(wordsFromGroup.Count);

        WordLeo word = wordsFromGroup[randomIndex];

        return(word);
    }
Example #6
0
    public WordLeo GetRandomWord()
    {
        int randomIndex = random.Next(allWords.Count);

        WordLeo word = allWords[randomIndex];

        return(word);
    }
Example #7
0
        public void LicenseValidityCheck_LicenseExpiries_ExpectedReducedLevelByOne(LicenseLevels actualLevel)
        {
            WordLeo word = CreateWordLeo(actualLevel);

            word.progress.lastRepeat = DateTime.Now - new TimeSpan(0, LicenseTimeout.Level_9 + 5, 0);
            word.LicenseValidityCheck();
            Assert.AreEqual(actualLevel - 1, word.progress.license);
        }
Example #8
0
        public void ResetLicense_LicenseLevelEqualsZero_StateProgressEqualsFalse()
        {
            WordLeo word = CreateWordLeo(LicenseLevels.Level_0);

            word.ResetLicense();

            Assert.AreEqual(word.GetLicense(), LicenseLevels.Level_0);
        }
Example #9
0
    public void GetRandomWordFromGroup_ValidGroup_ReturnWordLeo()
    {
        _wordCollection.LoadGroup(NameGroup);

        WordLeo word = _wordCollection.GetRandomWordFromGroup();

        Assert.IsInstanceOf <WordLeo>(word);
    }
Example #10
0
        public void LicenseValidityCheck_LicenseNotExpiries_ExpectedLevelHasNotChanged(LicenseLevels expectedLevel)
        {
            WordLeo word = CreateWordLeo(expectedLevel);

            word.progress.lastRepeat = DateTime.Now - new TimeSpan(0, 1, 0);
            word.LicenseValidityCheck();
            Assert.AreEqual(expectedLevel, word.progress.license);
        }
Example #11
0
        public void CanbeRepeated_AllWorkoutFalse_ReturnTrue()
        {
            bool expectedValue = true;

            WordLeo word        = CreateWordLeo(LicenseLevels.Level_3);
            bool    resultValue = word.CanbeRepeated();

            Assert.AreEqual(expectedValue, resultValue);
        }
Example #12
0
        public void CanTraining_AllWorkoutFalse_ReturnTrue(WorkoutNames WorkoutName)
        {
            bool expectedValue = true;

            WordLeo word        = CreateWordLeo(LicenseLevels.Level_3);
            bool    resultValue = word.CanTraining(WorkoutName);

            Assert.AreEqual(expectedValue, resultValue);
        }
Example #13
0
        public void GetLicenseExpiration_Level0_ReturnZero()
        {
            double expectedValue = 0;

            WordLeo word        = CreateWordLeo();
            double  resultValue = word.GetLicenseUnlockForRepeat().TotalMinutes;

            Assert.AreEqual(expectedValue, resultValue);
        }
Example #14
0
        public void ReduceLicense_LicenseLevelEqualsZero_StateNotChange()
        {
            WordLeo       word          = CreateWordLeo(LicenseLevels.Level_0);
            LicenseLevels expextedLevel = LicenseLevels.Level_0;

            word.ReduceLicense();
            var resultLevel = word.GetLicense();

            Assert.AreEqual(resultLevel, expextedLevel);
        }
Example #15
0
        public void ResetLicense_LicenseLevelBeggesZero_StateLicenseLevelEqualsZeroAndTimeEqualsNow()
        {
            WordLeo word = CreateWordLeo(LicenseLevels.Level_5);

            word.ResetLicense();
            var snapTime = DateTime.Now;

            Assert.AreEqual(word.GetLicense(), LicenseLevels.Level_0);
            Assert.AreEqual(word.progress.lastRepeat.Second, snapTime.Second);
        }
Example #16
0
        public void UnlockWorkouts_WorkoutsProgressIsTrue_StateWorkoutsProgressIsFalse()
        {
            WordLeo word = CreateWordLeo(LicenseLevels.Level_5, true);

            word.UnlockWorkouts();

            Assert.AreEqual(word.progress.word_translate, false);
            Assert.AreEqual(word.progress.translate_word, false);
            Assert.AreEqual(word.progress.audio_word, false);
            Assert.AreEqual(word.progress.word_puzzle, false);
        }
Example #17
0
    /// <summary>
    /// Заполнить кнопки вариантами ответов
    /// </summary>
    /// <param name="questionLeo"></param>
    /// <param name="questionWord"></param>
    private void SetButtons(QuestionLeo questionLeo, WordLeo questionWord)
    {
        List <string> answers = new List <string>(Workout.ANSWER_COUNT);

        foreach (WordLeo item in questionLeo.answers)
        {
            answers.Add(item.translations);
        }

        core.SetButtons(answers, questionWord.translations);
    }
Example #18
0
        public void ReduceLicense_LicenseLevelEqualsFive_StateLicenseLevelEqualsFour()
        {
            WordLeo       word          = CreateWordLeo(LicenseLevels.Level_5);
            LicenseLevels expextedLevel = LicenseLevels.Level_4;
            var           expextedTime  = DateTime.Now;

            word.ReduceLicense();
            var resultLevel = word.GetLicense();

            Assert.AreEqual(expextedLevel, resultLevel);
            Assert.AreEqual(expextedTime.Second, word.progress.lastRepeat.Second);
        }
Example #19
0
    private void UpdateInfoWord()
    {
        WordLeo word = coreWorkout.GetCurrentWord();

        LevelText.text = word.progress.license.ToString();

        TimeSpan time = word.GetLicenseValidityTime();

        TimeReduceText.text = Utilities.FormatTime(time);

        TimeSpan timeUnlock = word.GetLicenseUnlockForRepeat();

        TimeRepeatText.text = Utilities.FormatTime(timeUnlock);
    }
Example #20
0
        public void GetLicenseValidityTime()
        {
            LicenseLevels level         = LicenseLevels.Level_3;
            int           levelTime     = LicenseTimeout.Level_3;
            int           timeExpiries  = levelTime - 20;
            double        expectedValue = levelTime - timeExpiries;

            WordLeo word = CreateWordLeo(level);

            word.progress.lastRepeat = DateTime.Now - TimeSpan.FromMinutes(timeExpiries);

            double resultValue = RoundTofloat(word.GetLicenseValidityTime().TotalMinutes);

            Assert.AreEqual(expectedValue, resultValue);
        }
Example #21
0
        public void LicenseExpirationCheck_LicenseExpiries_ExpectedProgressHasReset(LicenseLevels expectedLevel)
        {
            bool currentProgress  = true;
            bool expectedProgress = false;

            WordLeo word = CreateWordLeo(expectedLevel, currentProgress);

            word.progress.lastRepeat = DateTime.Now - new TimeSpan(0, LicenseTimeTraining.Level_9 + 1, 0);
            word.LicenseExpirationCheck();

            Assert.AreEqual(word.progress.word_translate, expectedProgress);
            Assert.AreEqual(word.progress.translate_word, expectedProgress);
            Assert.AreEqual(word.progress.audio_word, expectedProgress);
            Assert.AreEqual(word.progress.word_puzzle, expectedProgress);
        }
Example #22
0
    public bool Equals(WordLeo other)
    {
        if (other == null)
        {
            return(false);
        }

        if (this.questWord.wordValue == other.wordValue)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #23
0
        //[Test]
        //public void GetProgressCount()
        //{
        //    Assert.Fail();
        //}

        //[Test]
        //public void LearnAudio()
        //{
        //    Assert.Fail();
        //}

        //[Test]
        //public void LearnPuzzle()
        //{
        //    Assert.Fail();
        //}

        //[Test]
        //public void LearnTranslateWord()
        //{
        //    Assert.Fail();
        //}

        //[Test]
        //public void LearnWordTranslate()
        //{
        //    Assert.Fail();
        //}

        //[Test]
        //public void LicenseExists()
        //{
        //    Assert.Fail();
        //}

        // Отложено до рефакторига
        //[Test]
        //public void AddLicenseLevel()
        //{
        //    WordLeo word = CreateWordLeo(LicenseLevels.Level_5);
        //    word.AddLicenseLevel();
        //    var snapTime = DateTime.Now;

        //    Assert.AreEqual(word.progress.license, LicenseLevels.Level_6);
        //    Assert.AreEqual(word.progress.lastRepeat.Second, snapTime.Second);
        //}


        #region Utils
        private static WordLeo CreateWordLeo(LicenseLevels level   = LicenseLevels.Level_0,
                                             bool workoutsProgress = false)
        {
            WordLeo word;

            word          = new WordLeo();
            word.progress = new WorkoutProgress();

            word.progress.license = level;

            word.progress.word_translate = workoutsProgress;
            word.progress.translate_word = workoutsProgress;
            word.progress.audio_word     = workoutsProgress;
            word.progress.word_puzzle    = workoutsProgress;

            return(word);
        }
Example #24
0
    public void Init(WordLeo word)
    {
        wordImage.sprite         = Utilities.GetSprite(word.pictureURL);
        wordImage.preserveAspect = true;

        levelText.text = word.progress.license.ToString();
        wordText.text  = word.wordValue + " - " + word.translations;
        word.LicenseExpirationCheck();

        TimeSpan time = word.GetLicenseValidityTime();

        TimeReduceText.text = Utilities.FormatTime(time);

        TimeSpan timeUnlock = word.GetLicenseUnlockForRepeat();

        TimeUnlockText.text = Utilities.FormatTime(timeUnlock);

        GetComponent <Transform>().localScale    = Vector3.one;
        GetComponent <Transform>().localPosition = Vector3.zero;
    }
Example #25
0
        public void GetLicenseExpiration_LevelBiggestZero_ReturnExpectedValue()
        {
            LicenseLevels level        = LicenseLevels.Level_3;
            int           levelTime    = LicenseTimeTraining.Level_3;
            int           timeExpiries = levelTime - 20;

            WordLeo word = CreateWordLeo(level, true);

            word.progress.lastRepeat = DateTime.Now - new TimeSpan(0, timeExpiries, 0);

            TimeSpan interval      = DateTime.Now - word.progress.lastRepeat;
            double   expectedValue = levelTime - interval.TotalMinutes;

            expectedValue = RoundTofloat(expectedValue);

            double resultValue = word.GetLicenseUnlockForRepeat().TotalMinutes;

            resultValue = RoundTofloat(resultValue);

            Assert.AreEqual(expectedValue, resultValue);
        }
Example #26
0
    private WordCollection BuildMockCollection()
    {
        WordCollection mockWordCollection = new WordCollection();

        WordLeo word = new WordLeo()
        {
            wordValue          = "metaphor",
            translations       = "метафора",
            pictureURL         = "http://contentcdn.lingualeo.com/uploads/picture/3250267.png",
            transcription      = "ˈmɛtəfɔr",
            highlightedContext = "",
            soundURL           = "https://audiocdn.lingualeo.com/v2/1/25559-631152008.mp3",
            clozefiedContext   = "",
            groups             = new[] { "Литература" }
        };

        word.progress = new WorkoutProgress();

        mockWordCollection.allWords.Add(word);
        return(mockWordCollection);
    }
Example #27
0
    private void AddWorkoutProgress(WordLeo word, WorkoutNames workout)
    {
        switch (workout)
        {
        case WorkoutNames.WordTranslate:
        case WorkoutNames.reiteration:
            word.LearnWordTranslate();
            break;

        case WorkoutNames.TranslateWord:
            word.LearnTranslateWord();
            break;

        case WorkoutNames.Audio:
            word.LearnAudio();
            break;

        case WorkoutNames.Puzzle:
            word.LearnPuzzle();
            break;
        }
    }
Example #28
0
 public static string GetFirstTranslate(WordLeo questWord)
 {
     return(questWord.translations.Split(',')[0]);
 }
Example #29
0
 public static string[] GetTranslates(WordLeo questWord)
 {
     return(questWord.translations.Split(','));
 }
Example #30
0
    private void CreateCard(WordLeo word)
    {
        WordInfoPanel setPanel = Instantiate(panelPrefab, content.transform);

        setPanel.Init(word);
    }