示例#1
0
        public async Task DeleteOptionsQuestionAssignmnentAsync_OptionsQuestionAssignmnentIsDeleted()
        {
            // Arrange
            await db.AddRangeAsync(seedAssignments);

            await db.SaveChangesAsync();

            int optionId = 1;

            var deletedOptionsQuestionAssignmnent = new OptionsQuestionAssignmnents()
            {
                OptionOrderNum = 1, FormId = 1, QuestionOrderNum = 1, OptionId = optionId
            };

            var expectedOptionsQuestionAssignmnent = seedAssignments.Where(a => a.OptionId != optionId);

            // Act
            await service.Delete(deletedOptionsQuestionAssignmnent);

            // Assert
            var actualOptionsQuestionAssignmnent = await db.OptionsQuestionAssignmnents.ToListAsync();

            Assert.Equal(
                expectedOptionsQuestionAssignmnent.OrderBy(o => o.OptionId).Select(o => o.OptionId),
                actualOptionsQuestionAssignmnent.OrderBy(o => o.OptionId).Select(o => o.OptionId));
        }
示例#2
0
        public async Task <OptionsQuestionAssignmnents> Add(OptionsQuestionAssignmnents option)
        {
            _context.OptionsQuestionAssignmnents.Add(option);
            await _context.SaveChangesAsync();

            return(option);
        }
示例#3
0
        public async Task <OptionsQuestionAssignmnents> Delete(OptionsQuestionAssignmnents option)
        {
            var deletedOption = await _context.OptionsQuestionAssignmnents.FindAsync(option.OptionOrderNum, option.FormId, option.QuestionOrderNum);

            _context.OptionsQuestionAssignmnents.Remove(deletedOption);
            await _context.SaveChangesAsync();

            return(deletedOption);
        }
示例#4
0
        public async Task AddOptionAssignmentAsync_OptionAssignmentIsAdded()
        {
            // Arrange
            var oon    = 1;
            var formid = 2;
            var qon    = 1;

            var expectedAssignment = new OptionsQuestionAssignmnents()
            {
                OptionOrderNum = oon, FormId = formid, QuestionOrderNum = qon, OptionId = 4
            };

            // Act
            await service.Add(expectedAssignment);

            // Assert
            var actualAssignment = await db.OptionsQuestionAssignmnents.FirstOrDefaultAsync(o => o.OptionOrderNum == oon && o.FormId == formid && o.QuestionOrderNum == qon);

            Assert.Equal(expectedAssignment, actualAssignment);
        }