public async Task UpdateQuestion_NoAccess() { Context .Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(ModelsCreationHelper.CreateAdmin); await Assert.ThrowsAsync <EducationSystemPublicException> (() => ServiceQuestion.UpdateQuestionAsync(999, new Question())); Context .Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(ModelsCreationHelper.CreateStudent); await Assert.ThrowsAsync <EducationSystemPublicException> (() => ServiceQuestion.UpdateQuestionAsync(999, new Question())); Context .Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(ModelsCreationHelper.CreateLecturer); RepositoryQuestion .Setup(x => x.FindFirstAsync(It.IsAny <ISpecification <DatabaseQuestion> >())) .ReturnsAsync(ModelsCreationHelper.CreateDatabaseQuestion(lecturerId: 1)); await Assert.ThrowsAsync <EducationSystemPublicException> (() => ServiceQuestion.UpdateQuestionAsync(999, new Question())); }
public async Task UpdateQuestion() { Context .Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(ModelsCreationHelper.CreateLecturer); RepositoryQuestion .Setup(x => x.FindFirstAsync(It.IsAny <ISpecification <DatabaseQuestion> >())) .ReturnsAsync(ModelsCreationHelper.CreateDatabaseQuestion()); await ServiceQuestion.UpdateQuestionAsync(999, new Question()); }