Beispiel #1
0
        public async Task UnSave_returns_404_on_not_found()
        {
            var studentId     = id1;
            var descriptionId = 100;

            repository.Setup(r => r.UnSavePlacementDescription(studentId, descriptionId)).ThrowsAsync(new ArgumentException());
            var controller = new StudentRepositoryController(repository.Object);

            var actual = await controller.UnSave(studentId, descriptionId, true);

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

            Assert.Equal(404, code.StatusCode);
        }
Beispiel #2
0
        public async Task UnSave_returns_500_on_internal_server_error()
        {
            var studentId     = id1;
            var descriptionId = 1;

            repository.Setup(r => r.UnSavePlacementDescription(studentId, descriptionId)).ThrowsAsync(new Exception());
            var controller = new StudentRepositoryController(repository.Object);

            var actual = await controller.UnSave(studentId, descriptionId, true);

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

            Assert.Equal(500, code.StatusCode);
        }
Beispiel #3
0
        public async Task UnSave_returns_true_on_200()
        {
            var studentId     = id2;
            var descriptionId = 1;

            repository.Setup(r => r.UnSavePlacementDescription(studentId, descriptionId)).ReturnsAsync(true);
            var controller = new StudentRepositoryController(repository.Object);

            var actual = await controller.UnSave(studentId, descriptionId, true);

            var actionCodeResult = Assert.IsType <ActionResult <bool> >(actual);
            var code             = Assert.IsType <OkObjectResult>(actionCodeResult.Result);
            var hasBeenUnSaved   = Assert.IsType <bool>(code.Value);

            Assert.Equal(200, code.StatusCode);
            Assert.True(hasBeenUnSaved);
        }