Exemplo n.º 1
0
            public void InitializeContext()
            {
                var store = new DslTestStore <PatternModelDomainModel>();
                PatternModelSchema patternModel = null;

                store.TransactionManager.DoWithinTransaction(() =>
                {
                    patternModel = store.ElementFactory.CreateElement <PatternModelSchema>();
                });

                var serviceProvider = Mock.Get(store.ServiceProvider);

                serviceProvider.Setup(s => s.GetService(typeof(IPatternManager))).Returns(
                    Mock.Of <IPatternManager>(p => p.InstalledToolkits == new List <IInstalledToolkitInfo>()));

                var uriService = Mock.Of <IUriReferenceService>(
                    u => u.ResolveUri <IInstanceBase>(It.IsAny <Uri>()) == Mock.Of <IProduct>(p =>
                                                                                              p.ToolkitInfo.Identifier == "AuthoredToolkit"));

                var patternSchema = patternModel.Create <PatternSchema>();

                patternSchema.Name        = "FooPattern";
                patternSchema.PatternLink = "patternmanager://foo";
                patternSchema.UriService  = uriService;

                this.view      = patternSchema.Create <ViewSchema>();
                this.view.Name = "View1";

                store.TransactionManager.DoWithinTransaction(() =>
                {
                    this.extensionPoint = store.ElementFactory.CreateElement <ExtensionPointSchema>("ExtensionPoint1");
                    this.view.ExtensionPoints.Add(this.extensionPoint);
                });
            }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a tailored pattern model.
        /// </summary>
        internal static PatternModelSchema TailorPatternModel(PatternModelSchema basePatternModel, Version baseVersion, string toolkitId = "ToolkitId")
        {
            var store = new DslTestStore <PatternModelDomainModel>();

            var serviceProvider = Mock.Get(store.ServiceProvider);

            serviceProvider.Setup(s => s.GetService(typeof(IPatternManager))).Returns(
                Mock.Of <IPatternManager>(p => p.InstalledToolkits == new List <IInstalledToolkitInfo>()));

            PatternModelSchema tailoredPatternModel = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                tailoredPatternModel = store.ElementFactory.CreateElement <PatternModelSchema>();
            });

            // Set baseId on the pattern line
            tailoredPatternModel.WithTransaction(pl => pl.BaseId = "Base");

            tailoredPatternModel.ClonerFactory = (b, v, t) =>
                                                 Mock.Of <PatternModelCloner>(
                c =>
                c.SourcePatternModel == b &&
                c.SourceVersion == v &&
                c.TargetPatternModel == t);

            // Clone the pattern line
            tailoredPatternModel.Tailor(basePatternModel, baseVersion);

            return(tailoredPatternModel);
        }
Exemplo n.º 3
0
        public void WhenNestedTransactionNotCommited_ThenNestedChangesNotCommited()
        {
            var           store        = new DslTestStore <ProductStateStoreDomainModel>();
            IProductState productState = null;
            IProduct      product      = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement <ProductState>();
                product      = productState.CreateProduct();
            });

            var committed = false;

            store.Store.EventManagerDirectory.TransactionCommitted.Add(new EventHandler <TransactionCommitEventArgs>(
                                                                           (sender, args) => committed = true));

            var parentTx = store.TransactionManager.BeginTransaction();

            product.DefinitionName = "foo";

            var nestedTx = store.TransactionManager.BeginTransaction();

            product.InstanceName = "bar";

            nestedTx.Dispose();

            Assert.NotEqual("bar", product.InstanceName);

            parentTx.Commit();

            Assert.True(committed);
            Assert.Equal("foo", product.DefinitionName);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns a tailored pattern model.
        /// </summary>
        internal static PatternModelSchema TailorPatternModel(PatternModelSchema basePatternModel, Version baseVersion, string toolkitId = "ToolkitId")
        {
            var store = new DslTestStore<PatternModelDomainModel>();

            var serviceProvider = Mock.Get(store.ServiceProvider);
            serviceProvider.Setup(s => s.GetService(typeof(IPatternManager))).Returns(
                Mock.Of<IPatternManager>(p => p.InstalledToolkits == new List<IInstalledToolkitInfo>()));

            PatternModelSchema tailoredPatternModel = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                tailoredPatternModel = store.ElementFactory.CreateElement<PatternModelSchema>();
            });

            // Set baseId on the pattern line
            tailoredPatternModel.WithTransaction(pl => pl.BaseId = "Base");

            tailoredPatternModel.ClonerFactory = (b, v, t) =>
                Mock.Of<PatternModelCloner>(
                    c =>
                        c.SourcePatternModel == b &&
                        c.SourceVersion == v &&
                        c.TargetPatternModel == t);

            // Clone the pattern line
            tailoredPatternModel.Tailor(basePatternModel, baseVersion);

            return tailoredPatternModel;
        }
            public virtual void InitializeContext()
            {
                var uriService = Mock.Of <IUriReferenceService>(
                    u => u.ResolveUri <IInstanceBase>(It.IsAny <Uri>()) == Mock.Of <IProduct>(p =>
                                                                                              p.ToolkitInfo.Identifier == "ToolkitId"));

                var store = new DslTestStore <PatternModelDomainModel>();

                var serviceProvider = Mock.Get(store.ServiceProvider);

                serviceProvider.Setup(s => s.GetService(typeof(IPatternManager))).Returns(
                    Mock.Of <IPatternManager>(p => p.InstalledToolkits == new List <IInstalledToolkitInfo>()));

                store.TransactionManager.DoWithinTransaction(() =>
                {
                    this.PatternModel   = store.ElementFactory.CreateElement <PatternModelSchema>();
                    var pattern         = this.PatternModel.Create <PatternSchema>();
                    pattern.Name        = "WebService";
                    pattern.PatternLink = "patternmanager://foo";
                    pattern.UriService  = uriService;

                    this.Property      = pattern.Create <PropertySchema>();
                    this.Property.Name = "Namespace";
                });
            }
