Ejemplo n.º 1
0
        public void AfterResetting_ThenANewQuestionnaireIsCreated()
        {
            QuestionViewModel[] originalQuestions = null;
            Action <IOperationResult <Questionnaire> > callback = null;

            var repository = new Mock <IQuestionnaireRepository>();

            repository.Setup(r => r.GetQuestionnaireAsync(It.IsAny <Action <IOperationResult <Questionnaire> > >()))
            .Callback <Action <IOperationResult <Questionnaire> > >(c => callback = c);

            var viewModel = new QuestionnaireViewModel(repository.Object);

            callback(CreateQuestionnaireResult());

            originalQuestions = viewModel.Questions.ToArray();

            viewModel.Questionnaire.Name = "TestName";
            viewModel.Questionnaire.Age  = 14;
            AnswerAllQuestions(viewModel);

            viewModel.Reset();

            var tracker = new PropertyChangeTracker(viewModel);

            callback(CreateQuestionnaireResult());

            CollectionAssert.AreNotEquivalent(originalQuestions, viewModel.Questions.ToArray());
            CollectionAssert.Contains(tracker.ChangedProperties, "CanSubmit");
        }