Ejemplo n.º 1
0
        public void ExtensionsTest_Validate_GuessesTheImageToReturn()
        {
            var good = new GuessesTheImageToReturn
            {
                Id   = 1,
                Path = "path",
                Word = new Word
                {
                    WordId        = 1,
                    Category      = "Category",
                    Original      = "Original",
                    Transcription = "Transcription",
                    Translate     = "Translate"
                }
            };
            var bad = new GuessesTheImageToReturn
            {
                Id   = 1,
                Path = "path",
                Word = new Word
                {
                    WordId        = 1,
                    Category      = "Category",
                    Original      = "Original",
                    Transcription = "Transcription",
                    Translate     = null
                }
            };

            Assert.AreEqual(true, good.Validate());
            Assert.AreEqual(false, bad.Validate());
        }
Ejemplo n.º 2
0
        public bool VerificationCorrectness(GuessesTheImageToReturn img)
        {
            const string lettersAndNumbers = "[^a-zA-Zа-яА-Я0-9]";

            Regex rx = new Regex(lettersAndNumbers);

            if (!img.Validate())
            {
                throw new HttpRequestException("Invalid model");
            }

            var task = rep.Get(img.Id);

            if (task == null)
            {
                return(false);
            }

            return(rx.Replace(task.Word.Original.ToLower(), "").Equals(rx.Replace(img.Word.Original.ToLower(), "")));
        }