protected override void SetAnswers(Form form)
 {
     Answers.Clear();
     foreach (var binaryAnswer in mGetAnswers(form).Where(x => x.BelongsTo(mStage)))
     {
         Answers.Add(new BinaryAnswerViewModel(binaryAnswer));
     }
 }
 protected override void SetAnswers(Form form)
 {
     Answers.Clear();
     foreach (var gradeAnswer in form.GradeAnswers.Where(x => x.BelongsTo(mStage)))
     {
         Answers.Add(new GradeAnswerViewModel(gradeAnswer));
     }
 }
        public void CreateFor()
        {
            var repository = new SongAnswerRepository(mSession);

            var form = new Form();
            repository.CreateFor(form);

            Assert.AreEqual(44, form.SongAnswers.Count);
        }
        public void BelongsTo()
        {
            var repository = new BinaryAnswerRepository(mSession);

            var form = new Form();
            repository.CreateFor(form);

            Assert.AreEqual(11, form.BinaryAnswers.Where(b => b.BelongsTo(Stage.Pre)).Count());
        }
Exemplo n.º 5
0
        public void Form_setter_calls_changed_event()
        {
            Form changed = null;
            mHolder.OnChanged += x => changed = x;

            var form = new Form();
            mHolder.Form = form;

            Assert.AreSame(form, changed);
        }
        public void CreateFor()
        {
            var repository = new BinaryAnswerRepository(mSession);

            var form = new Form();
            repository.CreateFor(form);

            var expectedAnswerCount = 51;

            Assert.AreEqual(expectedAnswerCount, form.BinaryAnswers.Count);
        }
Exemplo n.º 7
0
        public Form CreateNew()
        {
            var form = new Form { Id = mQuestionFormRepository.GetNextId() };

            foreach (var repository in mAnswerRepositories)
            {
                repository.CreateFor(form);
            }

            return form;
        }
Exemplo n.º 8
0
        public void GetNextForm_returns_null_when_at_last_index()
        {
            Form form1 = new Form { Name = "Form1" };

            var repository = new FormRepository(mSession);

            repository.Insert(form1);

            var next = repository.GetNextForm(form1.Id);

            Assert.IsNull(next);
        }
Exemplo n.º 9
0
        public void GetPreviousForm_returns_null_when_at_first_position()
        {
            Form form1 = new Form {Name = "Form1"};

            var repository = new FormRepository(mSession);

            repository.Insert(form1);

            var previous = repository.GetPreviousForm(form1.Id);

            Assert.IsNull(previous);
        }
Exemplo n.º 10
0
        public void HasNext()
        {
            Form form1 = new Form { Name = "Form1" };
            Form form2 = new Form { Name = "Form2" };

            var repository = new FormRepository(mSession);

            repository.Insert(form1);
            repository.Insert(form2);

            Assert.IsTrue(repository.HasNext(form1.Id));
        }
Exemplo n.º 11
0
        public void GetNext()
        {
            Form form1 = new Form { Name = "Form1" };
            Form form2 = new Form { Name = "Form2" };

            var repository = new FormRepository(mSession);

            repository.Insert(form1);
            repository.Insert(form2);

            var next = repository.GetNextForm(form1.Id);

            Assert.AreEqual(form2.Name, next.Name);
        }
Exemplo n.º 12
0
        public void GetPrevious()
        {
            Form form1 = new Form{ Name = "Form1"};
            Form form2 = new Form{ Name = "Form2"};

            var repository = new FormRepository(mSession);

            repository.Insert(form1);
            repository.Insert(form2);

            var previous = repository.GetPreviousForm(form2.Id);

            Assert.AreEqual(form1.Name, previous.Name);
        }
Exemplo n.º 13
0
 public CurrentFormHolder(Form form, IFormFactory formFactory)
 {
     mFormFactory = formFactory;
     Form = form;
 }
Exemplo n.º 14
0
        public void HasPrevious_should_return_false_if_it_is_the_first_form()
        {
            Form form1 = new Form { Name = "Form1" };
            Form form2 = new Form { Name = "Form2" };

            var repository = new FormRepository(mSession);

            repository.Insert(form1);
            repository.Insert(form2);

            Assert.IsFalse(repository.HasPrevious(form1.Id));
        }
Exemplo n.º 15
0
 private void ResetFormTo(Form form)
 {
     OnPropertyChanged("Name");
     OnPropertyChanged("School");
     OnPropertyChanged("Class");
     OnPropertyChanged("Age");
     OnPropertyChanged("Grade");
     OnPropertyChanged("Instrument");
     OnPropertyChanged("Email");
     OnPropertyChanged("Gender");
 }
Exemplo n.º 16
0
 private void UpdateHasPreviosAndHasNext(Form form)
 {
     HasPrevious = mFormRepository.HasPrevious(form.Id);
     HasNext = mFormRepository.HasNext(form.Id);
 }
Exemplo n.º 17
0
 public void Insert(Form item)
 {
     mSession.Save(item);
     mSession.Flush();
 }
Exemplo n.º 18
0
 protected abstract void SetAnswers(Form form);
Exemplo n.º 19
0
        public void HasNext_and_returns_false_if_none_exists()
        {
            Form form1 = new Form { Name = "Form1" };
            Form form2 = new Form { Name = "Form2" };

            var repository = new FormRepository(mSession);

            repository.Insert(form1);
            repository.Insert(form2);

            Assert.IsFalse(repository.HasNext(form2.Id));
        }
Exemplo n.º 20
0
 public void ResetWithNewForm()
 {
     Form = mFormFactory.CreateNew();
 }