public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { Microsoft.Practices.RecipeFramework.GuidancePackage package = (Microsoft.Practices.RecipeFramework.GuidancePackage)provider.GetService(typeof(IExecutionService)); string basepath = @"c:\"; string temp = package.BasePath; if (Directory.Exists(temp)) { basepath = temp; temp = string.Format(CultureInfo.InvariantCulture, @"{0}\Templates", basepath); if (Directory.Exists(temp)) { basepath = temp; if (!string.IsNullOrEmpty(AdditionalSubPath)) { temp = string.Format(CultureInfo.InvariantCulture, @"{0}\{1}", basepath, AdditionalSubPath); if (Directory.Exists(temp)) { basepath = temp; } } } } initialDirectory = basepath; return(base.EditValue(context, provider, value)); }
public void EnableDisablePackage() { // Load the package from the config. GuidancePackage package = new GuidancePackage(new XmlTextReader(Utils.MakeTestRelativePath("RecipeTest.xml"))); Manager.EnablePackage(package); package.Disposed += new EventHandler(OnPackageDisposed); Manager.DisablePackage(package.Configuration.Name); Assert.IsTrue(Flags[0], "Package was not disposed"); }
public void WizardChangeMonitoring() { // Load the package from the config. GuidancePackage package = new GuidancePackage(Utils.MakeTestRelativePath("ValueProviderTests.xml")); EnablePackage(package); package.Execute(new MockObjects.MockReference("TestChangeNotification", "")); Assert.IsTrue(Flags[0]); Assert.AreEqual("A new value-B", Values["B"]); }
private void EnablePackage(GuidancePackage guidancePackage, bool UseMock) { Manager.EnablePackage(guidancePackage); if (UseMock) { guidancePackage.AddService(typeof(IValueGatheringService), new MockServices.MockArgumentGatheringService()); } else { guidancePackage.AddService(typeof(IValueGatheringService), new WizardFramework.WizardGatheringService()); } }
public void SuccessfullAction() { // Load the package from the config. GuidancePackage package = new GuidancePackage(new XmlTextReader(Utils.MakeTestRelativePath("ActionExecutionTests.xml"))); Manager.EnablePackage(package); package.Execute(new MockObjects.MockReference("SuccessfullAction", "")); // Check the "SuccessAction" action was executed. Assert.IsNotNull(Tracker.Executed[typeof(SuccessAction)]); }
public void EnableCancel() { // Load the package from the config. GuidancePackage package = new GuidancePackage(Utils.MakeTestRelativePath("RecipeTest.xml")); Manager.AddService(typeof(Services.IHostService), new TestHost(Manager, true, false, false)); Manager.EnablePackage(package); Assert.IsNull(Manager.GetPackage(package.Configuration.Name), "Host shouldn't have let package to get enabled"); }
public void ValueProviderLifeCycle() { // Load the package from the config. GuidancePackage package = new GuidancePackage(Utils.MakeTestRelativePath("ValueProviderTests.xml")); EnablePackage(package); package.Execute(new MockObjects.MockReference("TestLifeCycle", "")); Assert.IsTrue(Flags[0]); Assert.IsTrue(Flags[1]); }
public void CanReplaceExecutionService() { MockActionExecutionService exec = new MockActionExecutionService(); // Load the package from the config. GuidancePackage package = new GuidancePackage(Utils.MakeTestRelativePath("RecipeTest.xml")); EnablePackage(package); package.AddService(typeof(IActionExecutionService), exec); package.Execute(new MockObjects.MockReference("TestRecipe", "")); Assert.IsTrue(exec.ExecuteCalled, "Custom execution service was not called"); }
public void ExecuteHost() { // Load the package from the config. GuidancePackage package = new GuidancePackage(new XmlTextReader(Utils.MakeTestRelativePath("RecipeTest.xml"))); Manager.AddService(typeof(Services.IHostService), new TestHost(Manager, false, false, false)); Manager.EnablePackage(package); Assert.IsTrue(Flags[0], "Host was not called at package enabling time"); Manager.DisablePackage(package.Configuration.Name); Assert.IsTrue(Flags[1], "Host was not called at package disabling time"); }
/// <summary> /// Disables a package. /// </summary> /// <param name="packageName">Name of the package to disable.</param> /// <remarks> /// Disabling a package causes it to be disposed also. /// </remarks> public void DisablePackage(string packageName) { if (packageName == null) { throw new ArgumentNullException("packageName"); } GuidancePackage package = GetPackage(packageName); if (package != null) { package.AfterRecipeExecution -= new RecipeEventHandler(package_AfterRecipeExecution); Remove(package); } }
//[Ignore("Test display a dialog and waits for input, Daniel to fix it")] public void ValueEditorChangeMonitoring() { // Load the package from the config. GuidancePackage package = new GuidancePackage(Utils.MakeTestRelativePath("ValueProviderTests.xml")); EnablePackage(package); // Set a value for the FirstValueProvider class to pick. Values["FirstValueProvider"] = "Hi there"; Values["ConcatValueProvider"] = " from B"; package.Execute(new MockObjects.MockReference("ValueEditorChangeMonitoring", "")); Assert.IsTrue(Flags[0]); Assert.AreEqual("Bye Hi there from B", Values["ConcatValueProvider"]); }
public void TryChangeValueProviderAfter() { // Load the package from the config. GuidancePackage package = new GuidancePackage(new XmlTextReader( Utils.MakeTestRelativePath("Services\\ReadOnlyDictionaryServiceTests.xml"))); EnablePackage(package, true); try { package.Execute(new MockObjects.MockReference("TryChangeValueProviderAfter", "")); } catch (ValueProviderException aex) { throw aex.InnerException; } }
public void LoadPackage() { RecipeManager mgr = new RecipeManager(); // Setup dependent services. mgr.RemoveService(typeof(System.ComponentModel.Design.ITypeResolutionService)); mgr.AddService(typeof(System.ComponentModel.Design.ITypeResolutionService), new MockServices.MockTypeResolutionService()); mgr.AddService(typeof(Services.IPersistenceService), new MockServices.MockPersistenceService()); Configuration.GuidancePackage config = new Configuration.GuidancePackage(); config.Name = "Test package"; config.SchemaVersion = "1.0"; config.Caption = "Test package caption"; GuidancePackage package = new GuidancePackage(config); mgr.Add(package); }
public void SetUp() { Manager = new RecipeManager(); Manager.AddService(typeof(IPersistenceService), new MockPersistenceService()); Manager.AddService(typeof(EnvDTE._DTE), new MockServices.MockDte()); Manager.AddService(typeof(IValueGatheringService), new WizardFramework.WizardGatheringService()); Flags = new bool[10]; Configuration.GuidancePackage package = GuidancePackage.ReadConfiguration( Utils.MakeTestRelativePath("PackageManagementTest.xml")); Manager.AddService(typeof(IHostService), new TestHost(package.Host)); //// Install host //ManifestInstallerTest.InstallHost(package.Host, typeof(TestInstaller), false); //// Install package. //ManifestInstallerTest.InstallPackage( // Utils.MakeTestRelativePath("PackageManagementTest.xml"), false); }
/// <summary> /// Enables a package. /// </summary> /// <param name="configuration"> /// Configuration to use for the new package. /// </param> /// <returns> /// Returns the loaded and enabled package. /// </returns> public GuidancePackage EnablePackage(Configuration.GuidancePackage configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } GuidancePackage package = new GuidancePackage(configuration); try { package.AfterRecipeExecution += new RecipeEventHandler(package_AfterRecipeExecution); Add(package); } catch { package.Dispose(); throw; } return(package); }
public void FailAction() { // Load the package from the config. GuidancePackage package = new GuidancePackage(new XmlTextReader(Utils.MakeTestRelativePath("ActionExecutionTests.xml"))); Manager.EnablePackage(package); try { // Must fail. package.Execute(new MockObjects.MockReference("FailAction", "")); } catch { // We passed. return; } Assert.Fail("Execution should have failed."); }
public void FailedActionIsNotUndone() { // Load the package from the config. GuidancePackage package = new GuidancePackage(new XmlTextReader(Utils.MakeTestRelativePath("ActionExecutionTests.xml"))); Manager.EnablePackage(package); try { // Must fail. package.Execute("FailAction"); } catch (ActionExecutionException) { Assert.IsNull(Tracker.Undone[typeof(FailAction)]); // We passed. return; } Assert.Fail("Execution should have failed."); }
public void ExecuteNullWizardNoGathering() { // Load the package from the config. GuidancePackage package = new GuidancePackage(Utils.MakeTestRelativePath("RecipeTest.xml")); // Don't add the gathering service to the package. Manager.EnablePackage(package); Manager.AddService(typeof(IUIService), new MockServices.MockUIService()); try { ExecutionResult result = package.Execute(new MockObjects.MockReference("TestRecipe", "")); } catch (Exception e) { if (e.InnerException != null) { throw e.InnerException; } else { throw e; } } }
public TestConfigurationService(string basePath, Microsoft.Practices.RecipeFramework.GuidancePackage parentPackage) { this.basePath = basePath; this.parentPackage = parentPackage; }
private void EnablePackage(GuidancePackage package) { Manager.EnablePackage(package); //package.AddService(typeof(IValueGatheringService), new MockServices.MockArgumentGatheringService()); package.AddService(typeof(IValueGatheringService), new WizardFramework.WizardGatheringService()); }
/// <summary> /// Adds a package to the manager, enabling it for use. /// </summary> /// <param name="component">The package component.</param> /// <param name="name">Optional name (can be <see langword="null"/>) /// that must match the package name.</param> /// <remarks> /// This method is also called to add to the container services that /// inherit from <see cref="IComponent"/>, so the type of the component /// is not enforced. Just special logic is applied to package component types. /// </remarks> public override void Add(IComponent component, string name) { if (component == null) { throw new ArgumentNullException("component"); } if (component is GuidancePackage) { GuidancePackage package = (GuidancePackage)component; if (name != null && name != package.Configuration.Name) { throw new ArgumentException(String.Format( System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.RecipeManager_NameDoesntMatch, name, package.Configuration.Caption)); } // If there's a host listening, query for name to see if they match. IHostService host = GetService <IHostService>(); if (host != null && host.HostName != package.Configuration.Host) { throw new ArgumentException(String.Format( System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.RecipeManager_PackageHostMismatch, package.Configuration.Caption, package.Configuration.Host, host.HostName)); } try { // Force the package to be sited at Enabling event time also. base.Add(component, package.Configuration.Name); bool executebinding = true; if (EnablingPackage != null) { CancelPackageEventArgs args = new CancelPackageEventArgs( package, false); EnablingPackage(this, args); if (args.Cancel) { base.Remove(component); return; } executebinding = args.ExecuteBindingRecipe; } if (executebinding && package.Configuration.BindingRecipe != null && package.Configuration.BindingRecipe.Length > 0) { package.TurnOnOutput(); package.Execute(package.Configuration.BindingRecipe); package.TurnOffOutput(); } if (EnabledPackage != null) { EnabledPackage(this, new PackageEventArgs(package)); } } catch { // Notify host that we're disabling. if (DisablingPackage != null) { DisablingPackage(this, new CancelPackageEventArgs(package, false)); } // Don't let the package be enabled if an exception happened. base.Remove(component); if (DisabledPackage != null) { DisabledPackage(this, new PackageEventArgs(package)); } package.GetService <IPersistenceService>(true).ClearState(package.Configuration.Name); throw; } } else { // Just add the component so it gets sited. // Services that implement IComponent will arrive here. base.Add(component, name); } }
public TestConfigurationService(string basePath, Microsoft.Practices.RecipeFramework.GuidancePackage parentPackage ) { this.basePath = basePath; this.parentPackage = parentPackage; }
public void DuplicateActionParameter() { // Load the package from the config. GuidancePackage package = new GuidancePackage(new XmlTextReader( Utils.MakeTestRelativePath("Action-DuplicateParam.xml"))); }
private void EnablePackage(GuidancePackage guidancePackage) { EnablePackage(guidancePackage, false); }
public void CircularDependencies() { // Load the package from the config. GuidancePackage package = new GuidancePackage(Utils.MakeTestRelativePath("ValueProviderTests-Circular.xml")); }
private void EnablePackage(GuidancePackage guidancePackage) { Manager.EnablePackage(guidancePackage); guidancePackage.AddService(typeof(IValueGatheringService), new WizardFramework.WizardGatheringService()); }