示例#1
0
        public async System.Threading.Tasks.Task AddQuestionForTopic()
        {
            using var dbContext = this.GetDbContext();
            using var unity     = new UnitofWork(dbContext);
            dbContext.Questions.Add(new Models.Questions {
                Id = Guid.NewGuid(), Question = "question1", Tags = "c#"
            });
            dbContext.Questions.Add(new Models.Questions {
                Id = Guid.NewGuid(), Question = "question2", Tags = "asp"
            });
            dbContext.Questions.Add(new Models.Questions {
                Id = Guid.NewGuid(), Question = "question3", Tags = "azure"
            });

            await dbContext.SaveChangesAsync();

            Models.Questions newquestion = new Models.Questions()
            {
                Question = "question4", Tags = "azure"
            };
            var service = new QuestionsController(unity);
            var result  = await service.AddQuestionsAsync(newquestion);

            Xunit.Assert.NotNull(result);
        }