public async Task UpdateTest_NoAccess() { Context .Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(ModelsCreationHelper.CreateAdmin); await Assert.ThrowsAsync <EducationSystemPublicException> (() => ServiceTest.UpdateTestAsync(999, new Test())); Context .Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(ModelsCreationHelper.CreateStudent); await Assert.ThrowsAsync <EducationSystemPublicException> (() => ServiceTest.UpdateTestAsync(999, new Test())); Context .Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(ModelsCreationHelper.CreateLecturer); RepositoryTest .Setup(x => x.FindFirstAsync(It.IsAny <ISpecification <DatabaseTest> >())) .ReturnsAsync(ModelsCreationHelper.CreateDatabaseTest(lecturerId: 1)); await Assert.ThrowsAsync <EducationSystemPublicException> (() => ServiceTest.UpdateTestAsync(999, new Test())); }
public async Task UpdateTest() { Context .Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(ModelsCreationHelper.CreateLecturer); RepositoryTest .Setup(x => x.FindFirstAsync(It.IsAny <ISpecification <DatabaseTest> >())) .ReturnsAsync(ModelsCreationHelper.CreateDatabaseTest()); await ServiceTest.UpdateTestAsync(999, new Test()); }
public async Task GetTest_Student_NoAccess() { Context .Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(ModelsCreationHelper.CreateStudent); RepositoryTest .Setup(x => x.FindFirstAsync(It.IsAny <ISpecification <DatabaseTest> >())) .ReturnsAsync(ModelsCreationHelper.CreateDatabaseTest(isActive: true, studentId: 1)); await Assert.ThrowsAsync <EducationSystemPublicException> (() => ServiceTest.GetTestAsync(999)); RepositoryTest .Setup(x => x.FindFirstAsync(It.IsAny <ISpecification <DatabaseTest> >())) .ReturnsAsync(ModelsCreationHelper.CreateDatabaseTest()); await Assert.ThrowsAsync <EducationSystemPublicException> (() => ServiceTest.GetTestAsync(999)); }