public void WhenInstantiatingClassWithDefaultConstructor_Edit_Succeeds()
        {
            // Arrange
            RichContentEditViewModel model;

            // Act
            model = new RichContentEditViewModel();

            // Assert
            Assert.NotNull(model);
        }
        public void WhenPassedAValidViewModel_ThenPersists()
        {
            // Arrange
            const string PageId = "1";
            var contentRepositoryMock = new Mock<IContentBlobRepository>();
            contentRepositoryMock.Setup(repo => repo.GetById(It.IsAny<int>())).Returns(
                DefaultModelHelper.DummyPopulatedContentBlob);
            var contentBlobService = new ContentBlobService(
                contentRepositoryMock.Object, new Mock<IUnitOfWork>().Object);
            var controller = new RichContentController(contentBlobService);
            var viewModel = new RichContentEditViewModel { Html = "EditedHtml", ContentBlobId = 1, PartId = 1 };

            // Act
            var viewResult = controller.EditMode(PageId, "", "", viewModel) as PartialViewResult;

            // Assert
            Assert.NotNull(viewResult);
            Assert.Equal(string.Empty, viewResult.ViewName);
            Assert.True(viewResult.ViewData.ModelState.IsValid);
            Assert.True(controller.ModelState.IsValid);
        }
        public ActionResult EditMode(string id, string partId, string zoneId, RichContentEditViewModel viewModel)
        {
            try
            {
                RichContentServiceBinder modelBinder = this.GetServiceBinder();

                if (viewModel.Html == null)
                {
                    viewModel = modelBinder.EditViewModelBind(id, partId, zoneId);
                }

                viewModel = viewModel.ContentBlobId != -1 ? modelBinder.EditViewModelUpdate(partId, viewModel) : modelBinder.EditViewModelAdd(partId, viewModel);

            }
            catch (Exception ex)
            {
                this.LoggingService.Log(ex.Message);
            }

            return PartialView(viewModel);
        }