예제 #1
0
        public void WhenQuestionHasValidValue_ThenItIsComplete()
        {
            var question = new OpenQuestionTemplate() { MaxLength = 10 }.CreateNewQuestion() as OpenQuestion;
            question.Response = "aaaa";

            Assert.IsTrue(question.IsComplete);
        }
        public void ViewModelHasMaxLengthAsTheAvailableLength()
        {
            var question = new OpenQuestionTemplate { QuestionText = "Question", MaxLength = 25 }.CreateNewQuestion() as OpenQuestion;
            var viewModel = new OpenQuestionViewModel(question);

            Assert.AreEqual(25, viewModel.AvailableLength);
        }
예제 #3
0
        public void WhenQuestionHasEmptyValue_ThenItIsNotComplete()
        {
            var question = new OpenQuestionTemplate() { MaxLength = 10 }.CreateNewQuestion() as OpenQuestion;
            question.Response = "";

            Assert.IsFalse(question.IsComplete);
        }
예제 #4
0
        public void WhenResponseLengthExceedsMaxLength_ThenIndicatesErrorOnResponse()
        {
            var question = new OpenQuestionTemplate() { MaxLength = 10 }.CreateNewQuestion() as OpenQuestion;
            var notifyErrorInfo = (INotifyDataErrorInfo)question;

            question.Response = "ThisIsLongerThanTenCharacters";

            Assert.IsTrue(notifyErrorInfo.GetErrors("Response").Cast<ValidationResult>().Any());
        }
        public void WhenSettingTheResponseTextPropertyOnTheModel_ThenAvailableLengthIsUpdatedOnTheViewModel()
        {
            var question = new OpenQuestionTemplate { QuestionText = "Question", MaxLength = 25 }.CreateNewQuestion() as OpenQuestion;
            var viewModel = new OpenQuestionViewModel(question);

            question.Response = "1234567890";

            Assert.AreEqual(15, viewModel.AvailableLength);
        }
        public void WhenSettingTheResponseTextPropertyOnTheModel_ThenAChangeOnAvailableLengthIsNotifiedOnTheViewModel()
        {
            var question = new OpenQuestionTemplate { QuestionText = "Question", MaxLength = 25 }.CreateNewQuestion() as OpenQuestion;
            var viewModel = new OpenQuestionViewModel(question);

            var changeTracker = new PropertyChangeTracker(viewModel);
            question.Response = "1234567890";

            Assert.IsTrue(changeTracker.ChangedProperties.Contains("AvailableLength"));
        }
예제 #7
0
        public void WhenSettingResponseToNull_ThenIndicatesErrorOnResponse()
        {
            var question = new OpenQuestionTemplate() { MaxLength = 10 }.CreateNewQuestion() as OpenQuestion;
            var notifyErrorInfo = (INotifyDataErrorInfo)question;

            question.Response = "valid";
            Assert.IsFalse(notifyErrorInfo.GetErrors("Response").Cast<ValidationResult>().Any());

            question.Response = null;
            Assert.IsTrue(notifyErrorInfo.GetErrors("Response").Cast<ValidationResult>().Any());
        }
        public void WhenSettingTheResponseTextPropertyOnTheModel_ThenTheViewModelNotifiesAResponseChange()
        {
            var question = new OpenQuestionTemplate { QuestionText = "Question", MaxLength = 25 }.CreateNewQuestion() as OpenQuestion;
            var viewModel = new OpenQuestionViewModel(question);

            bool responseChanged = false;
            viewModel.ResponseChanged += (s, e) => responseChanged = true;
            question.Response = "1234567890";

            Assert.IsTrue(responseChanged);
        }
예제 #9
0
 public void WhenQuestionIsNew_ThenTemplateValuesAreCopied()
 {
     var question = new OpenQuestionTemplate() { MaxLength = 10 }.CreateNewQuestion() as OpenQuestion;
     Assert.AreEqual(10, question.MaxLength);
 }
예제 #10
0
 public void WhenQuestionIsNew_ThenItIsNotComplete()
 {
     var question = new OpenQuestionTemplate() { MaxLength = 10 }.CreateNewQuestion();
     Assert.IsFalse(question.IsComplete);
 }
        public void WhenSettingTheResponseOntheModel_ThenViewModelHasChanges()
        {
            var question = new OpenQuestionTemplate { QuestionText = "Question", MaxLength = 25 }.CreateNewQuestion() as OpenQuestion;
            var viewModel = new OpenQuestionViewModel(question);

            question.Response = "1234567890";

            Assert.IsTrue(viewModel.HasChanges);
        }
        public void WhenCreatingTheViewModel_ThenHasChangesIsFalse()
        {
            var question = new OpenQuestionTemplate { QuestionText = "Question", MaxLength = 25 }.CreateNewQuestion() as OpenQuestion;
            var viewModel = new OpenQuestionViewModel(question);

            Assert.IsFalse(viewModel.HasChanges);
        }