Esempio n. 1
0
        public void WhenQuestionHasNegativeValue_ThenItIsNotComplete()
        {
            var question = new NumericQuestionTemplate() { MaxValue = 15 }.CreateNewQuestion() as NumericQuestion;
            question.Response = -1;

            Assert.IsFalse(question.IsComplete);
        }
Esempio n. 2
0
        public void WhenQuestionHasValidValue_ThenItIsComplete()
        {
            var question = new NumericQuestionTemplate() { }.CreateNewQuestion() as NumericQuestion;
            question.Response = 10;

            Assert.IsTrue(question.IsComplete);
        }
Esempio n. 3
0
        public void WhenQuestionHasNullValue_ThenItIsNotComplete()
        {
            var question = new NumericQuestionTemplate() { }.CreateNewQuestion() as NumericQuestion;
            question.Response = 10;
            question.Response = null;

            Assert.IsFalse(question.IsComplete);
        }
Esempio n. 4
0
        public void WhenResponseIsNegative_ThenIndicatesErrorOnResponse()
        {
            var question = new NumericQuestionTemplate() { }.CreateNewQuestion() as NumericQuestion;
            var notifyErrorInfo = (INotifyDataErrorInfo)question;

            question.Response = -15;

            Assert.IsTrue(notifyErrorInfo.GetErrors("Response").Cast<ValidationResult>().Any());
        }
        public void WhenResponseChangesOnTheModel_ThenResponseValueChangeIsFired()
        {
            var question = new NumericQuestionTemplate { MaxValue = 100 }.CreateNewQuestion() as NumericQuestion;
            var viewModel = new NumericQuestionViewModel(question);

            bool responseChangeFired = false;
            viewModel.ResponseChanged += (s, e) => { responseChangeFired = true; };
            question.Response = 15;

            // Assertions
            Assert.IsTrue(responseChangeFired);
        }
        public void WhenHasErrorIsChangedToFalseOnTheViewModel_ThenResponseValueChangeIsFired()
        {
            var question = new NumericQuestionTemplate { MaxValue = 100 }.CreateNewQuestion() as NumericQuestion;
            var viewModel = new NumericQuestionViewModel(question);

            viewModel.HasBindingError = true;
            bool responseChangeFired = false;
            viewModel.ResponseChanged += (s, e) => { responseChangeFired = true; };
            viewModel.HasBindingError = false;

            // Assertions
            Assert.IsTrue(responseChangeFired);
        }
Esempio n. 7
0
        public void WhenResponseIsPositiveWithNoMaximum_ThenIndicatesNoErrorOnResponse()
        {
            var question = new NumericQuestionTemplate() { }.CreateNewQuestion() as NumericQuestion;
            var notifyErrorInfo = (INotifyDataErrorInfo)question;

            question.Response = 15;

            Assert.IsFalse(notifyErrorInfo.GetErrors("Response").Cast<ValidationResult>().Any());
        }
Esempio n. 8
0
 public void WhenQuestionIsCreated_ThenTemplateValuesAreCopied()
 {
     var question = new NumericQuestionTemplate() { MaxValue = 35 }.CreateNewQuestion() as NumericQuestion;
     Assert.AreEqual(35, question.MaxValue);
 }
Esempio n. 9
0
        public void WhenQuestionIsNew_ThenItIsNotComplete()
        {
            var question = new NumericQuestionTemplate() { }.CreateNewQuestion() as NumericQuestion;

            Assert.IsFalse(question.IsComplete);
        }
Esempio n. 10
0
        public void WhenSettingResponseToNull_ThenIndicatesErrorOnResponse()
        {
            var question = new NumericQuestionTemplate() { }.CreateNewQuestion() as NumericQuestion;
            var notifyErrorInfo = (INotifyDataErrorInfo)question;

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

            question.Response = null;
            Assert.IsTrue(notifyErrorInfo.GetErrors("Response").Cast<ValidationResult>().Any());
        }
        public void WhenResponseIsSetOnTheModel_ThenTheHasErrorPropertyInTheViewModelIsCleared()
        {
            var question = new NumericQuestionTemplate { MaxValue = 100 }.CreateNewQuestion() as NumericQuestion;
            var viewModel = new NumericQuestionViewModel(question);

            viewModel.HasBindingError = true;
            int responseChanges = 0;
            viewModel.ResponseChanged += (s, e) => { responseChanges++; };
            question.Response = 15;

            // Assertions
            Assert.IsFalse(viewModel.HasBindingError);
            Assert.AreEqual(1, responseChanges);
        }
        public void WhenViewModelHasErrorIsSet_ThenDoesNotHaveCompletedResponse()
        {
            var question = new NumericQuestionTemplate { MaxValue = 100 }.CreateNewQuestion() as NumericQuestion;
            var viewModel = new NumericQuestionViewModel(question);

            question.Response = 15;
            viewModel.HasBindingError = true;

            // Assertions
            Assert.IsFalse(viewModel.ResponseComplete);
        }
        public void WhenResponseIsSetOnTheModel_ThenHasChangesIsTrue()
        {
            var question = new NumericQuestionTemplate { MaxValue = 100 }.CreateNewQuestion() as NumericQuestion;
            var viewModel = new NumericQuestionViewModel(question);

            question.Response = 15;

            // Assertions
            Assert.IsTrue(viewModel.HasChanges);
        }
        public void WhenCreatingANewViewModel_ThenHasChangesIsFalse()
        {
            var question = new NumericQuestionTemplate { MaxValue = 100 }.CreateNewQuestion() as NumericQuestion;
            var viewModel = new NumericQuestionViewModel(question);

            // Assertions
            Assert.IsFalse(viewModel.HasChanges);
        }