Exemplo n.º 6
0
            public void InitializeContext()
            {
                var sourceStore = new DslTestStore <PatternModelDomainModel>();

                sourceStore.TransactionManager.DoWithinTransaction(() =>
                {
                    this.sourcePatternModel = sourceStore.ElementFactory.CreateElement <PatternModelSchema>();
                });

                var serviceProvider = Mock.Get(sourceStore.ServiceProvider);

                serviceProvider.Setup(s => s.GetService(typeof(IPatternManager))).Returns(
                    Mock.Of <IPatternManager>(p => p.InstalledToolkits == new List <IInstalledToolkitInfo>()));

                var uriService = Mock.Of <IUriReferenceService>(
                    u => u.ResolveUri <IInstanceBase>(It.IsAny <Uri>()) == Mock.Of <IProduct>(p =>
                                                                                              p.ToolkitInfo.Identifier == "MyToolkit"));

                var patternSchema = this.sourcePatternModel.Create <PatternSchema>();

                patternSchema.Name        = "Pattern1";
                patternSchema.PatternLink = "patternmanager://foo";
                patternSchema.UriService  = uriService;

                var targetStore = new DslTestStore <PatternModelDomainModel>();

                var serviceProvider1 = Mock.Get(targetStore.ServiceProvider);

                serviceProvider1.Setup(s => s.GetService(typeof(IPatternManager))).Returns(
                    Mock.Of <IPatternManager>(p => p.InstalledToolkits == new List <IInstalledToolkitInfo>()));

                targetStore.TransactionManager.DoWithinTransaction(() =>
                                                                   this.targetPatternModel = targetStore.ElementFactory.CreateElement <PatternModelSchema>());
            }
            public void InitializeContext()
            {
                var sourceStore = new DslTestStore<PatternModelDomainModel>();

                sourceStore.TransactionManager.DoWithinTransaction(() =>
                {
                    this.sourcePatternModel = sourceStore.ElementFactory.CreateElement<PatternModelSchema>();
                });

                var serviceProvider = Mock.Get(sourceStore.ServiceProvider);
                serviceProvider.Setup(s => s.GetService(typeof(IPatternManager))).Returns(
                    Mock.Of<IPatternManager>(p => p.InstalledToolkits == new List<IInstalledToolkitInfo>()));

                var uriService = Mock.Of<IUriReferenceService>(
                    u => u.ResolveUri<IInstanceBase>(It.IsAny<Uri>()) == Mock.Of<IProduct>(p =>
                        p.ToolkitInfo.Identifier == "MyToolkit"));

                var patternSchema = this.sourcePatternModel.Create<PatternSchema>();
                patternSchema.Name = "Pattern1";
                patternSchema.PatternLink = "patternmanager://foo";
                patternSchema.UriService = uriService;

                patternSchema.Create<ViewSchema>();

                var targetStore = new DslTestStore<PatternModelDomainModel>();

                var serviceProvider1 = Mock.Get(targetStore.ServiceProvider);
                serviceProvider1.Setup(s => s.GetService(typeof(IPatternManager))).Returns(
                    Mock.Of<IPatternManager>(p => p.InstalledToolkits == new List<IInstalledToolkitInfo>()));

                targetStore.TransactionManager.DoWithinTransaction(() =>
                    this.targetPatternModel = targetStore.ElementFactory.CreateElement<PatternModelSchema>());
            }
            public void InitializeContext()
            {
                var store = new DslTestStore<PatternModelDomainModel>().Store;

                store.TransactionManager.DoWithinTransaction(
                    () => this.product = (PatternSchema)store.ElementFactory.CreateElement<PatternModelSchema>().CreatePatternSchema());
            }
            public void InitializeContext()
            {
                var store = new DslTestStore <PatternModelDomainModel>();

                store.TransactionManager.DoWithinTransaction(
                    () => this.product = store.ElementFactory.CreateElement <PatternModelSchema>().Create <PatternSchema>());
            }
Exemplo n.º 10
0
            public virtual void Initialize()
            {
                this.DslStore = new DslTestStore <ProductStateStoreDomainModel>();

                using (var tx = this.DslStore.TransactionManager.BeginTransaction())
                {
                    this.ProductStore = this.DslStore.ElementFactory.CreateElement <ProductState>();
                    tx.Commit();
                }
            }
Exemplo n.º 11
0
            public void InitializeContext()
            {
                this.store = new DslTestStore <ProductStateStoreDomainModel>();

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.element = this.store.ElementFactory.CreateElement <Element>();
                    tx.Commit();
                }
            }
            public virtual void InitializeContext()
            {
                var store = new DslTestStore<PatternModelDomainModel>();

                store.TransactionManager.DoWithinTransaction(() =>
                {
                    this.PatternModel = store.ElementFactory.CreateElement<PatternModelSchema>();
                    var pattern = this.PatternModel.Create<PatternSchema>();
                    this.Element = pattern.Create<ElementSchema>();
                });
            }
Exemplo n.º 13
0
            public void Initialize()
            {
                this.store = new DslTestStore<ProductStateStoreDomainModel>();

                this.toolkit = Mocks.Of<IInstalledToolkitInfo>().First(
                    f => f.Id == "foo" && f.Schema.Pattern.Id == Guid.NewGuid());

                var serviceProvider = Mock.Get(this.store.ServiceProvider);
                serviceProvider.Setup(sp => sp.GetService(typeof(IPatternManager)))
                    .Returns(Mocks.Of<IPatternManager>().First(x => x.InstalledToolkits == new[] { this.toolkit }));
            }
Exemplo n.º 14
0
            public void InitializeContext()
            {
                this.provider = new TestReferenceWithoutItsTypeConverter();
                this.store    = new DslTestStore <ProductStateStoreDomainModel>();

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.element = this.store.ElementFactory.CreateElement <Element>();
                    tx.Commit();
                }
            }
Exemplo n.º 15
0
            public virtual void InitializeContext()
            {
                var store = new DslTestStore <PatternModelDomainModel>();

                store.TransactionManager.DoWithinTransaction(() =>
                {
                    this.PatternModel = store.ElementFactory.CreateElement <PatternModelSchema>();
                    var pattern       = this.PatternModel.Create <PatternSchema>();
                    this.Element      = pattern.Create <ElementSchema>();
                });
            }
