public async void DeleteAssigment_CalledWithinvalidId_ReturnsNotFoundWithId()
        {
            IUnitOfWork    _unitOfWork    = Substitute.For <IUnitOfWork>();
            ICookieManager _cookieManager = Substitute.For <ICookieManager>();
            var            context        = Substitute.For <HttpContext>();

            long      testId        = default;
            Assigment nullAssigment = null;

            _cookieManager.GetRoleFromToken(Arg.Any <string>()).Returns(Role.Admin.ToString());
            _unitOfWork.Assigments.GetById(Arg.Any <long>()).Returns(nullAssigment);

            var assigmentsController = new AssigmentsController(_unitOfWork, _cookieManager);

            assigmentsController.ControllerContext = new ControllerContext()
            {
                HttpContext = context
            };

            var result = await assigmentsController.DeleteAssigment(testId);

            var notFoundObjetResult = Assert.IsType <NotFoundObjectResult>(result);
            var returnValue         = Assert.IsType <long>(notFoundObjetResult.Value);

            Assert.Equal(testId, returnValue);
        }
        public async void DeleteAssigment_CalledAndRoleIsNotAdmin_ReturnsBadRequestWithError()
        {
            IUnitOfWork    _unitOfWork    = Substitute.For <IUnitOfWork>();
            ICookieManager _cookieManager = Substitute.For <ICookieManager>();
            var            context        = Substitute.For <HttpContext>();

            long   testId        = 1;
            var    testAssigment = new Assigment();
            string error         = "Only Admins can delete assigments.";

            _cookieManager.GetRoleFromToken(Arg.Any <string>()).Returns(Role.Student.ToString());
            _unitOfWork.Assigments.GetById(Arg.Any <long>()).Returns(testAssigment);

            var assigmentsController = new AssigmentsController(_unitOfWork, _cookieManager);

            assigmentsController.ControllerContext = new ControllerContext()
            {
                HttpContext = context
            };

            var result = await assigmentsController.DeleteAssigment(testId);

            var badRequestObjectResult = Assert.IsType <BadRequestObjectResult>(result);
            var returnValue            = Assert.IsType <string>(badRequestObjectResult.Value);

            Assert.Equal(error, returnValue);
        }
        public async void DeleteAssigment_CalledWithValidId_ReturnsOk()
        {
            IUnitOfWork    _unitOfWork    = Substitute.For <IUnitOfWork>();
            ICookieManager _cookieManager = Substitute.For <ICookieManager>();
            var            context        = Substitute.For <HttpContext>();

            long testId        = 1;
            var  testAssgiment = new Assigment();

            _cookieManager.GetRoleFromToken(Arg.Any <string>()).Returns(Role.Admin.ToString());
            _unitOfWork.Assigments.GetById(Arg.Any <long>()).Returns(testAssgiment);

            var assigmentsController = new AssigmentsController(_unitOfWork, _cookieManager);

            assigmentsController.ControllerContext = new ControllerContext()
            {
                HttpContext = context
            };

            var result = await assigmentsController.DeleteAssigment(testId);

            var okResult = Assert.IsType <OkResult>(result);

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