public virtual void Initialize()
 {
     this.store.TransactionManager.DoWithinTransaction(() =>
     {
         this.automation = this.store.ElementFactory.CreateElement<AutomationSettingsSchema>();
     });
 }
Ejemplo n.º 2
0
 public void InitializeContext()
 {
     this.store.TransactionManager.DoWithinTransaction(() =>
     {
         this.automation = this.store.ElementFactory.CreateElement <AutomationSettingsSchema>();
     });
 }
 public virtual void Initialize()
 {
     this.store.TransactionManager.DoWithinTransaction(() =>
     {
         this.elementOwner = this.store.ElementFactory.CreateElement <ElementSchema>();
         this.element      = this.store.ElementFactory.CreateElement <AutomationSettingsSchema>();
         this.elementOwner.AutomationSettings.Add(this.element);
     });
     validationContext = new ValidationContext(ValidationCategories.Save, this.element);
 }
 public virtual void Initialize()
 {
     this.store.TransactionManager.DoWithinTransaction(() =>
     {
         this.elementOwner = this.store.ElementFactory.CreateElement<ElementSchema>();
         this.element = this.store.ElementFactory.CreateElement<AutomationSettingsSchema>();
         this.elementOwner.AutomationSettings.Add(this.element);
     });
     validationContext = new ValidationContext(ValidationCategories.Save, this.element);
 }
            public void WhenSameNamedElementAddedToDifferentOwner_ThenValidateNameIsUniqueSucceeds()
            {
                this.store.TransactionManager.DoWithinTransaction(() =>
                {
                    ElementSchema elementOwner2       = this.store.ElementFactory.CreateElement <ElementSchema>();
                    AutomationSettingsSchema element2 = this.store.ElementFactory.CreateElement <AutomationSettingsSchema>();
                    element2.Name = this.element.Name;
                    elementOwner2.AutomationSettings.Add(element2);
                });
                this.element.ValidateNameIsUnique(validationContext);

                Assert.True(validationContext.CurrentViolations.Count == 0);
            }
            public void WhenSameNamedElementAddedToSameOwner_ThenValidateNameIsUniqueFails()
            {
                this.store.TransactionManager.DoWithinTransaction(() =>
                {
                    AutomationSettingsSchema element2 = this.store.ElementFactory.CreateElement <AutomationSettingsSchema>();
                    element2.Name = this.element.Name;
                    this.elementOwner.AutomationSettings.Add(element2);
                });
                this.element.ValidateNameIsUnique(validationContext);

                Assert.True(validationContext.CurrentViolations.Count == 1);
                Assert.True(validationContext.ValidationSubjects.IndexOf(this.element) == 0);
                Assert.True(validationContext.CurrentViolations[0].Code == Properties.Resources.Validate_AutomationSettingsNameIsNotUniqueCode);
            }
            public void InitializeContext()
            {
                this.textTemplateFile = this.solution.Find <IItem>().First();

                this.store.TransactionManager.DoWithinTransaction(() =>
                {
                    var patternModel = this.store.ElementFactory.CreateElement <PatternModelSchema>();
                    var pattern      = patternModel.Create <PatternSchema>();
                    var view         = pattern.CreateViewSchema();
                    var parent       = view.CreateElementSchema();
                    this.element     = parent.CreateAutomationSettingsSchema() as AutomationSettingsSchema;
                    this.settings    = element.AddExtension <CommandSettings>();

                    this.settings.TypeId = typeof(GenerateModelingCodeCommand).Name;
                    ((ICommandSettings)this.settings).Properties.Add(new PropertyBindingSettings {
                        Name = Reflector <GenerateModelingCodeCommand> .GetPropertyName(u => u.TargetFileName)
                    });
                    ((ICommandSettings)this.settings).Properties.Add(new PropertyBindingSettings {
                        Name = Reflector <GenerateModelingCodeCommand> .GetPropertyName(u => u.TargetPath)
                    });
                    ((ICommandSettings)this.settings).Properties.Add(new PropertyBindingSettings {
                        Name = Reflector <GenerateModelingCodeCommand> .GetPropertyName(u => u.TemplateAuthoringUri)
                    });
                    ((ICommandSettings)this.settings).Properties.Add(new PropertyBindingSettings {
                        Name = Reflector <GenerateModelingCodeCommand> .GetPropertyName(u => u.TemplateUri)
                    });
                });

                this.serviceProvider = new Mock <IServiceProvider>();
                this.uriService      = new Mock <IUriReferenceService>();
                this.serviceProvider.Setup(sp => sp.GetService(typeof(IUriReferenceService))).Returns(this.uriService.Object);
                this.validation = new GenerateModelingCodeCommandValidation
                {
                    serviceProvider = this.serviceProvider.Object,
                };

                this.validationContext = new ValidationContext(ValidationCategories.Custom, this.settings);
            }