Ejemplo n.º 1
0
        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()));
        }
Ejemplo n.º 2
0
 public async Task <IActionResult> UpdateMaterial([FromRoute] int id, [FromBody] Material material)
 {
     return(await Ok(() => _serviceMaterial.UpdateMaterialAsync(id, material)));
 }