Exemplo n.º 16
0
            public void Initialize()
            {
                this.store = new DslTestStore <ProductStateStoreDomainModel>();

                this.toolkit = Mocks.Of <IInstalledToolkitInfo>().First(
                    f => f.Id == "foo" && f.Schema.Pattern.Id == Guid.NewGuid());

                var serviceProvider = Mock.Get(this.store.ServiceProvider);

                serviceProvider.Setup(sp => sp.GetService(typeof(IPatternManager)))
                .Returns(Mocks.Of <IPatternManager>().First(x => x.InstalledToolkits == new[] { this.toolkit }));
            }
Exemplo n.º 17
0
            public void Initialize()
            {
                this.solutionEvents = new Mock <ISolutionEvents>();
                this.itemEvents     = new Mock <IItemEvents>();
                this.messageService = new Mock <IUserMessageService>();

                if (Directory.Exists(solutionItemsDir))
                {
                    Directory.Delete(solutionItemsDir, true);
                }

                Directory.CreateDirectory(solutionItemsDir);

                this.solution = new Solution
                {
                    PhysicalPath = Path.GetTempFileName(),
                    Items        =
                    {
                        new SolutionFolder
                        {
                            PhysicalPath = Path.GetTempPath() + "\\Solution Items",
                            Name         = "Solution Items"
                        }
                    }
                };

                this.store = new DslTestStore <ProductStateStoreDomainModel>();

                this.toolkitInfo = new Mock <IInstalledToolkitInfo>
                {
                    DefaultValue = DefaultValue.Mock
                };
                this.toolkitInfo.Setup(f => f.Id).Returns("foo");
                this.toolkitInfo.Setup(f => f.Version).Returns(new Version("1.0.0.0"));
                this.toolkitInfo.Setup(f => f.Schema.Pattern.ExtensionId).Returns("foo");

                var installedFactories = new[] { this.toolkitInfo.Object };

                var componentModel = new Mock <IComponentModel>();

                componentModel.Setup(cm => cm.GetService <IEnumerable <IInstalledToolkitInfo> >()).Returns(installedFactories);
                componentModel.Setup(cm => cm.GetService <IToolkitRepository>()).Returns(Mock.Of <IToolkitRepository>());

                var serviceProvider = Mock.Get(this.store.ServiceProvider);

                serviceProvider.Setup(s => s.GetService(typeof(SComponentModel))).Returns(componentModel.Object);
                serviceProvider.Setup(s => s.GetService(typeof(ISolution))).Returns(this.solution);

                this.shellEvents = new Mock <IShellEvents>();
                this.shellEvents.Setup(x => x.IsInitialized).Returns(true);

                this.manager = new TestPatternManager(this.store.ServiceProvider, this.solution, this.shellEvents.Object, this.solutionEvents.Object, this.itemEvents.Object, installedFactories, this.messageService.Object);
            }
Exemplo n.º 18
0
            public void InitializeContext()
            {
                var store = new DslTestStore <PatternModelDomainModel>();

                store.TransactionManager.DoWithinTransaction(
                    () => this.sourcePatternModel = store.ElementFactory.CreateElement <PatternModelSchema>());

                var serviceProvider = Mock.Get(store.ServiceProvider);

                serviceProvider.Setup(s => s.GetService(typeof(IPatternManager))).Returns(
                    Mock.Of <IPatternManager>(p => p.InstalledToolkits == new List <IInstalledToolkitInfo>()));
            }
Exemplo n.º 19
0
            public void Initialize()
            {
                this.store = new DslTestStore <ProductStateStoreDomainModel>();

                this.extension = new Mock <IAutomationExtension>();
                this.extension.As <IDisposable>();

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.element = this.store.ElementFactory.CreateElement <Product>();
                    tx.Commit();
                }

                this.element.AutomationExtensions.Add(this.extension.Object);
            }
Exemplo n.º 20
0
        public void WhenProductInstantiated_ThenRetrievesProductInstance()
        {
            var           store        = new DslTestStore <ProductStateStoreDomainModel>();
            IProductState productState = null;
            IProduct      product      = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement <ProductState>();
                product      = productState.CreateProduct();
            });

            Assert.Equal(1, productState.FindAll <Product>().Count());
            Assert.Equal(product.Id, productState.FindAll <Product>().ElementAt(0).Id);
        }
Exemplo n.º 21
0
            public void Initialize()
            {
                this.store = new DslTestStore<ProductStateStoreDomainModel>();

                this.extension = new Mock<IAutomationExtension>();
                this.extension.As<IDisposable>();

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.element = this.store.ElementFactory.CreateElement<Product>();
                    tx.Commit();
                }

                this.element.AutomationExtensions.Add(this.extension.Object);
            }
            public void Initialize()
            {
                this.store = new DslTestStore<ProductStateStoreDomainModel>();

                using (var tx = store.TransactionManager.BeginTransaction())
                {
                    this.property = store.ElementFactory.CreateElement<Property>();
                    this.property.Info = Mocks.Of<IPropertyInfo>().First(i => i.Name == PropertyName && i.IsVisible == true && i.IsReadOnly == false);

                    this.element = store.ElementFactory.CreateElement<Element>();
                    this.element.Properties.Add(this.property);
                    tx.Commit();
                }

                this.descriptor = new ProductElementTypeDescriptor(
                    TypeDescriptor.GetProvider(this.element).GetTypeDescriptor(this.element), this.element);
            }
            public void Initialize()
            {
                this.store = new DslTestStore <ProductStateStoreDomainModel>();

                using (var tx = store.TransactionManager.BeginTransaction())
                {
                    this.property      = store.ElementFactory.CreateElement <Property>();
                    this.property.Info = Mocks.Of <IPropertyInfo>().First(i => i.Name == PropertyName && i.IsVisible == true && i.IsReadOnly == false);

                    this.element = store.ElementFactory.CreateElement <Element>();
                    this.element.Properties.Add(this.property);
                    tx.Commit();
                }

                this.descriptor = new ProductElementTypeDescriptor(
                    TypeDescriptor.GetProvider(this.element).GetTypeDescriptor(this.element), this.element);
            }
        private static Product CreateProduct()
        {
            ProductState productStore = null;
            DslTestStore <ProductStateStoreDomainModel> store = new DslTestStore <ProductStateStoreDomainModel>();

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productStore = store.ElementFactory.CreateElement <ProductState>();
            });

            var product = (Product)productStore.CreateProduct();

            product.InstanceName = "AProduct1";
            product.Info         = Mock.Of <IPatternInfo>(i => i.Name == "AProduct" && i.CodeIdentifier == "AProduct");

            return(product);
        }
