Exemplo n.º 1
0
        public async Task Delete_returns_500_on_internal_error()
        {
            var id = Guid.NewGuid();

            repository.Setup(r => r.DeleteStudentAsync(id)).ThrowsAsync(new Exception());
            var controller = new StudentRepositoryController(repository.Object);

            var actual = await controller.Delete(id, true);

            var actionResult = Assert.IsType <ActionResult <bool> >(actual);
            var code         = Assert.IsType <StatusCodeResult>(actionResult.Result);

            Assert.Equal(500, code.StatusCode);
        }
Exemplo n.º 2
0
        public async Task Delete_returns_200_and_true()
        {
            var id = Guid.NewGuid();

            repository.Setup(r => r.DeleteStudentAsync(id)).ReturnsAsync(true);
            var controller = new StudentRepositoryController(repository.Object);

            var actual = await controller.Delete(id, true);

            var actionResult   = Assert.IsType <ActionResult <bool> >(actual);
            var okResult       = Assert.IsType <OkObjectResult>(actionResult.Result);
            var hasBeenDeleted = Assert.IsType <bool>(okResult.Value);

            Assert.Equal(200, okResult.StatusCode);
            Assert.True(hasBeenDeleted);
        }