public void Initialize() { this.settings = Mock.Get(Mock.Of<ITemplateSettings>(s => s.Owner.Name == "ElementWithTemplateAutomation" && s.CommandId == CommandId && s.WizardId == WizardId && s.TemplateUri == "template://item/CSharp/DataContract" && s.TargetFileName == Mock.Of<IPropertyBindingSettings>(binding => binding.Value == "MyItem.cs") && s.TargetPath == Mock.Of<IPropertyBindingSettings>(binding => binding.Value == "") )); var commandSettings = Mock.Of<IAutomationSettingsSchema>(s => s.Id == CommandId && s.Name == "Command" && s.As<ICommandSettings>() == Mock.Of<ICommandSettings>(c => c.Id == CommandId && c.Name == "Command") ); var commandInfo = Mock.Of<IAutomationSettingsInfo>(i => i.Id == commandSettings.Id && i.Name == commandSettings.Name && i.As<IAutomationSettings>() == Mock.Of<IAutomationSettings>(s => s.Id == commandSettings.Id && s.Name == commandSettings.Name) ); var wizardSettings = Mock.Of<IAutomationSettingsSchema>(s => s.Id == WizardId && s.Name == "Wizard" && s.As<IWizardSettings>() == Mock.Of<IWizardSettings>(c => c.Id == WizardId && c.Name == "Wizard") ); var wizardInfo = Mock.Of<IAutomationSettingsInfo>(i => i.Id == wizardSettings.Id && i.Name == wizardSettings.Name && i.As<IAutomationSettings>() == Mock.Of<IAutomationSettings>(s => s.Id == wizardSettings.Id && s.Name == wizardSettings.Name) ); this.settings.Setup(x => x.Owner.AutomationSettings).Returns(new[] { commandSettings, wizardSettings }); this.command = Mock.Get(Mock.Of<IAutomationExtension>(c => c.Name == "Command")); this.wizard = Mock.Get(Mock.Of<IWizardAutomationExtension>(w => w.Name == "Wizard" && w.IsCanceled == false)); this.owner = Mock.Get(Mock.Of<IProductElement>(o => o.BeginTransaction() == Mock.Of<ITransaction>() && o.InstanceName == "ElementWithTemplateAutomation" && o.Info.AutomationSettings == new[] { commandInfo, wizardInfo } && o.AutomationExtensions == new[] { this.command.Object, this.wizard.Object } )); this.owner.DefaultValue = DefaultValue.Mock; this.onInstantiated = new Mock<IOnElementInstantiatedEvent>(); this.automation = new TemplateAutomation(this.owner.Object, this.settings.Object); this.automation.OnInstantiated = this.onInstantiated.Object; this.solution = new Solution { PhysicalPath = Path.GetTempFileName(), Items = { new SolutionFolder { PhysicalPath = Path.GetTempPath() + "\\Solution Items", Name = "Solution Items" }, new Project { PhysicalPath = Path.GetTempPath() + "\\MyProject.csproj", Name = "MyProject" } } }; this.automation.Solution = this.solution; this.assetUnfoldTemplate = new Mock<ITemplate> { DefaultValue = DefaultValue.Mock }; this.uriService = Mock.Get(Mock.Of<IUriReferenceService>(s => s.ResolveUri<ITemplate>(It.IsAny<Uri>()) == this.assetUnfoldTemplate.Object && s.CreateUri(It.IsAny<IItemContainer>(), null) == new Uri("solution://" + Guid.NewGuid().ToString()) )); this.assetVsTemplate = new Mock<IVsTemplate> { DefaultValue = DefaultValue.Mock }; this.assetVsTemplate.Setup(x => x.Type).Returns(VsTemplateType.Item); this.uriService.Setup(x => x.ResolveUri<IVsTemplate>(It.IsAny<Uri>())) .Returns(this.assetVsTemplate.Object); this.automation.UriService = this.uriService.Object; this.tag = new ReferenceTag { SyncNames = this.settings.Object.SyncName, TargetFileName = this.settings.Object.TargetFileName.Value, Id = this.settings.Object.Id, }; }
public void Initialize() { this.settings = Mock.Get(Mock.Of <ITemplateSettings>(s => s.Owner.Name == "ElementWithTemplateAutomation" && s.CommandId == CommandId && s.WizardId == WizardId && s.TemplateUri == "template://item/CSharp/DataContract" && s.TargetFileName == Mock.Of <IPropertyBindingSettings>(binding => binding.Value == "MyItem.cs") && s.TargetPath == Mock.Of <IPropertyBindingSettings>(binding => binding.Value == "") )); var commandSettings = Mock.Of <IAutomationSettingsSchema>(s => s.Id == CommandId && s.Name == "Command" && s.As <ICommandSettings>() == Mock.Of <ICommandSettings>(c => c.Id == CommandId && c.Name == "Command") ); var commandInfo = Mock.Of <IAutomationSettingsInfo>(i => i.Id == commandSettings.Id && i.Name == commandSettings.Name && i.As <IAutomationSettings>() == Mock.Of <IAutomationSettings>(s => s.Id == commandSettings.Id && s.Name == commandSettings.Name) ); var wizardSettings = Mock.Of <IAutomationSettingsSchema>(s => s.Id == WizardId && s.Name == "Wizard" && s.As <IWizardSettings>() == Mock.Of <IWizardSettings>(c => c.Id == WizardId && c.Name == "Wizard") ); var wizardInfo = Mock.Of <IAutomationSettingsInfo>(i => i.Id == wizardSettings.Id && i.Name == wizardSettings.Name && i.As <IAutomationSettings>() == Mock.Of <IAutomationSettings>(s => s.Id == wizardSettings.Id && s.Name == wizardSettings.Name) ); this.settings.Setup(x => x.Owner.AutomationSettings).Returns(new[] { commandSettings, wizardSettings }); this.command = Mock.Get(Mock.Of <IAutomationExtension>(c => c.Name == "Command")); this.wizard = Mock.Get(Mock.Of <IWizardAutomationExtension>(w => w.Name == "Wizard" && w.IsCanceled == false)); this.owner = Mock.Get(Mock.Of <IProductElement>(o => o.BeginTransaction() == Mock.Of <ITransaction>() && o.InstanceName == "ElementWithTemplateAutomation" && o.Info.AutomationSettings == new[] { commandInfo, wizardInfo } && o.AutomationExtensions == new[] { this.command.Object, this.wizard.Object } )); this.owner.DefaultValue = DefaultValue.Mock; this.onInstantiated = new Mock <IOnElementInstantiatedEvent>(); this.automation = new TemplateAutomation(this.owner.Object, this.settings.Object); this.automation.OnInstantiated = this.onInstantiated.Object; this.solution = new Solution { PhysicalPath = Path.GetTempFileName(), Items = { new SolutionFolder { PhysicalPath = Path.GetTempPath() + "\\Solution Items", Name = "Solution Items" }, new Project { PhysicalPath = Path.GetTempPath() + "\\MyProject.csproj", Name = "MyProject" } } }; this.automation.Solution = this.solution; this.assetUnfoldTemplate = new Mock <ITemplate> { DefaultValue = DefaultValue.Mock }; this.uriService = Mock.Get(Mock.Of <IUriReferenceService>(s => s.ResolveUri <ITemplate>(It.IsAny <Uri>()) == this.assetUnfoldTemplate.Object && s.CreateUri(It.IsAny <IItemContainer>(), null) == new Uri("solution://" + Guid.NewGuid().ToString()) )); this.assetVsTemplate = new Mock <IVsTemplate> { DefaultValue = DefaultValue.Mock }; this.assetVsTemplate.Setup(x => x.Type).Returns(VsTemplateType.Item); this.uriService.Setup(x => x.ResolveUri <IVsTemplate>(It.IsAny <Uri>())) .Returns(this.assetVsTemplate.Object); this.automation.UriService = this.uriService.Object; this.tag = new ReferenceTag { SyncNames = this.settings.Object.SyncName, TargetFileName = this.settings.Object.TargetFileName.Value, Id = this.settings.Object.Id, }; }