Exemplo n.º 1
0
        public void WhenQuestionIsNew_ThenItIsNotComplete()
        {
            var question = new OpenQuestionTemplate()
            {
                MaxLength = 10
            }.CreateNewQuestion();

            Assert.IsFalse(question.IsComplete);
        }
Exemplo n.º 2
0
        public void WhenQuestionIsNew_ThenTemplateValuesAreCopied()
        {
            var question = new OpenQuestionTemplate()
            {
                MaxLength = 10
            }.CreateNewQuestion() as OpenQuestion;

            Assert.AreEqual(10, question.MaxLength);
        }
Exemplo n.º 3
0
        public void ViewModelHasMaxLengthAsTheAvailableLength()
        {
            var question = new OpenQuestionTemplate {
                QuestionText = "Question", MaxLength = 25
            }.CreateNewQuestion() as OpenQuestion;
            var viewModel = new OpenQuestionViewModel(question);

            Assert.AreEqual(25, viewModel.AvailableLength);
        }
Exemplo n.º 4
0
        public void WhenCreatingTheViewModel_ThenHasChangesIsFalse()
        {
            var question = new OpenQuestionTemplate {
                QuestionText = "Question", MaxLength = 25
            }.CreateNewQuestion() as OpenQuestion;
            var viewModel = new OpenQuestionViewModel(question);

            Assert.IsFalse(viewModel.HasChanges);
        }
Exemplo n.º 5
0
        public void WhenQuestionHasValidValue_ThenItIsComplete()
        {
            var question = new OpenQuestionTemplate()
            {
                MaxLength = 10
            }.CreateNewQuestion() as OpenQuestion;

            question.Response = "aaaa";

            Assert.IsTrue(question.IsComplete);
        }
Exemplo n.º 6
0
        public void WhenQuestionHasEmptyValue_ThenItIsNotComplete()
        {
            var question = new OpenQuestionTemplate()
            {
                MaxLength = 10
            }.CreateNewQuestion() as OpenQuestion;

            question.Response = "";

            Assert.IsFalse(question.IsComplete);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
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());
        }
Exemplo n.º 10
0
        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"));
        }
Exemplo n.º 11
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());
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
 internal OpenQuestion(OpenQuestionTemplate questionTemplate)
     : base(questionTemplate)
 {
 }
Exemplo n.º 14
0
 internal OpenQuestion(OpenQuestionTemplate questionTemplate)
     : base(questionTemplate)
 {
 }