private void CreateHostDesignerModel(ServiceContract sc)
        {
            hdStore       = new Store(serviceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(HostDesignerDomainModel));
            hdDomainModel = hdStore.GetDomainModel <HostDesignerDomainModel>();
            hdTransaction = hdStore.TransactionManager.BeginTransaction();
            hdModel       = (HostDesignerModel)hdDomainModel.CreateElement(new Partition(hdStore), typeof(HostDesignerModel), null);

            HostApplication app = (HostApplication)hdStore.ElementFactory.CreateElement(HostApplication.DomainClassId);

            app.ImplementationTechnology = new HostDesignerWcfExtensionProvider();

            reference = (ServiceReference)hdStore.ElementFactory.CreateElement(ServiceReference.DomainClassId);

            //mel://[DSLNAMESPACE]\[MODELELEMENTTYPE]\[MODELELEMENT.GUID]@[PROJECT]\[MODELFILE]
            string serviceMoniker = string.Format(@"mel://{0}\{1}\{2}@{3}\{4}",
                                                  sc.GetType().Namespace,
                                                  serviceContractName,
                                                  sc.Id.ToString(),
                                                  serviceContractModelProjectName, serviceContractModelFileName);

            reference.Name = serviceMelReferenceName;
            reference.ServiceImplementationType = new MockModelBusReference(sc);

            app.ServiceDescriptions.Add(reference);
        }
        public void ValidationPassedWhenProjectDiffersButNameIsSame()
        {
            Store store = new Store(typeof(CoreDesignSurfaceDomainModel), typeof(HostDesignerDomainModel));

            using (Transaction t = store.TransactionManager.BeginTransaction())
            {
                HostApplication hostApp1 = new HostApplication(store,
                                                               new PropertyAssignment(HostApplication.ImplementationProjectDomainPropertyId, "Project1"));
                HostApplication hostApp2 = new HostApplication(store,
                                                               new PropertyAssignment(HostApplication.ImplementationProjectDomainPropertyId, "SomeOtherProject"));

                HostDesignerModel model = new HostDesignerModel(store);

                model.HostApplications.Add(hostApp1);
                model.HostApplications.Add(hostApp2);

                ServiceReference serviceReference1 = new ServiceReference(store,
                                                                          new PropertyAssignment(ServiceReference.NameDomainPropertyId, "ServiceRef1"));
                ServiceReference serviceReference2 = new ServiceReference(store,
                                                                          new PropertyAssignment(ServiceReference.NameDomainPropertyId, "ServiceRef1"));


                hostApp1.ServiceDescriptions.Add(serviceReference1);
                hostApp2.ServiceDescriptions.Add(serviceReference2);

                TestableHostModelContainsUniqueServiceReferencesAcrossHostsValidator validator = new TestableHostModelContainsUniqueServiceReferencesAcrossHostsValidator();

                Assert.IsTrue(validator.IsValid(model));


                t.Rollback();
            }
        }
        public void ValidationPassedWhenProjectDiffersButNameIsSame()
        {
            Store store = new Store(typeof(CoreDesignSurfaceDomainModel), typeof(HostDesignerDomainModel));

            using (Transaction t = store.TransactionManager.BeginTransaction())
            {
                ClientApplication clientApp1 = new ClientApplication(store,
                                                                     new PropertyAssignment(ClientApplication.ImplementationProjectDomainPropertyId, "Project1"));
                ClientApplication clientApp2 = new ClientApplication(store,
                                                                     new PropertyAssignment(ClientApplication.ImplementationProjectDomainPropertyId, "AnotherProject"));

                HostDesignerModel model = new HostDesignerModel(store);

                model.ClientApplications.Add(clientApp1);
                model.ClientApplications.Add(clientApp2);

                Proxy proxy1 = new Proxy(store,
                                         new PropertyAssignment(Proxy.NameDomainPropertyId, "Proxy1"));
                Proxy proxy2 = new Proxy(store,
                                         new PropertyAssignment(Proxy.NameDomainPropertyId, "Proxy1"));


                clientApp1.Proxies.Add(proxy1);
                clientApp2.Proxies.Add(proxy2);

                TestableHostModelContainsUniqueProxyNamesAcrossClientsValidator validator = new TestableHostModelContainsUniqueProxyNamesAcrossClientsValidator();


                t.Rollback();
            }
        }
        public void ValidationOnlyAppliesToServicesReferencesInDifferentHosts()
        {
            Store store = new Store(typeof(CoreDesignSurfaceDomainModel), typeof(HostDesignerDomainModel));

            using (Transaction t = store.TransactionManager.BeginTransaction())
            {
                ClientApplication clientApp = new ClientApplication(store,
                                                                    new PropertyAssignment(ClientApplication.ImplementationProjectDomainPropertyId, "Project1"));

                HostDesignerModel model = new HostDesignerModel(store);

                model.ClientApplications.Add(clientApp);

                Proxy proxy1 = new Proxy(store,
                                         new PropertyAssignment(Proxy.NameDomainPropertyId, "Proxy1"));
                Proxy proxy2 = new Proxy(store,
                                         new PropertyAssignment(Proxy.NameDomainPropertyId, "Proxy1"));


                clientApp.Proxies.Add(proxy1);
                clientApp.Proxies.Add(proxy2);

                TestableHostModelContainsUniqueProxyNamesAcrossClientsValidator validator = new TestableHostModelContainsUniqueProxyNamesAcrossClientsValidator();

                Assert.IsTrue(validator.IsValid(model));


                t.Rollback();
            }
        }
            public bool IsValid(HostDesignerModel hostModel)
            {
                ValidationResults vrs = new ValidationResults();

                this.DoValidate(hostModel.HostApplications, hostModel.HostApplications, "", vrs);

                return(new List <ValidationResult>(vrs).Count == 0);
            }