Exemplo n.º 25
0
            public void Initialize()
            {
                this.store = new DslTestStore <ProductStateStoreDomainModel>();
                Mock.Get(this.store.ServiceProvider)
                .Setup(x => x.GetService(typeof(SComponentModel)))
                .Returns(new Mock <IComponentModel>
                {
                    DefaultValue = DefaultValue.Mock
                }
                         .Object);
                Mock.Get(this.store.ServiceProvider)
                .Setup(x => x.GetService(typeof(IBindingCompositionService)))
                .Returns(new Mock <IBindingCompositionService>
                {
                    DefaultValue = DefaultValue.Mock
                }
                         .Object);

                this.automationExtension = new Mock <IAutomationExtension>();
                this.automationExtension.As <IDisposable>();
                this.automationExtension.As <ISupportInitialize>();
                this.extensionSettings = new Mock <IAutomationSettings>();
                this.extensionSettings
                .Setup(x => x.CreateAutomation(It.IsAny <IProductElement>()))
                .Returns(this.automationExtension.Object);

                var settingsContainer = new Mock <IPatternElementInfo>();
                var settingsInfo      = new Mock <IAutomationSettingsInfo>();

                settingsContainer
                .Setup(x => x.AutomationSettings)
                .Returns(new[] { settingsInfo.Object });

                settingsInfo
                .Setup(info => info.As <IAutomationSettings>())
                .Returns(this.extensionSettings.Object);

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.element      = this.store.ElementFactory.CreateElement <Product>();
                    this.element.Info = settingsContainer.Object;
                    tx.Commit();
                }
            }
            public void Initialize()
            {
                this.store = new DslTestStore<ProductStateStoreDomainModel>();
                Mock.Get(this.store.ServiceProvider)
                    .Setup(x => x.GetService(typeof(SComponentModel)))
                    .Returns(new Mock<IComponentModel>
                    {
                        DefaultValue = DefaultValue.Mock
                    }
                    .Object);
                Mock.Get(this.store.ServiceProvider)
                    .Setup(x => x.GetService(typeof(IBindingCompositionService)))
                    .Returns(new Mock<IBindingCompositionService>
                    {
                        DefaultValue = DefaultValue.Mock
                    }
                    .Object);

                this.automationExtension = new Mock<IAutomationExtension>();
                this.automationExtension.As<IDisposable>();
                this.automationExtension.As<ISupportInitialize>();
                this.extensionSettings = new Mock<IAutomationSettings>();
                this.extensionSettings
                    .Setup(x => x.CreateAutomation(It.IsAny<IProductElement>()))
                    .Returns(this.automationExtension.Object);

                var settingsContainer = new Mock<IPatternElementInfo>();
                var settingsInfo = new Mock<IAutomationSettingsInfo>();

                settingsContainer
                    .Setup(x => x.AutomationSettings)
                    .Returns(new[] { settingsInfo.Object });

                settingsInfo
                    .Setup(info => info.As<IAutomationSettings>())
                    .Returns(this.extensionSettings.Object);

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.element = this.store.ElementFactory.CreateElement<Product>();
                    this.element.Info = settingsContainer.Object;
                    tx.Commit();
                }
            }
Exemplo n.º 27
0
            public void Initialize()
            {
                this.store = new DslTestStore <ProductStateStoreDomainModel>();

                var productInfo = new Mock <IPatternInfo>();

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.product      = this.store.ElementFactory.CreateElement <Product>();
                    this.product.Info = productInfo.Object;
                    tx.Commit();
                }

                this.viewInfo = new Mock <IViewInfo>();
                this.viewInfo.Setup(v => v.Id).Returns(Guid.NewGuid());
                this.viewInfo.Setup(v => v.Pattern).Returns(this.product.Info);

                productInfo.Setup(p => p.Views).Returns(new[] { this.viewInfo.Object });
            }
            public void Initialize()
            {
                this.store = new DslTestStore<ProductStateStoreDomainModel>();

                var viewInfo = new Mock<IViewInfo>();

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.view = this.store.ElementFactory.CreateElement<View>();
                    this.view.Info = viewInfo.Object;
                    tx.Commit();
                }

                this.collectionInfo = new Mock<ICollectionInfo>();
                this.collectionInfo.Setup(c => c.Id).Returns(Guid.NewGuid());
                this.collectionInfo.Setup(c => c.Parent).Returns(this.view.Info);

                viewInfo.Setup(p => p.Elements).Returns(new[] { this.collectionInfo.Object });
            }
            public void Initialize()
            {
                this.store = new DslTestStore <ProductStateStoreDomainModel>();

                var viewInfo = new Mock <IViewInfo>();

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.view      = this.store.ElementFactory.CreateElement <View>();
                    this.view.Info = viewInfo.Object;
                    tx.Commit();
                }

                this.elementInfo = new Mock <IElementInfo>();
                this.elementInfo.Setup(e => e.Id).Returns(Guid.NewGuid());
                this.elementInfo.Setup(e => e.Parent).Returns(this.view.Info);

                viewInfo.Setup(p => p.Elements).Returns(new[] { this.elementInfo.Object });
            }
Exemplo n.º 30
0
        public void Initialize()
        {
            this.store = new DslTestStore <ProductStateStoreDomainModel>();

            var elementInfo = new Mock <IElementInfo>();

            using (var tx = this.store.TransactionManager.BeginTransaction())
            {
                this.element      = this.store.ElementFactory.CreateElement <Element>();
                this.element.Info = elementInfo.Object;
                tx.Commit();
            }

            this.propertyInfo = new Mock <IPropertyInfo>();
            this.propertyInfo.Setup(v => v.Id).Returns(Guid.NewGuid());
            this.propertyInfo.Setup(v => v.Parent).Returns(this.element.Info);

            elementInfo.Setup(e => e.Properties).Returns(new[] { this.propertyInfo.Object });
        }
