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

            // Assertions
            Assert.IsFalse(viewModel.HasChanges);
        }
        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 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 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);
        }
        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 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);
        }
        public void WhenResponseIsSetOnTheModel_ThenHasChangesIsTrue()
        {
            var question = new NumericQuestion { MaxValue = 100 };
            var viewModel = new NumericQuestionViewModel(question);

            bool hasChanges = false;
            viewModel.ResponseChanged += (o, e) => { hasChanges = true; };

            question.Response = 15;

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

            bool hasChanges = false;
            viewModel.ResponseChanged += (o, e) => { hasChanges = true; };

            // Assertions
            Assert.IsFalse(hasChanges);
        }