public void ValidationFailsWhenTwoServiceReferencesHasSameNameAndProject() { 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, "Project1")); 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.IsFalse(validator.IsValid(model)); t.Rollback(); } }
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(); } }