Exemplo n.º 31
0
        public void Initialize()
        {
            this.store = new DslTestStore<ProductStateStoreDomainModel>();

            var elementInfo = new Mock<IElementInfo>();

            using (var tx = this.store.TransactionManager.BeginTransaction())
            {
                this.element = this.store.ElementFactory.CreateElement<Element>();
                this.element.Info = elementInfo.Object;
                tx.Commit();
            }

            this.propertyInfo = new Mock<IPropertyInfo>();
            this.propertyInfo.Setup(v => v.Id).Returns(Guid.NewGuid());
            this.propertyInfo.Setup(v => v.Parent).Returns(this.element.Info);

            elementInfo.Setup(e => e.Properties).Returns(new[] { this.propertyInfo.Object });
        }
Exemplo n.º 32
0
        public void WhenChangingProperty_ThenNotifiesSubscriber()
        {
            var      store   = new DslTestStore <ProductStateStoreDomainModel>();
            IProduct product = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                var productStore = store.ElementFactory.CreateElement <ProductState>();
                product          = productStore.Create <Product>();
            });

            var notified = false;

            product.SubscribeChanged(x => x.InstanceName, p => notified = true);

            product.InstanceName = "Hello";

            Assert.IsTrue(notified);
        }
Exemplo n.º 33
0
        public void WhenChangingProperty_ThenNotifiesSubscriber()
        {
            var store = new DslTestStore<ProductStateStoreDomainModel>();
            IProduct product = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                var productStore = store.ElementFactory.CreateElement<ProductState>();
                product = productStore.Create<Product>();
            });

            var notified = false;

            product.SubscribeChanged(x => x.InstanceName, p => notified = true);

            product.InstanceName = "Hello";

            Assert.IsTrue(notified);
        }
Exemplo n.º 34
0
            public void Initialize()
            {
                this.template        = new Mock <ITemplate>();
                this.serviceProvider = new Mock <IServiceProvider>();
                this.modelBus        = new Mock <IModelBus>();

                this.serviceProvider.Setup(x => x.GetService(typeof(SModelBus))).Returns(this.modelBus.Object);

                this.solution = CreateSolution();
                this.store    = new DslTestStore <ProductStateStoreDomainModel>();

                this.store.TransactionManager.DoWithinTransaction(() =>
                {
                    var productStore  = this.store.ElementFactory.CreateElement <ProductState>();
                    this.product      = productStore.CreateProduct(prod => prod.InstanceName = "Foo");
                    var property      = (Property)this.product.CreateProperty();
                    property.RawValue = "GuidanceValue";
                    property.Info     = Mocks.Of <IPropertyInfo>().First(i => i.Name == "GuidanceName" && i.Type == "System.String" && i.IsVisible == true && i.IsReadOnly == false);
                });

                this.uriService = new Mock <IUriReferenceService>();
                this.uriService.Setup(x => x.ResolveUri <ITemplate>(It.IsAny <Uri>())).Returns(this.template.Object);

                this.command = new GenerateModelingCodeCommand
                {
                    TargetFileName  = "Foo",
                    TemplateUri     = new Uri("t4://foo.tt"),
                    UriService      = this.uriService.Object,
                    ModelElement    = (ModelElement)this.product,
                    ModelFile       = "C:\\Temp\\foo" + NuPattern.Runtime.StoreConstants.RuntimeStoreExtension,
                    ServiceProvider = this.serviceProvider.Object,
                    Solution        = this.solution,
                };

                // Set modelbus adapter
                var adapter = new Mock <ModelBusAdapterManager>();

                this.modelBus.Setup(x => x.FindAdapterManagers(It.IsAny <object[]>())).Returns(new[] { adapter.Object });
                adapter.Setup(x => x.GetSupportedLogicalAdapterIds()).Returns(new[] { "FooAdapter" });
                adapter.Setup(x => x.GetExposedElementTypes("FooAdapter")).Returns(new[] { new SupportedType(typeof(IProduct)) });
            }
Exemplo n.º 35
0
        public void WhenTransactionCommited_ThenRaisesTransactionCommitedEvent()
        {
            var           store        = new DslTestStore <ProductStateStoreDomainModel>();
            IProductState productState = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement <ProductState>();
            });

            var fired = false;

            productState.TransactionCommited += (sender, args) => fired = true;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState.CreateProduct();
            });

            Assert.True(fired);
        }
            public void Initialize()
            {
                this.template = new Mock<ITemplate>();
                this.serviceProvider = new Mock<IServiceProvider>();
                this.modelBus = new Mock<IModelBus>();

                this.serviceProvider.Setup(x => x.GetService(typeof(SModelBus))).Returns(this.modelBus.Object);

                this.solution = CreateSolution();
                this.store = new DslTestStore<ProductStateStoreDomainModel>();

                this.store.TransactionManager.DoWithinTransaction(() =>
                {
                    var productStore = this.store.ElementFactory.CreateElement<ProductState>();
                    this.product = productStore.CreateProduct(prod => prod.InstanceName = "Foo");
                    var property = (Property)this.product.CreateProperty();
                    property.RawValue = "GuidanceValue";
                    property.Info = Mocks.Of<IPropertyInfo>().First(i => i.Name == "GuidanceName" && i.Type == "System.String" && i.IsVisible == true && i.IsReadOnly == false);
                });

                this.uriService = new Mock<IUriReferenceService>();
                this.uriService.Setup(x => x.ResolveUri<ITemplate>(It.IsAny<Uri>())).Returns(this.template.Object);

                this.command = new GenerateModelingCodeCommand
                {
                    TargetFileName = "Foo",
                    TemplateUri = new Uri("t4://foo.tt"),
                    UriService = this.uriService.Object,
                    ModelElement = (ModelElement)this.product,
                    ModelFile = "C:\\Temp\\foo" + NuPattern.Runtime.StoreConstants.RuntimeStoreExtension,
                    ServiceProvider = this.serviceProvider.Object,
                    Solution = this.solution,
                };

                // Set modelbus adapter
                var adapter = new Mock<ModelBusAdapterManager>();
                this.modelBus.Setup(x => x.FindAdapterManagers(It.IsAny<object[]>())).Returns(new[] { adapter.Object });
                adapter.Setup(x => x.GetSupportedLogicalAdapterIds()).Returns(new[] { "FooAdapter" });
                adapter.Setup(x => x.GetExposedElementTypes("FooAdapter")).Returns(new[] { new SupportedType(typeof(IProduct)) });
            }
