Exemple #1
0
        public ActionResult Edit(TranslationModel model)
        {
            if (model.IsValid())
            {

            }

            return View(model);
        }
Exemple #2
0
        public ActionResult Edit(TranslationModel model)
        {
            if (model.IsValid())
            {

                return RedirectToAction("Index", "Tag");
            }

            return View(model);
        }
        public void edit_should_return_translation_model()
        {
            // Arrange
            var demoService = new Mock<IDemoDataService>();

            var translated = new TranslationModel { Key = "my-key" };
            demoService.Setup(x => x.GetATranslation()).Returns(translated);

            // Act
            var controller = new KeyController(null, demoService.Object);
            var view = controller.Edit("id",ConstHelper.tr);

            // Assert
            Assert.NotNull(view);

            var model = view.Model as TranslationModel;

            Assert.NotNull(model);

            demoService.Verify(x => x.GetATranslation(), Times.Once);
            Assert.IsTrue(controller.HasPostAttribute("Edit", new[] { typeof(TranslationModel) }), "HttpPost attribute not found or ValidateAntiForgeryToken attribute not added on KeyController's Edit() action method");
        }