Ejemplo n.º 1
0
        public async Task GetTest_NotFound()
        {
            RepositoryTest
            .Setup(x => x.FindFirstAsync(It.IsAny <ISpecification <DatabaseTest> >()))
            .ReturnsAsync((DatabaseTest)null);

            Context
            .Setup(x => x.GetCurrentUserAsync())
            .ReturnsAsync(ModelsCreationHelper.CreateAdmin);

            await Assert.ThrowsAsync <EducationSystemNotFoundException>
                (() => ServiceTest.GetTestAsync(999));

            Context
            .Setup(x => x.GetCurrentUserAsync())
            .ReturnsAsync(ModelsCreationHelper.CreateLecturer);

            await Assert.ThrowsAsync <EducationSystemNotFoundException>
                (() => ServiceTest.GetTestAsync(999));

            Context
            .Setup(x => x.GetCurrentUserAsync())
            .ReturnsAsync(ModelsCreationHelper.CreateStudent);

            await Assert.ThrowsAsync <EducationSystemNotFoundException>
                (() => ServiceTest.GetTestAsync(999));
        }
Ejemplo n.º 2
0
 public async Task <IActionResult> GetTest([FromRoute] int id)
 {
     return(await Ok(() => _serviceTest.GetTestAsync(id)));
 }