コード例 #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());
        }
コード例 #2
0
ファイル: Extensions.cs プロジェクト: SergeyMokin/EngMan
 //Validate GuessesTheImageToReturn
 public static bool Validate(this GuessesTheImageToReturn task)
 {
     return(task != null &&
            task.Id.Validate() &&
            task.Word.Validate(true) &&
            !String.IsNullOrEmpty(task.Path));
 }
コード例 #3
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(), "")));
        }
コード例 #4
0
        public void GuessesTheImageServiceTest_VerificationCorrectness_invalid()
        {
            var model = new GuessesTheImageToReturn
            {
                Id   = 1,
                Path = "path1",
                Word = new Word
                {
                    WordId        = 1,
                    Category      = "Category" + 1,
                    Original      = "Original" + 1235,
                    Translate     = "Translate" + 1,
                    Transcription = "Transcription" + 1
                }
            };
            var expected = false;
            var actual   = service.VerificationCorrectness(model);

            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        public void GuessesTheImageControllerTest_VerificationCorrectness()
        {
            var model = new GuessesTheImageToReturn
            {
                Id   = 1,
                Path = "path1",
                Word = new Word
                {
                    WordId        = 1,
                    Category      = "Category" + 1,
                    Original      = "Original" + 1,
                    Translate     = "Translate" + 1,
                    Transcription = "Transcription" + 1
                }
            };
            var expected = true;
            var actual   = controller.VerificationCorrectness(model);

            Assert.AreEqual(expected, actual);
        }
コード例 #6
0
 public bool VerificationCorrectness(GuessesTheImageToReturn img)
 {
     return(service.VerificationCorrectness(img));
 }