Exemplo n.º 37
0
        public void WhenEventsAreRaised_ThenStoreIsInATransaction()
        {
            var           store        = new DslTestStore <ProductStateStoreDomainModel>();
            IProductState productState = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement <ProductState>();
            });

            IProduct product       = null;
            bool     inTransaction = false;

            productState.ElementInstantiated += (sender, args) => inTransaction = store.Store.TransactionActive;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                product = productState.CreateProduct();
            });

            Assert.True(inTransaction);
        }
Exemplo n.º 38
0
        public void WhenTransactionCommitedWhileSerializing_ThenDoesNotRaiseTransactionCommitedEvent()
        {
            var store = new DslTestStore <ProductStateStoreDomainModel>();

            store.Store.PropertyBag[ProductState.IsSerializingKey] = true;
            IProductState productState = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement <ProductState>();
            });

            var fired = false;

            productState.TransactionCommited += (sender, args) => fired = true;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState.CreateProduct();
            });

            Assert.False(fired);
        }
Exemplo n.º 39
0
        public void WhenPropertyInstantiated_ThenRaisesInstantiatedEvent()
        {
            var           store        = new DslTestStore <ProductStateStoreDomainModel>();
            IProductState productState = null;
            IProduct      product      = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement <ProductState>();
                product      = productState.CreateProduct();
            });

            IInstanceBase instantiated = null;

            productState.ElementInstantiated += (sender, args) => instantiated = args.Value;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                product.CreateProperty();
            });

            Assert.NotNull(instantiated);
        }
Exemplo n.º 40
0
        public void WhenElementInstantiated_ThenDoesNotRaisePropertyChangedEventsFromInitializerSetters()
        {
            var store = new DslTestStore<ProductStateStoreDomainModel>();
            IProductState productState = null;
            IView view = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement<ProductState>();
                var product = productState.CreateProduct();
                view = product.CreateView();
            });

            bool changed = false;
            productState.PropertyChanged += (sender, args) => changed = true;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                view.CreateElement(e => e.InstanceName = "Foo");
            });

            Assert.False(changed);
        }
            public virtual void InitializeContext()
            {
                var store = new DslTestStore<PatternModelDomainModel>();

                var serviceProvider = Mock.Get(store.ServiceProvider);
                serviceProvider.Setup(s => s.GetService(typeof(IPatternManager))).Returns(
                    Mock.Of<IPatternManager>(p => p.InstalledToolkits == new List<IInstalledToolkitInfo>()));

                store.TransactionManager.DoWithinTransaction(() =>
                {
                    this.PatternModel = store.ElementFactory.CreateElement<PatternModelSchema>();
                    var pattern = this.PatternModel.Create<PatternSchema>();
                    pattern.PatternLink = "patternmanager://foo";

                    var uriService = Mock.Of<IUriReferenceService>(
                        u => u.ResolveUri<IInstanceBase>(It.IsAny<Uri>()) == Mock.Of<IProduct>(p =>
                            p.ToolkitInfo.Identifier == "ToolkitId"));

                    pattern.UriService = uriService;

                    this.Property = pattern.Create<PropertySchema>();
                });
            }
            public void InitializeContext()
            {
                var uriService = Mock.Of<IUriReferenceService>(
                    u => u.ResolveUri<IInstanceBase>(It.IsAny<Uri>()) == Mock.Of<IProduct>(p =>
                    p.ToolkitInfo.Identifier == "AuthoredToolkit"));

                var store = new DslTestStore<PatternModelDomainModel>();

                var serviceProvider = Mock.Get(store.ServiceProvider);
                serviceProvider.Setup(s => s.GetService(typeof(IPatternManager))).Returns(
                    Mock.Of<IPatternManager>(p => p.InstalledToolkits == new List<IInstalledToolkitInfo>()));

                PatternModelSchema patternModel = null;

                store.TransactionManager.DoWithinTransaction(() =>
                {
                    patternModel = store.ElementFactory.CreateElement<PatternModelSchema>();
                });

                var patternSchema = patternModel.Create<PatternSchema>();
                patternSchema.Name = "FooPattern";
                patternSchema.PatternLink = "patternmanager://foo";
                patternSchema.UriService = uriService;

                var view = patternSchema.Create<ViewSchema>();
                view.Name = "View1";

                store.TransactionManager.DoWithinTransaction(() =>
                {
                    this.collection = store.ElementFactory.CreateElement<CollectionSchema>("Collection1");

                    var extensionPoint = store.ElementFactory.CreateElement<ExtensionPointSchema>("ExtensionPoint1");

                    this.collection.ExtensionPoints.Add(extensionPoint);
                    view.Elements.Add(collection);
                });
            }
Exemplo n.º 43
0
        public void WhenElementInstantiated_ThenRaisesInstantiatedEvent()
        {
            var store = new DslTestStore<ProductStateStoreDomainModel>();
            IProductState productState = null;
            IView view = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement<ProductState>();
                var product = productState.CreateProduct();
                view = product.CreateView();
            });

            IInstanceBase instantiated = null;

            productState.ElementInstantiated += (sender, args) => instantiated = args.Value;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                view.CreateElement();
            });

            Assert.NotNull(instantiated);
        }
Exemplo n.º 44
0
        public void WhenProductInstantiatedWhileSerializing_ThenDoesNotRaisePropertyChangeEvents()
        {
            var store = new DslTestStore <ProductStateStoreDomainModel>();

            store.Store.PropertyBag[ProductState.IsSerializingKey] = true;
            IProductState productState = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement <ProductState>();
            });

            bool     changed = false;
            IProduct product = null;

            productState.PropertyChanged += (sender, args) => changed = true;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                product = productState.CreateProduct();
            });

            Assert.False(changed);
        }
