/// <summary>
        /// Starts the process of editing the provided entity.
        /// </summary>
        /// <param name="entity"></param>
        public virtual void Edit(IEntity entity)
        {
            using (LogGroup logGroup = LogGroup.Start("Starting an edit action.", NLog.LogLevel.Debug))
            {
                if (EditController == null)
                {
                    throw new InvalidOperationException("Controller has not be initialized. Call FormPage.Initialize().");
                }

                DataSource = entity;

                EditController.Edit(entity);

                DataBind();
            }
        }
        public void EditTest002()
        {
            var editViewModel = new EditViewModel()
            {
                Id = "1", Title = "たいとる更新(テスト)", Content = "ほんぶん更新(てすと)"
            };

            mockService.Setup(x => x.UpdateDiary(editViewModel)).Returns(true);

            var controller = new EditController(mockService.Object);

            controller.TempData = tempData;
            controller.ModelState.AddModelError("key", "ERROR");
            var result = controller.Edit(editViewModel);
            var model  = Assert.IsType <ViewResult>(result);

            Assert.Equal("Index", model.ViewName);
            controller.Dispose();
        }
        public void EditTest003()
        {
            var editViewModel = new EditViewModel()
            {
                Id = "2", Title = "たいとる更新(テスト)", Content = "ほんぶん更新(てすと)"
            };

            mockService.Setup(x => x.UpdateDiary(editViewModel)).Returns(false);
            var controller = new EditController(mockService.Object);

            controller.TempData = tempData;

            var result = controller.Edit(editViewModel);

            var model = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal("Index", model.ActionName);
            Assert.Equal("Menu", model.ControllerName);
            Assert.Equal("更新できませんでした。", controller.TempData["notification"]);

            controller.Dispose();
        }
Exemplo n.º 4
0
 private void NewProfile()
 {
     profile = new DepersonalizerProfile();
     controller.Edit(profile);
 }