Example #6
0
        public void TestInitialize()
        {
            serviceProvider = new MockMappingServiceProvider();

            scStore       = new Store(serviceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(ServiceContractDslDomainModel));
            scDomainModel = scStore.GetDomainModel <ServiceContractDslDomainModel>();
            scTransaction = scStore.TransactionManager.BeginTransaction();

            scModel = (ServiceContractModel)scDomainModel.CreateElement(new Partition(scStore), typeof(ServiceContractModel), null);
            scModel.ImplementationTechnology = new ServiceContractWCFExtensionProvider();
            scModel.ProjectMappingTable      = projectMappingTableName;

            ServiceContract sc = scStore.ElementFactory.CreateElement(ServiceContract.DomainClassId) as ServiceContract;

            sc.Name = serviceContractName;

            scModel.ServiceContracts.Add(sc);

            hdStore       = new Store(serviceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(HostDesignerDomainModel));
            hdDomainModel = hdStore.GetDomainModel <HostDesignerDomainModel>();
            hdTransaction = hdStore.TransactionManager.BeginTransaction();
            hdModel       = (HostDesignerModel)hdDomainModel.CreateElement(new Partition(hdStore), typeof(HostDesignerModel), null);

            HostApplication app = (HostApplication)hdStore.ElementFactory.CreateElement(HostApplication.DomainClassId);

            app.ImplementationTechnology = new HostDesignerWcfExtensionProvider();

            reference = (ServiceReference)hdStore.ElementFactory.CreateElement(ServiceReference.DomainClassId);

            //mel://[DSLNAMESPACE]\[MODELELEMENTTYPE]\[MODELELEMENT.GUID]@[PROJECT]\[MODELFILE]
            string serviceMoniker = string.Format(@"mel://{0}\{1}\{2}@{3}\{4}",
                                                  sc.GetType().Namespace,
                                                  serviceContractName,
                                                  sc.Id.ToString(),
                                                  serviceContractModelProjectName, serviceContractModelFileName);

            reference.Name = serviceMelReferenceName;
            reference.ServiceImplementationType = new MockModelBusReference(sc);

            app.ServiceDescriptions.Add(reference);

            // Initialize validator's config
            attributes = new NameValueCollection();
            attributes.Add("elementNameProperty", "Name");
        }