Ejemplo n.º 1
0
        public async Task UpdateQuestionAsync_UpdatesBlanks()
        {
            var database = GetDatabase().Build();
            var question = database.Context.ShortAnswerQuestions
                           .Include(q => q.Blanks)
                           .First();

            database.Reload();

            question.Blanks.Clear();
            question.Blanks.Add(new ShortAnswerQuestionBlank()
            {
                Name = "NewBlank1\r\nLine2"
            });
            question.Blanks.Add(new ShortAnswerQuestionBlank()
            {
                Name = "NewBlank2\r\nLine2"
            });

            var errors  = new MockErrorCollection();
            var updater = new ShortAnswerQuestionUpdater(database.Context, question, errors);
            await updater.UpdateQuestionAsync();

            Assert.False(errors.HasErrors);
            Assert.Equal(2, question.Blanks.Count);
            Assert.Equal("NewBlank1\nLine2", question.Blanks[0].Name);
            Assert.Equal(0, question.Blanks[0].Order);
            Assert.Equal("NewBlank2\nLine2", question.Blanks[1].Name);
            Assert.Equal(1, question.Blanks[1].Order);
        }
		public async Task UpdateQuestionAsync_UpdatesBlanks()
		{
			var database = GetDatabase().Build();
			var question = database.Context.ShortAnswerQuestions
				.Include(q => q.Blanks)
				.First();

			database.Reload();

			question.Blanks.Clear();
			question.Blanks.Add(new ShortAnswerQuestionBlank() { Name = "NewBlank1\r\nLine2" });
			question.Blanks.Add(new ShortAnswerQuestionBlank() { Name = "NewBlank2\r\nLine2" });

			var errors = new MockErrorCollection();
			var updater = new ShortAnswerQuestionUpdater(database.Context, question, errors);
			await updater.UpdateQuestionAsync();

			Assert.False(errors.HasErrors);
			Assert.Equal(2, question.Blanks.Count);
			Assert.Equal("NewBlank1\nLine2", question.Blanks[0].Name);
			Assert.Equal(0, question.Blanks[0].Order);
			Assert.Equal("NewBlank2\nLine2", question.Blanks[1].Name);
			Assert.Equal(1, question.Blanks[1].Order);
		}