public async Task TestNotEnoughQuestion() { //Prepare TestingContext context = new TestingContext(); context.AddPrincipalMock(); context.AddBinaryServiceMock(); context.AddInMemoryDb(); context.AddMockLogService(); context.AddGermanCultureServiceMock(); context.AddQuestionService(); CourseService courseService = context.GetService <CourseService>(); context.DependencyMap[typeof(ICourseService)] = courseService; ApplicationDbContext dbContext = context.GetSimple <ApplicationDbContext>(); Course course = dbContext.Courses.First(); course.NumQuestionsToAsk = 100; ICourseInstanceService courseInstanceService = context.GetService <CourseInstanceService>(); //Act var courseInstance = await courseInstanceService.StartCourseAsync(course.Id); //Assert Assert.Equal(10, courseInstance.NumQuestionsTotal); }
public async Task TestGetVersions() { //Prepare TestingContext testingContext = new TestingContext(); SetUpTestingContext(testingContext); ApplicationDbContext dbContext = testingContext.GetSimple <ApplicationDbContext>(); Question question = dbContext.Questions.First(); testingContext.AddPrincipalMock(question.User.UserId, Roles.User); testingContext.AddBusinessSecurityService(); IQuestionService questionService = testingContext.GetService <QuestionService>(); testingContext.DependencyMap[typeof(IQuestionService)] = questionService; IVersionService versionService = testingContext.GetService <VersionService>(); int newId = await versionService.VersionQuestionAsync(question.Id); await versionService.AcceptQuestionAsync(newId); VersionInfoParametersDto versionInfoParametersDto = new VersionInfoParametersDto() { Page = 0, IdQuestion = newId, }; //Act PagedResultDto <VersionInfoDto> result = await versionService.GetVersionsAsync(versionInfoParametersDto); //Assert Assert.Equal(2, result.Count); }
public async Task TestCopyQuestion() { //Prepare TestingContext context = new TestingContext(); InitContext(context); ApplicationDbContext dbContext = context.GetSimple <ApplicationDbContext>(); Question question = dbContext.Questions.First(); context.AddPrincipalMock(question.User.UserId, Roles.User); IQuestionService questionService = context.GetService <QuestionService>(); context.DependencyMap[typeof(IQuestionService)] = questionService; IVersionService versionService = context.GetService <VersionService>(); //Act int newId = await versionService.CopyQuestionAsync(question.Id); //Assert Assert.True(question.Id != newId); Assert.True(newId > 0); QuestionDto newQuestion = await questionService.GetQuestionAsync(newId); Assert.Equal(question.Options.Count, newQuestion.Options.Count); Assert.Equal(question.QuestionType, newQuestion.QuestionType); for (int i = 0; i < question.Options.Count; i++) { QuestionOption optionSource = question.Options[i]; QuestionOptionDto optionDestination = newQuestion.Options[i]; Assert.NotEqual(optionSource.Id, optionDestination.Id); Assert.True(optionDestination.Id > 0); } }
private void InitContext(TestingContext context) { context.AddPrincipalMock(); context.AddInMemoryDb(); context.AddMockLogService(); context.AddGermanCultureServiceMock(); context.AddBinaryServiceMock(); context.AddCacheService(); context.DependencyMap[typeof(ICommentsService)] = context.GetService <CommentsService>(); context.DependencyMap[typeof(ITagService)] = context.GetService <TagService>(); }
public async Task UpdateQuestionOk() { //Prepare TestingContext testingContext = new TestingContext(); InitContext(testingContext); ApplicationDbContext dbContext = testingContext.GetSimple <ApplicationDbContext>(); Question question = dbContext.Questions.First(); testingContext.AddPrincipalMock(question.User.UserId, Roles.User); testingContext.AddBusinessSecurityService(); IQuestionService questionService = testingContext.GetService <QuestionService>(); QuestionDto dto = await questionService.GetQuestionAsync(question.Id); dto.Title = "Another Title"; //Act await questionService.UpdateQuestionAsync(dto); //Assert QuestionDto dtoResult = await questionService.GetQuestionAsync(question.Id); Assert.Equal("Another Title", dtoResult.Title); }
public async Task TestAddPushNotificationSubscriptionAsync() { //Setup TestingContext testingContext = new TestingContext(); SetUpTestingContext(testingContext); INotificationService notificationService = testingContext.GetService <NotificationService>(); NotificationSubscriptionDto dto = new NotificationSubscriptionDto() { Endpoint = "Test", Keys = new KeyDto() { Auth = "TestAut", P256dh = "testp256", }, ExpirationTime = DateTime.Today.AddYears(3), }; //Act await notificationService.AddPushNotificationSubscriptionAsync(dto); //Assert ApplicationDbContext dbContext = testingContext.GetSimple <ApplicationDbContext>(); NotificationSubscription sub = await dbContext.Notifications.LastAsync(); Assert.Equal(dto.Endpoint, sub.Endpoint); Assert.True(sub.Id > 0); }
public async void TestExport() { //Prepare TestingContext testingContext = new TestingContext(); testingContext.AddAdminPrincipalMock(); testingContext.AddBinaryServiceMock(); testingContext.AddInMemoryDb(); testingContext.AddUserService(); testingContext.AddBusinessSecurityService(); testingContext.AddLogServiceMock(); testingContext.AddGermanCultureServiceMock(); testingContext.AddQuestionService(); IExportService exportService = testingContext.GetService <ExportService>(); //Act Stream stream = await exportService.Export(); //Assert ZipArchive arch = new ZipArchive(stream); ZipArchiveEntry entry = arch.GetEntry("questions.json"); Stream zipEntryStream = entry.Open(); using (var reader = new StreamReader(zipEntryStream, Encoding.UTF8)) { string value = reader.ReadToEnd(); IList <QuestionDto> questions = JsonConvert.DeserializeObject <IList <QuestionDto> >(value); Assert.True(questions.Count > 0); } Assert.True(arch.Entries.Count > 0); }
public async Task TestGetComments() { TestingContext testingContext = new TestingContext(); SetUpTestingContext(testingContext); ApplicationDbContext appDbContext = testingContext.GetSimple <ApplicationDbContext>(); ICommentsService commentsService = testingContext.GetService <CommentsService>(); Question question = appDbContext.Questions.First(); for (int i = 0; i < 20; i++) { CommentDto commentDto = new CommentDto() { IdQuestion = question.Id, CommentText = "Hello Comment", }; await commentsService.AddCommentAsync(commentDto); } GetCommentsDto getCommentsDto = new GetCommentsDto { IdQuestion = question.Id, Page = 0, }; //Act PagedResultDto <CommentDto> comments = await commentsService.GetCommentssAsync(getCommentsDto); //Assert Assert.Equal(5, comments.Data.Count); Assert.Equal(4, comments.Numpages); Assert.Equal(20, comments.Count); }
public async Task GetTextEnTest() { TestingContext testingContext = new TestingContext(); testingContext.AddAdminPrincipalMock(); testingContext.AddInMemoryDb(); testingContext.AddLogServiceMock(); testingContext.AddEnglishCultureServiceMock(); ApplicationDbContext dbContext = testingContext.GetSimple <ApplicationDbContext>(); dbContext.Texts.Add(new Text() { Key = "TestKey", ContentDe = "ContentDe {0} {1} {2}", ContentEn = "ContentEn {0} {1} {2}", }); await dbContext.SaveChangesAsync(); ITextService textService = testingContext.GetService <TextService>(); //Act string text = await textService.GetTextAsync("TestKey", "pl1", "pl2", "pl3"); //Assert Assert.Equal("ContentEn pl1 pl2 pl3", text); }
public async Task AddTag() { //Prepare TestingContext context = new TestingContext(); SetupContext(context); ITagService tagService = context.GetService <TagService>(); TagDto tag = new TagDto() { Name = "TestTag", ShortDescDe = "ShortDescDe", ShortDescEn = "ShortDescEn", }; //Act int id = await tagService.InsertTagAsync(tag); TagDto tagDto = await tagService.GetTagAsync(id); //Assert Assert.True(id > 0); Assert.Equal(TagType.Standard, (TagType)tagDto.IdTagType); }
private IQuestionService InitQuestionService(TestingContext context) { InitContext(context); IQuestionService questionService = context.GetService <QuestionService>(); return(questionService); }
public async Task TestVersionQuestion() { //Prepare TestingContext testingContext = new TestingContext(); SetUpTestingContext(testingContext); ApplicationDbContext dbContext = testingContext.GetSimple <ApplicationDbContext>(); Question question = dbContext.Questions.First(); testingContext.AddPrincipalMock(question.User.UserId, Roles.User); testingContext.AddBusinessSecurityService(); IQuestionService questionService = testingContext.GetService <QuestionService>(); testingContext.DependencyMap[typeof(IQuestionService)] = questionService; Mock <INotificationService> notificationMock = new Mock <INotificationService>(MockBehavior.Loose); notificationMock.Setup(x => x.SendNotificationAboutQuestionAsync(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(Task.CompletedTask); testingContext.DependencyMap[typeof(INotificationService)] = notificationMock.Object; IVersionService versionService = testingContext.GetService <VersionService>(); //Act int newId = await versionService.VersionQuestionAsync(question.Id); //Assert Assert.True(question.Id != newId); Assert.True(newId > 0); await versionService.AcceptQuestionAsync(newId); //Assert QuestionDto oldDto = await questionService.GetQuestionAsync(question.Id); QuestionDto newDto = await questionService.GetQuestionAsync(newId); Assert.Contains(oldDto.Tags, x => x.Name == "Deprecated"); Assert.Equal(QuestionStatus.Released, (QuestionStatus)newDto.Status); Assert.Equal(QuestionStatus.Obsolete, (QuestionStatus)oldDto.Status); question = await dbContext.FindAsync <Question>(newId); Assert.NotNull(question.ApprovalDate); notificationMock.Verify(x => x.SendNotificationAboutQuestionAsync(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once()); }
public async Task GetSpecialTag(SpecialTag specialTag) { TestingContext testingContext = new TestingContext(); SetupContext(testingContext); ITagService tagService = testingContext.GetService <TagService>(); TagDto tagDto = await tagService.GetSpecialTagAsync(specialTag); Assert.NotNull(tagDto); }
public async Task FindTagsAsync() { TestingContext testingContext = new TestingContext(); SetupContext(testingContext); ITagService tagService = testingContext.GetService <TagService>(); IList <TagDto> result = await tagService.FindTagsAsync("e"); Assert.Equal(4, result.Count); Assert.All(result, tagDto => Assert.True(tagDto.IdTagType == (int)TagType.Standard)); }
private void InitContext(TestingContext testingContext) { testingContext.AddPrincipalMock(); testingContext.AddInMemoryDb(); testingContext.AddUserService(); testingContext.AddBusinessSecurityService(); testingContext.AddLogServiceMock(); testingContext.AddGermanCultureServiceMock(); testingContext.AddBinaryServiceMock(); testingContext.AddQuestionService(); testingContext.DependencyMap[typeof(IBinaryService)] = testingContext.GetService <BinaryService>(); }
public async Task TestImage() { //Perpare TestingContext context = new TestingContext(); InitContext(context); context.DependencyMap[typeof(IBinaryService)] = context.GetService <BinaryService>(); IQuestionService questionService = InitQuestionService(context); //Add Q QuestionDto qdto = new QuestionDto() { Title = "Bla", Explanation = "bla", Language = "De", }; int newId = await questionService.InsertQuestionAsync(qdto); //Add Binary IBinaryService binaryService = context.GetSimple <IBinaryService>(); int id = await binaryService.AddBinaryAsync(new BinaryDto { ContentDisposition = "ContentDisposition", ContentType = "ContentType", FileName = "FileName", Name = "Name", Length = 2334, }); ImageDto imageDto = new ImageDto() { IdBinary = id, Full = false, Height = 124, Width = 64, }; imageDto = await questionService.AddImageAsync(imageDto); QuestionDto questionDto = await questionService.GetQuestionAsync(newId); questionDto.Images.Add(imageDto); await questionService.UpdateQuestionAsync(questionDto); questionDto = await questionService.GetQuestionAsync(newId); Assert.True(questionDto.Images.Count == 1); }
private void SetUpTestingContext(TestingContext testingContext) { testingContext.AddPrincipalMock(); testingContext.AddInMemoryDb(); testingContext.AddUserService(); testingContext.AddBusinessSecurityService(); testingContext.AddLogServiceMock(); testingContext.AddGermanCultureServiceMock(); testingContext.AddBinaryServiceMock(); testingContext.AddInfoTextServiceMock(); testingContext.AddCacheService(); testingContext.DependencyMap[typeof(ICommentsService)] = testingContext.GetService <CommentsService>(); testingContext.DependencyMap[typeof(ITagService)] = testingContext.GetService <TagService>(); Mock <INotificationService> notificationMock = new Mock <INotificationService>(MockBehavior.Loose); notificationMock.Setup(x => x.SendNotificationAboutQuestionAsync(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(Task.CompletedTask); testingContext.DependencyMap[typeof(INotificationService)] = notificationMock.Object; }
public async Task TestVersionQuestion() { //Prepare TestingContext context = new TestingContext(); InitContext(context); ApplicationDbContext dbContext = context.GetSimple <ApplicationDbContext>(); Question question = dbContext.Questions.First(); context.AddPrincipalMock(question.User.UserId, Roles.User); IQuestionService questionService = context.GetService <QuestionService>(); context.DependencyMap[typeof(IQuestionService)] = questionService; IVersionService versionService = context.GetService <VersionService>(); //Act int newId = await versionService.VersionQuestionAsync(question.Id); //Assert Assert.True(question.Id != newId); Assert.True(newId > 0); await versionService.AcceptQuestionAsync(newId); //Assert QuestionDto oldDto = await questionService.GetQuestionAsync(question.Id); QuestionDto newDto = await questionService.GetQuestionAsync(newId); Assert.Contains(oldDto.Tags, x => x.Name == "Deprecated"); Assert.Equal(QuestionStatus.Released, (QuestionStatus)newDto.Status); Assert.Equal(QuestionStatus.Obsolete, (QuestionStatus)oldDto.Status); question = await dbContext.FindAsync <Question>(newId); Assert.NotNull(question.ApprovalDate); }
public async Task TestNotEnoughQuestion() { //Prepare TestingContext testingContext = new TestingContext(); InitTestingContext(testingContext); CourseService courseService = testingContext.GetService <CourseService>(); testingContext.DependencyMap[typeof(ICourseService)] = courseService; ApplicationDbContext dbContext = testingContext.GetSimple <ApplicationDbContext>(); Course course = dbContext.Courses.First(); course.NumQuestionsToAsk = 100; ICourseInstanceService courseInstanceService = testingContext.GetService <CourseInstanceService>(); //Act var courseInstance = await courseInstanceService.StartCourseAsync(course.Id); //Assert Assert.Equal(10, courseInstance.NumQuestionsTotal); }
public async void TestPaging() { TestingContext testingContext = new TestingContext(); testingContext.AddAdminPrincipalMock(); testingContext.AddInMemoryDb(); testingContext.AddLogServiceMock(); testingContext.AddEnglishCultureServiceMock(); ApplicationDbContext dbContext = testingContext.GetSimple <ApplicationDbContext>(); for (int i = 0; i < 13; i++) { dbContext.Texts.Add(new Text() { Key = $"TestKey{i}", ContentDe = $"ContentDe", ContentEn = $"ContentEn", }); } await dbContext.SaveChangesAsync(); ITextService textService = testingContext.GetService <TextService>(); //Act SearchTextDto dto = new SearchTextDto(); dto.Page = 0; PagedResultDto <TextDto> res = await textService.GetTextsAsync(dto); //Assert Assert.Equal(13, res.Count); Assert.Equal(5, res.Pagesize); Assert.Equal(5, res.Data.Count); Assert.Equal(3, res.Numpages); //Act dto = new SearchTextDto(); dto.Page = 2; res = await textService.GetTextsAsync(dto); //Assert Assert.Equal(13, res.Count); Assert.Equal(5, res.Pagesize); Assert.Equal(3, res.Data.Count); Assert.Equal(3, res.Numpages); }
public async Task SaveBinaryTest() { TestingContext testingContext = new TestingContext(); testingContext.AddAdminPrincipalMock(); testingContext.AddLogServiceMock(); testingContext.AddRealDb(); testingContext.AddUserService(); IBinaryService service = testingContext.GetService <BinaryService>(); string testWord = "Hello World"; var bytes = System.Text.Encoding.UTF8.GetBytes(testWord); MemoryStream stream = new MemoryStream(); stream.Write(bytes, 0, bytes.Length); stream.Flush(); stream.Seek(0, SeekOrigin.Begin); BinaryDto binaryDto = new BinaryDto { ContentDisposition = "ContentDisposition", ContentType = "ContentType", FileName = "FileName", Name = "Name", Length = 2334, }; int id = await service.AddBinaryAsync(binaryDto); //Act await service.SaveAsync(id, stream); //Assert Stream streamToAssert = await service.GetBinaryAsync(id); StreamReader reader = new StreamReader(streamToAssert); string text = reader.ReadToEnd(); Assert.Equal(testWord, text); //Cleanup await service.DeleteBinaryAsync(id); }
public async Task TestGetAllSubscriptionsAsync() { //Setup TestingContext testingContext = new TestingContext(); SetUpTestingContext(testingContext); await AddSampleSubscriptions(testingContext, null); INotificationService notificationService = testingContext.GetService <NotificationService>(); //Act PagedResultDto <SubscriptionShortDto> result = await notificationService.GetAllSubscriptionsAsync(0); //Assert Assert.Equal(1, result.Count); Assert.Equal("testendpoint", result.Data[0].Endpoint); }
public async Task DeleteTagNoRights() { TestingContext testingContext = new TestingContext(); SetupContext(testingContext); ITagService tagService = testingContext.GetService <TagService>(); ApplicationDbContext dbContext = testingContext.GetSimple <ApplicationDbContext>(); int firstTagId = dbContext.Tags.First().Id; //Act and Assert Exception ex = await Assert.ThrowsAsync <SecurityException>(async() => { await tagService.DeleteTagAsync(firstTagId); }); }
public async Task GetTags() { //Prepare TestingContext testingContext = new TestingContext(); SetupContext(testingContext); ApplicationDbContext dbContext = testingContext.GetSimple <ApplicationDbContext>(); ITagService tagService = testingContext.GetService <TagService>(); IList <int> tagIds = dbContext.Tags.Select(x => x.Id).Take(3).ToList(); //Act IList <TagDto> tags = await tagService.GetTagsAsync(tagIds); //Assert Assert.Equal(3, tags.Count); }
public async Task TestSendNotificationAsync() { //Setup TestingContext testingContext = new TestingContext(); SetUpTestingContext(testingContext); await AddSampleSubscriptions(testingContext, null); Mock <IWebPushClient> webPushClientMock = new Mock <IWebPushClient>(MockBehavior.Loose); string messageSent = string.Empty; PushSubscription psSent = null; VapidDetails vapiDetSent = null; webPushClientMock.Setup(x => x.SendNotificationAsync(It.IsAny <PushSubscription>(), It.IsAny <string>(), It.IsAny <VapidDetails>())) .Callback <PushSubscription, string, VapidDetails>((ps, message, vapiDet) => { messageSent = message; psSent = ps; vapiDetSent = vapiDet; }) .Returns(Task.CompletedTask); testingContext.DependencyMap[typeof(IWebPushClient)] = webPushClientMock.Object; INotificationService notificationService = testingContext.GetService <NotificationService>(); NotificationDto dto = new NotificationDto(); dto.SubscriptionId = testingContext.GetSimple <ApplicationDbContext>().Notifications.First().Id; dto.Text = "TestText"; dto.Title = "TestTitle"; //Act await notificationService.SendNotificationToUserAsync(dto); //Assert webPushClientMock.Verify(x => x.SendNotificationAsync(It.IsAny <PushSubscription>(), It.IsAny <string>(), It.IsAny <VapidDetails>()), Times.Once()); Assert.Matches("TestText", messageSent); }
public async Task TestAddComment() { TestingContext testingContext = new TestingContext(); SetUpTestingContext(testingContext); ApplicationDbContext appDbContext = testingContext.GetSimple <ApplicationDbContext>(); ICommentsService commentsService = testingContext.GetService <CommentsService>(); Question question = appDbContext.Questions.First(); CommentDto commentDto = new CommentDto() { IdQuestion = question.Id, CommentText = "Hello Comment", }; //Act int newId = await commentsService.AddCommentAsync(commentDto); Assert.True(newId > 0); }
public async Task DeleteTagOk() { //Prepare TestingContext testingContext = new TestingContext(); SetupContext(testingContext); testingContext.AddAdminPrincipalMock(); ITagService tagService = testingContext.GetService <TagService>(); ApplicationDbContext dbContext = testingContext.GetSimple <ApplicationDbContext>(); int firstTagId = dbContext.Tags.First().Id; //Act await tagService.DeleteTagAsync(firstTagId); //Assert Exception ex = await Assert.ThrowsAsync <EntityNotFoundException>(async() => { TagDto dto = await tagService.GetTagAsync(firstTagId); }); }
public async Task TestSendNotificationAboutQuestionAsync() { TestingContext testingContext = new TestingContext(); SetUpTestingContext(testingContext); ApplicationDbContext dbContext = testingContext.GetSimple <ApplicationDbContext>(); Question first = await dbContext.Questions.LastAsync(); await AddSampleSubscriptions(testingContext, first.User); string messageSent = string.Empty; PushSubscription psSent = null; VapidDetails vapiDetSent = null; Mock <IWebPushClient> webPushClientMock = new Mock <IWebPushClient>(MockBehavior.Loose); webPushClientMock.Setup(x => x.SendNotificationAsync(It.IsAny <PushSubscription>(), It.IsAny <string>(), It.IsAny <VapidDetails>())) .Callback <PushSubscription, string, VapidDetails>((ps, message, vapiDet) => { messageSent = message; psSent = ps; vapiDetSent = vapiDet; }) .Returns(Task.CompletedTask); testingContext.DependencyMap[typeof(IWebPushClient)] = webPushClientMock.Object; INotificationService notificationService = testingContext.GetService <NotificationService>(); // Act await notificationService.SendNotificationAboutQuestionAsync(first.Id, "MessageAkzeptiert", "Some"); //Assert webPushClientMock.Verify(x => x.SendNotificationAsync(It.IsAny <PushSubscription>(), It.IsAny <string>(), It.IsAny <VapidDetails>()), Times.Once()); }
public async Task GetEntryAsync() { TestingContext testingContext = new TestingContext(); ICacheService cacheService = testingContext.GetService <CacheService>(); Func <Task <TagDto> > getTagFunc = () => { TagDto result = new TagDto { Id = 3, Name = "Test", }; return(Task.FromResult(result)); }; TagDto myTag = await cacheService.GetEntryAsync("MyKey", getTagFunc); Assert.Equal(3, myTag.Id); TagDto myTag2 = await cacheService.GetEntryAsync("MyKey", getTagFunc); Assert.True(ReferenceEquals(myTag, myTag2)); }
public async Task TestStartTest() { TestingContext testingContext = new TestingContext(); InitTestingContext(testingContext); ICourseService courseService = testingContext.GetService <CourseService>(); testingContext.DependencyMap[typeof(ICourseService)] = courseService; ICourseInstanceService courseInstanceService = testingContext.GetService <CourseInstanceService>(); var courses = await courseService.GetCoursesAsync(0); int courseId = courses.Data.Select(x => x.Id).First(); //Act CourseInstanceDto result = await courseInstanceService.StartCourseAsync(courseId); Assert.True(result.IdCourseInstance > 0); Assert.True(result.IdCourse == courseId); Assert.True(result.IdCourseInstanceQuestion > 0); Assert.True(result.NumQuestionsAlreadyAsked == 0); Assert.True(result.NumQuestionsTotal > 0); CourseInstanceDto result2 = await courseInstanceService.NextQuestion(result.IdCourseInstance); Assert.True(result2.IdCourse == courseId); Assert.True(result2.IdCourseInstanceQuestion > 0); Assert.True(result2.NumQuestionsAlreadyAsked == 1); Assert.True(result2.NumQuestionsTotal > 0); CourseInstanceDto result3 = await courseInstanceService.NextQuestion(result.IdCourseInstance); Assert.True(result3.IdCourse == courseId); Assert.True(result3.IdCourseInstanceQuestion > 0); Assert.True(result3.NumQuestionsAlreadyAsked == 2); Assert.True(result3.NumQuestionsTotal > 0); QuestionToAskDto result4 = await courseInstanceService.GetQuestionToAskAsync(result.IdCourseInstanceQuestion); Assert.Equal(QuestionType.MultipleChoice, result4.QuestionType); QuestionAnswerDto answer = new QuestionAnswerDto(); answer.IdCourseInstanceQuestion = result.IdCourseInstanceQuestion; answer.Answers.Add(false); answer.Answers.Add(true); answer.Answers.Add(false); answer.Answers.Add(true); QuestionDto result5 = await courseInstanceService.AnswerQuestionAndGetSolutionAsync(answer); Assert.True(result5.Explanation != null); Assert.Equal(4, result5.Options.Count); Assert.True(result5.Options[1].IsTrue); Assert.True(result5.Options[3].IsTrue); CourseInstanceDto result6 = await courseInstanceService.AnswerQuestionAndGetNextQuestionAsync(answer); Assert.True(result6.AnsweredCorrectly); Assert.True(result6.Done); Assert.Equal(3, result6.NumQuestionsAlreadyAsked); Assert.Equal(3, result6.NumQuestionsTotal); }