Exemplo n.º 45
0
        public void WhenElementInstantiated_ThenDoesNotRaisePropertyChangedEventsFromInitializerSetters()
        {
            var           store        = new DslTestStore <ProductStateStoreDomainModel>();
            IProductState productState = null;
            IView         view         = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement <ProductState>();
                var product  = productState.CreateProduct();
                view         = product.CreateView();
            });

            bool changed = false;

            productState.PropertyChanged += (sender, args) => changed = true;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                view.CreateElement(e => e.InstanceName = "Foo");
            });

            Assert.False(changed);
        }
Exemplo n.º 46
0
            public void Initialize()
            {
                this.store = new DslTestStore <ProductStateStoreDomainModel>();

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.element = this.store.ElementFactory.CreateElement <Product>();
                    tx.Commit();
                }

                this.bindingContext = new Mock <IDynamicBindingContext> {
                    DefaultValue = DefaultValue.Mock
                };

                Mock.Get(this.store.ServiceProvider)
                .Setup(x => x.GetService(typeof(IBindingFactory)))
                .Returns(Mock.Of <IBindingFactory>(factory =>
                                                   factory.CreateContext() == this.bindingContext.Object));

                this.element.InstanceName = "Hello";
                this.element.Info         = Mock.Of <IElementInfo>(info =>
                                                                   info.Name == "My" &&
                                                                   info.ValidationSettings == new IBindingSettings[] { Mock.Of <IBindingSettings>() });
            }
Exemplo n.º 47
0
        public void WhenNestedTransactionNotCommited_ThenNestedChangesNotCommited()
        {
            var store = new DslTestStore<ProductStateStoreDomainModel>();
            IProductState productState = null;
            IProduct product = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement<ProductState>();
                product = productState.CreateProduct();
            });

            var committed = false;
            store.Store.EventManagerDirectory.TransactionCommitted.Add(new EventHandler<TransactionCommitEventArgs>(
                (sender, args) => committed = true));

            var parentTx = store.TransactionManager.BeginTransaction();

            product.DefinitionName = "foo";

            var nestedTx = store.TransactionManager.BeginTransaction();

            product.InstanceName = "bar";

            nestedTx.Dispose();

            Assert.NotEqual("bar", product.InstanceName);

            parentTx.Commit();

            Assert.True(committed);
            Assert.Equal("foo", product.DefinitionName);
        }
            public void InitializeContext()
            {
                var store = new DslTestStore<PatternModelDomainModel>();

                var serviceProvider = Mock.Get(store.ServiceProvider);
                serviceProvider.Setup(s => s.GetService(typeof(IPatternManager))).Returns(
                    Mock.Of<IPatternManager>(p => p.InstalledToolkits == new List<IInstalledToolkitInfo>()));

                PatternModelSchema authoredPatternModel = null;

                store.TransactionManager.DoWithinTransaction(() =>
                {
                    authoredPatternModel = store.ElementFactory.CreateElement<PatternModelSchema>();
                });

                var uriService = Mock.Of<IUriReferenceService>(
                    u => u.ResolveUri<IInstanceBase>(It.IsAny<Uri>()) == Mock.Of<IProduct>(p =>
                        p.ToolkitInfo.Identifier == "AuthoredToolkit"));

                var patternSchema = authoredPatternModel.Create<PatternSchema>();
                patternSchema.Name = "FooPattern";
                patternSchema.PatternLink = "patternmanager://foo";
                patternSchema.UriService = uriService;

                this.view = patternSchema.Create<ViewSchema>();
                this.view.Name = "View1";

                store.TransactionManager.DoWithinTransaction(() =>
                {
                    this.authoredExtensionPoint = store.ElementFactory.CreateElement<ExtensionPointSchema>("ExtensionPoint1");
                    this.view.ExtensionPoints.Add(this.authoredExtensionPoint);

                });

                // Customize Toolkit
                var tailoredUriService = Mock.Of<IUriReferenceService>(
                    u => u.ResolveUri<IInstanceBase>(It.IsAny<Uri>()) == Mock.Of<IProduct>(p =>
                        p.ToolkitInfo.Identifier == "TailoredToolkit"));

                var tailoredPatternModel = PatternModelSpec.TailorPatternModel(authoredPatternModel, new Version("1.0.0.0"), "AuthoredToolkit");

                store.TransactionManager.DoWithinTransaction(() =>
                {
                    tailoredPatternModel.Pattern.UriService = tailoredUriService;
                    tailoredPatternModel.BaseId = "AuthoredToolkit";
                });

                this.tailoredExtensionPoint = tailoredPatternModel.Pattern.Views[0].ExtensionPoints[0];
            }
Exemplo n.º 49
0
        public void WhenProductInstantiatedWhileSerializing_ThenDoesNotRaiseInstantiatedEvent()
        {
            var store = new DslTestStore<ProductStateStoreDomainModel>();
            store.Store.PropertyBag[ProductState.IsSerializingKey] = true;
            IProductState productState = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement<ProductState>();
            });

            IInstanceBase instantiated = null;
            IProduct product = null;

            productState.ElementInstantiated += (sender, args) => instantiated = args.Value;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                product = productState.CreateProduct();
            });

            Assert.Null(instantiated);
        }
Exemplo n.º 50
0
        public void WhenProductInstantiatedWhileSerializing_ThenDoesNotRaisePropertyChangeEvents()
        {
            var store = new DslTestStore<ProductStateStoreDomainModel>();
            store.Store.PropertyBag[ProductState.IsSerializingKey] = true;
            IProductState productState = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement<ProductState>();
            });

            bool changed = false;
            IProduct product = null;

            productState.PropertyChanged += (sender, args) => changed = true;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                product = productState.CreateProduct();
            });

            Assert.False(changed);
        }
