Exemple #1
0
        public void CreateJobOffer_ModelIsNotValid_RedirectToViewResult()
        {
            JobOffersController jobOffersController = new JobOffersController(context);
            JobOfferViewModel   jobOffer            = new JobOfferViewModel();

            jobOffersController.ModelState.AddModelError("testError", "testError");

            var response = jobOffersController.Create(jobOffer).GetAwaiter().GetResult();

            Assert.IsInstanceOfType(response, typeof(ViewResult));
        }
Exemple #2
0
        public void CreateJobOffer_ModelValid_RedirectToIndex()
        {
            JobOffersController jobOffersController = new JobOffersController(context);
            JobOfferViewModel   jobOffer            = new JobOfferViewModel()
            {
                Id = 4,
            };

            jobOffersController.ModelState.Clear();

            var result = jobOffersController.Create(jobOffer).GetAwaiter().GetResult();

            Assert.IsInstanceOfType(result, typeof(RedirectToActionResult));
            var redirectToActionResult = result as RedirectToActionResult;

            Assert.IsNull(redirectToActionResult.ControllerName);
            Assert.AreEqual("Index", redirectToActionResult.ActionName);
        }