public void ExecuteRecipeStepTest()
        {
            _folders.Manifests.Add("SuperWiki", @"
Name: SuperWiki
Version: 1.0.3
OrchardVersion: 1
Features:
    SuperWiki: 
        Description: My super wiki theme for Orchard.
");
            _packagesInRepository.AddPublishedPackage(new PublishedPackage {
                Id              = "Orchard.Theme.SuperWiki",
                PackageType     = DefaultExtensionTypes.Theme,
                Title           = "SuperWiki",
                Version         = "1.0.3",
                IsLatestVersion = true,
            });

            IShellDescriptorManager shellDescriptorManager = _container.Resolve <IShellDescriptorManager>();

            // No features enabled
            shellDescriptorManager.UpdateShellDescriptor(0,
                                                         Enumerable.Empty <ShellFeature>(),
                                                         Enumerable.Empty <ShellParameter>());

            ThemeRecipeHandler themeRecipeHandler = _container.Resolve <ThemeRecipeHandler>();

            RecipeContext recipeContext = new RecipeContext {
                RecipeStep = new RecipeStep {
                    Name = "Theme", Step = new XElement("SuperWiki")
                }
            };

            recipeContext.RecipeStep.Step.Add(new XAttribute("packageId", "Orchard.Theme.SuperWiki"));
            recipeContext.RecipeStep.Step.Add(new XAttribute("repository", "test"));

            IFeatureManager featureManager = _container.Resolve <IFeatureManager>();
            IEnumerable <FeatureDescriptor> enabledFeatures = featureManager.GetEnabledFeatures();

            Assert.That(enabledFeatures.Count(), Is.EqualTo(0));
            themeRecipeHandler.ExecuteRecipeStep(recipeContext);

            // without setting enable no feature should be activated...
            featureManager.GetEnabledFeatures();
            Assert.That(enabledFeatures.Count(), Is.EqualTo(0));

            // Adding enable the feature should get active
            recipeContext.RecipeStep.Step.Add(new XAttribute("enable", true));
            themeRecipeHandler.ExecuteRecipeStep(recipeContext);

            enabledFeatures = featureManager.GetEnabledFeatures();
            Assert.That(enabledFeatures.FirstOrDefault(feature => feature.Id.Equals("SuperWiki")), Is.Not.Null);
            Assert.That(enabledFeatures.Count(), Is.EqualTo(1));
            Assert.That(recipeContext.Executed, Is.True);
        }
        public void ExecuteRecipeStepNeedsNameTest()
        {
            _folders.Manifests.Add("SuperWiki", @"
Name: SuperWiki
Version: 1.0.3
OrchardVersion: 1
Features:
    SuperWiki: 
        Description: My super wiki module for Orchard.
");

            ThemeRecipeHandler themeRecipeHandler = _container.Resolve <ThemeRecipeHandler>();

            RecipeContext recipeContext = new RecipeContext {
                RecipeStep = new RecipeStep {
                    Name = "Theme", Step = new XElement("SuperWiki")
                }
            };

            recipeContext.RecipeStep.Step.Add(new XAttribute("repository", "test"));

            Assert.Throws(typeof(InvalidOperationException), () => themeRecipeHandler.ExecuteRecipeStep(recipeContext));
        }
        public void ExecuteRecipeStepWithRepositoryAndVersionNotLatestTest()
        {
            _packagesInRepository.AddPublishedPackage(new PublishedPackage {
                Id              = "Orchard.Theme.SuperWiki",
                PackageType     = DefaultExtensionTypes.Theme,
                Title           = "SuperWiki",
                Version         = "1.0.3",
                IsLatestVersion = true,
            });
            _packagesInRepository.AddPublishedPackage(new PublishedPackage {
                Id              = "Orchard.Theme.SuperWiki",
                PackageType     = DefaultExtensionTypes.Theme,
                Title           = "SuperWiki",
                Version         = "1.0.2",
                IsLatestVersion = false,
            });

            ThemeRecipeHandler themeRecipeHandler = _container.Resolve <ThemeRecipeHandler>();

            RecipeContext recipeContext = new RecipeContext {
                RecipeStep = new RecipeStep {
                    Name = "Theme", Step = new XElement("SuperWiki")
                }
            };

            recipeContext.RecipeStep.Step.Add(new XAttribute("packageId", "Orchard.Theme.SuperWiki"));
            recipeContext.RecipeStep.Step.Add(new XAttribute("repository", "test"));
            recipeContext.RecipeStep.Step.Add(new XAttribute("version", "1.0.2"));

            themeRecipeHandler.ExecuteRecipeStep(recipeContext);

            var installedPackage = _packageManager.GetInstalledPackages().FirstOrDefault(info => info.ExtensionName == "Orchard.Theme.SuperWiki");

            Assert.That(installedPackage, Is.Not.Null);
            Assert.That(installedPackage.ExtensionVersion, Is.EqualTo("1.0.2"));
            Assert.That(recipeContext.Executed, Is.True);
        }