Exemplo n.º 51
0
            public void Initialize()
            {
                this.solutionEvents = new Mock<ISolutionEvents>();
                this.itemEvents = new Mock<IItemEvents>();
                this.messageService = new Mock<IUserMessageService>();

                if (Directory.Exists(solutionItemsDir))
                {
                    Directory.Delete(solutionItemsDir, true);
                }

                Directory.CreateDirectory(solutionItemsDir);

                this.solution = new Solution
                {
                    PhysicalPath = Path.GetTempFileName(),
                    Items =
                    {
                        new SolutionFolder
                        {
                            PhysicalPath = Path.GetTempPath() + "\\Solution Items",
                            Name = "Solution Items"
                        }
                    }
                };

                this.store = new DslTestStore<ProductStateStoreDomainModel>();

                this.toolkitInfo = new Mock<IInstalledToolkitInfo>
                {
                    DefaultValue = DefaultValue.Mock
                };
                this.toolkitInfo.Setup(f => f.Id).Returns("foo");
                this.toolkitInfo.Setup(f => f.Version).Returns(new Version("1.0.0.0"));
                this.toolkitInfo.Setup(f => f.Schema.Pattern.ExtensionId).Returns("foo");

                var installedFactories = new[] { this.toolkitInfo.Object };

                var componentModel = new Mock<IComponentModel>();
                componentModel.Setup(cm => cm.GetService<IEnumerable<IInstalledToolkitInfo>>()).Returns(installedFactories);
                componentModel.Setup(cm => cm.GetService<IToolkitRepository>()).Returns(Mock.Of<IToolkitRepository>());

                var serviceProvider = Mock.Get(this.store.ServiceProvider);
                serviceProvider.Setup(s => s.GetService(typeof(SComponentModel))).Returns(componentModel.Object);
                serviceProvider.Setup(s => s.GetService(typeof(ISolution))).Returns(this.solution);

                this.shellEvents = new Mock<IShellEvents>();
                this.shellEvents.Setup(x => x.IsInitialized).Returns(true);

                this.manager = new TestPatternManager(this.store.ServiceProvider, this.solution, this.shellEvents.Object, this.solutionEvents.Object, this.itemEvents.Object, installedFactories, this.messageService.Object);
            }
Exemplo n.º 52
0
            public void Initialize()
            {
                this.store = new DslTestStore<ProductStateStoreDomainModel>();

                var productInfo = new Mock<IPatternInfo>();

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.product = this.store.ElementFactory.CreateElement<Product>();
                    this.product.Info = productInfo.Object;
                    tx.Commit();
                }

                this.viewInfo = new Mock<IViewInfo>();
                this.viewInfo.Setup(v => v.Id).Returns(Guid.NewGuid());
                this.viewInfo.Setup(v => v.Pattern).Returns(this.product.Info);

                productInfo.Setup(p => p.Views).Returns(new[] { this.viewInfo.Object });
            }
Exemplo n.º 53
0
        public void WhenTransactionCommitedWhileSerializing_ThenDoesNotRaiseTransactionCommitedEvent()
        {
            var store = new DslTestStore<ProductStateStoreDomainModel>();
            store.Store.PropertyBag[ProductState.IsSerializingKey] = true;
            IProductState productState = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement<ProductState>();
            });

            var fired = false;
            productState.TransactionCommited += (sender, args) => fired = true;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState.CreateProduct();
            });

            Assert.False(fired);
        }
Exemplo n.º 54
0
        public void WhenTransactionCommited_ThenRaisesTransactionCommitedEvent()
        {
            var store = new DslTestStore<ProductStateStoreDomainModel>();
            IProductState productState = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement<ProductState>();
            });

            var fired = false;
            productState.TransactionCommited += (sender, args) => fired = true;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState.CreateProduct();
            });

            Assert.True(fired);
        }
Exemplo n.º 55
0
            public void Initialize()
            {
                this.store = new DslTestStore<ProductStateStoreDomainModel>();

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.element = this.store.ElementFactory.CreateElement<Product>();
                    tx.Commit();
                }

                this.bindingContext = new Mock<IDynamicBindingContext> { DefaultValue = DefaultValue.Mock };

                Mock.Get(this.store.ServiceProvider)
                    .Setup(x => x.GetService(typeof(IBindingFactory)))
                    .Returns(Mock.Of<IBindingFactory>(factory =>
                        factory.CreateContext() == this.bindingContext.Object));

                this.element.InstanceName = "Hello";
                this.element.Info = Mock.Of<IElementInfo>(info =>
                    info.Name == "My" &&
                    info.ValidationSettings == new IBindingSettings[] { Mock.Of<IBindingSettings>() });
            }
            public void InitializeContext()
            {
                var type = typeof(ISolutionEvents);

                var store = new DslTestStore<PatternModelDomainModel>();

                store.TransactionManager.DoWithinTransaction(
                    () => this.product = store.ElementFactory.CreateElement<PatternModelSchema>().Create<PatternSchema>());
            }
Exemplo n.º 57
0
        public void WhenProductInstantiated_ThenRetrievesProductInstance()
        {
            var store = new DslTestStore<ProductStateStoreDomainModel>();
            IProductState productState = null;
            IProduct product = null;

            store.TransactionManager.DoWithinTransaction(() =>
            {
                productState = store.ElementFactory.CreateElement<ProductState>();
                product = productState.CreateProduct();
            });

            Assert.Equal(1, productState.FindAll<Product>().Count());
            Assert.Equal(product.Id, productState.FindAll<Product>().ElementAt(0).Id);
        }
            public void Initialize()
            {
                this.store = new DslTestStore<ProductStateStoreDomainModel>();

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.element = this.store.ElementFactory.CreateElement<Product>();
                    tx.Commit();
                }
            }
            public void InitializeContext()
            {
                var store = new DslTestStore<PatternModelDomainModel>();

                store.TransactionManager.DoWithinTransaction(
                    () => this.sourcePatternModel = store.ElementFactory.CreateElement<PatternModelSchema>());

                var serviceProvider = Mock.Get(store.ServiceProvider);
                serviceProvider.Setup(s => s.GetService(typeof(IPatternManager))).Returns(
                    Mock.Of<IPatternManager>(p => p.InstalledToolkits == new List<IInstalledToolkitInfo>()));
            }
        private static Product CreateProduct()
        {
            ProductState productStore = null;
            DslTestStore<ProductStateStoreDomainModel> store = new DslTestStore<ProductStateStoreDomainModel>();
            store.TransactionManager.DoWithinTransaction(() =>
            {
                productStore = store.ElementFactory.CreateElement<ProductState>();
            });

            var product = (Product)productStore.CreateProduct();
            product.InstanceName = "AProduct1";
            product.Info = Mock.Of<IPatternInfo>(i => i.Name == "AProduct" && i.CodeIdentifier == "AProduct");

            return product;
        }