public void Edit_GET_Should_Load_Settings_From_Repository()
        {
            // Arrange
            TextPluginStub plugin = new TextPluginStub();

            plugin.Repository  = _repository;
            plugin.PluginCache = _siteCache;
            plugin.Settings.SetValue("name1", "default-value1");
            plugin.Settings.SetValue("name2", "default-value2");

            RepositoryMock repositoryMock = new RepositoryMock();

            repositoryMock.SaveTextPluginSettings(plugin);
            repositoryMock.TextPlugins[0].Settings.SetValue("name1", "value1");
            repositoryMock.TextPlugins[0].Settings.SetValue("name2", "value2");

            _pluginFactory.RegisterTextPlugin(plugin);

            // Act
            ViewResult result = _controller.Edit(plugin.Id) as ViewResult;

            // Assert
            PluginViewModel model = result.ModelFromActionResult <PluginViewModel>();

            Assert.That(model.SettingValues[0].Value, Is.EqualTo("value1"));
            Assert.That(model.SettingValues[1].Value, Is.EqualTo("value2"));
        }
        public void Edit_GET_Should_Load_Settings_From_Repository()
        {
            // Arrange
            TextPluginStub plugin = new TextPluginStub();
            plugin.Repository = _repository;
            plugin.PluginCache = _siteCache;
            plugin.Settings.SetValue("name1", "default-value1");
            plugin.Settings.SetValue("name2", "default-value2");

            RepositoryMock repositoryMock = new RepositoryMock();
            repositoryMock.SaveTextPluginSettings(plugin);
            repositoryMock.TextPlugins[0].Settings.SetValue("name1", "value1");
            repositoryMock.TextPlugins[0].Settings.SetValue("name2", "value2");

            _pluginFactory.RegisterTextPlugin(plugin);

            // Act
            ViewResult result = _controller.Edit(plugin.Id) as ViewResult;

            // Assert
            PluginViewModel model = result.ModelFromActionResult<PluginViewModel>();
            Assert.That(model.SettingValues[0].Value, Is.EqualTo("value1"));
            Assert.That(model.SettingValues[1].Value, Is.EqualTo("value2"));
        }
        public void Edit_GET_Should_Return_ViewResult_And_Model_With_Known_Values()
        {
            // Arrange
            TextPluginStub plugin = new TextPluginStub();

            plugin.Repository  = _repository;
            plugin.PluginCache = _siteCache;

            _repository.SaveTextPluginSettings(plugin);
            _pluginFactory.RegisterTextPlugin(plugin);

            // Act
            ViewResult result = _controller.Edit(plugin.Id) as ViewResult;

            // Assert
            Assert.That(result, Is.Not.Null);
            PluginViewModel model = result.ModelFromActionResult <PluginViewModel>();

            Assert.NotNull(model, "Null model");

            Assert.That(model.Id, Is.EqualTo(plugin.Id));
            Assert.That(model.Name, Is.EqualTo(plugin.Name));
            Assert.That(model.Description, Is.EqualTo(plugin.Description));
        }