public async Task UpdateMaterial_NoAccess() { Context .Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(ModelsCreationHelper.CreateAdmin); await Assert.ThrowsAsync <EducationSystemPublicException> (() => ServiceMaterial.UpdateMaterialAsync(999, new Material())); Context .Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(ModelsCreationHelper.CreateStudent); await Assert.ThrowsAsync <EducationSystemPublicException> (() => ServiceMaterial.UpdateMaterialAsync(999, new Material())); Context .Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(ModelsCreationHelper.CreateLecturer); RepositoryMaterial .Setup(x => x.FindFirstAsync(It.IsAny <ISpecification <DatabaseMaterial> >())) .ReturnsAsync(ModelsCreationHelper.CreateDatabaseMaterial(ownerId: 1)); await Assert.ThrowsAsync <EducationSystemPublicException> (() => ServiceMaterial.UpdateMaterialAsync(999, new Material())); }
public async Task <IActionResult> UpdateMaterial([FromRoute] int id, [FromBody] Material material) { return(await Ok(() => _serviceMaterial.UpdateMaterialAsync(id, material))); }