Exemple #1
0
        public void PopulationSampleTest(Store store)
        {
            myTestServices.LogValidationErrors("Expect V2=100 Population Mandatory");

            myTestServices.LogMessage("Testing IsIndependent and PopulationMandatoryError associated with implied mandatory constraint");
            ORMModel   model = store.ElementDirectory.FindElements <ORMModel>()[0];
            ObjectType v2    = (ObjectType)model.ObjectTypesDictionary.GetElement("V2").SingleElement;

            using (Transaction t = store.TransactionManager.BeginTransaction("Set IsIndependent"))
            {
                v2.IsIndependent = true;
                t.Commit();
            }
            myTestServices.LogValidationErrors("Set IsIndependent, No error expected after explicit transaction");
            store.UndoManager.Undo();
            DomainTypeDescriptor.CreatePropertyDescriptor(v2, ObjectType.IsIndependentDomainPropertyId).SetValue(v2, true);
            myTestServices.LogValidationErrors("Set IsIndependent, No error expected after implicit transaction");
            store.UndoManager.Undo();

            myTestServices.LogMessage("Testing PopulationMandatoryError by turning on a SimpleMandatory constraint.");
            RoleBase   rightRole  = v2.PlayedRoleCollection[0];
            RoleBase   leftRole   = rightRole.OppositeRole;
            FactType   factType   = rightRole.FactType;
            ObjectType populateMe = leftRole.Role.RolePlayer;
            LinkedElementCollection <ObjectTypeInstance> populateMeInstances = populateMe.ObjectTypeInstanceCollection;
            LinkedElementCollection <ObjectTypeInstance> v2Instances         = v2.ObjectTypeInstanceCollection;

            using (Transaction t = store.TransactionManager.BeginTransaction("Set IsMandatory"))
            {
                leftRole.Role.IsMandatory = true;
                t.Commit();
            }
            myTestServices.LogValidationErrors("Set IsMandatory, expect new errors for instances 'Tom' and 'Dick'");
            FactTypeInstance factTypeInstance;

            using (Transaction t = store.TransactionManager.BeginTransaction("Populate first row"))
            {
                factTypeInstance          = new FactTypeInstance(store);
                factTypeInstance.FactType = factType;
                new FactTypeRoleInstance(leftRole.Role, populateMeInstances[0]).FactTypeInstance = factTypeInstance;
                new FactTypeRoleInstance(rightRole.Role, v2Instances[0]).FactTypeInstance        = factTypeInstance;
                t.Commit();
            }

            myTestServices.LogMessage("Adding second population row one role at a time");
            myTestServices.LogValidationErrors("Add a complete FactTypeInstance for Tom, 1 error remaining for 'Dick'");
            using (Transaction t = store.TransactionManager.BeginTransaction("Populate second row"))
            {
                factTypeInstance          = new FactTypeInstance(store);
                factTypeInstance.FactType = factType;
                new FactTypeRoleInstance(leftRole.Role, populateMeInstances[1]).FactTypeInstance = factTypeInstance;
                t.Commit();
            }
            myTestServices.LogValidationErrors("Add a partial FactTypeInstance for Dick, 1 error remaining for partial FactTypeInstance");
            using (Transaction t = store.TransactionManager.BeginTransaction("Finish second row populations"))
            {
                new FactTypeRoleInstance(rightRole.Role, v2Instances[0]).FactTypeInstance = factTypeInstance;
                t.Commit();
            }
        }
Exemple #2
0
        public void UniqueUniqueImplied_1a(Store store)
        {
            myTestServices.LogValidationErrors("Start with one Implication Error");
            ORMModel             model      = store.ElementDirectory.FindElements <ORMModel>()[0];
            UniquenessConstraint constraint = (UniquenessConstraint)model.ConstraintsDictionary.GetElement("ExternalUniquenessConstraint_A").SingleElement;

            myTestServices.LogMessage("Removing the Implied Uniqueness Costraint...");
            using (Transaction t = store.TransactionManager.BeginTransaction("Remove Implied Uniqueness Costraint"))
            {
                constraint.Delete();
                t.Commit();
            }
            myTestServices.LogValidationErrors("Error is removed with removal of Implied Constraint");
        }
Exemple #3
0
        public void Test3(Store store)
        {
            myTestServices.Compare(store, (MethodInfo)MethodInfo.GetCurrentMethod(), "OriginalOrder");
            ORMModel   model      = store.ElementDirectory.FindElements <ORMModel>()[0];
            ObjectType objectType = (ObjectType)model.ObjectTypesDictionary.GetElement("A").FirstElement;

            myTestServices.LogMessage("Reorder columns on composite pid with no referenced composite elements");
            using (Transaction t = store.TransactionManager.BeginTransaction("Reorder columns on pid with no referenced composite elements"))
            {
                objectType.PreferredIdentifier.RoleCollection.Move(0, 1);
                t.Commit();
            }
            objectType = (ObjectType)model.ObjectTypesDictionary.GetElement("E").FirstElement;
            myTestServices.Compare(store, (MethodInfo)MethodInfo.GetCurrentMethod(), "AfterReorder");

            myTestServices.LogMessage("Reorder columns on composite pid with referenced composite elements");
            using (Transaction t = store.TransactionManager.BeginTransaction("Reorder columns on pid with no referenced composite elements"))
            {
                objectType.PreferredIdentifier.RoleCollection.Move(0, 1);
                t.Commit();
            }
        }
        public void ResolvePreferredTest1(Store store)
        {
            IElementDirectory   directory       = store.ElementDirectory;
            SubtypeFact         FiveToTwo       = (SubtypeFact)directory.GetElement(new Guid("9B85CC3F-FAA1-485B-A6CA-DE65165C6AE5"));
            SubtypeFact         FiveToThree     = (SubtypeFact)directory.GetElement(new Guid("C48F356A-DC20-4CD8-AD6A-EE4518622FFB"));
            SubtypeFact         SixToFive       = (SubtypeFact)directory.GetElement(new Guid("321CD412-8DAA-4D35-8D4E-D8D5915F07E0"));
            SubtypeFact         SixToSeven      = (SubtypeFact)directory.GetElement(new Guid("D6A4C2F2-3F99-4E2F-AB2F-407E03AB6F42"));
            SubtypeFact         FiveToFour      = (SubtypeFact)directory.GetElement(new Guid("DE1FC770-19A5-4CA9-AEF7-CE1204D80270"));
            SubtypeFact         SevenToFour     = (SubtypeFact)directory.GetElement(new Guid("71D29425-481E-445B-8F8A-63E9F29F761A"));
            ORMModel            model           = FiveToTwo.Model;
            RoleValueConstraint valueConstraint = (RoleValueConstraint)model.ConstraintsDictionary.GetElement("RoleValueConstraint1").SingleElement;

            myTestServices.LogValidationErrors("Expected three initial errors");

            myTestServices.LogMessage("Scenario 1: Make 5->2 preferred path, sibling and downstream subtypes should all be preferred");
            DomainTypeDescriptor.CreatePropertyDescriptor(FiveToTwo, SubtypeFact.ProvidesPreferredIdentifierDomainPropertyId).SetValue(FiveToTwo, true);
            myTestServices.LogValidationErrors("No errors expected");
            myTestServices.LogMessage("5->4, 6->5, 6->7 are on the preferred path: " + (FiveToFour.ProvidesPreferredIdentifier && SixToFive.ProvidesPreferredIdentifier && SixToSeven.ProvidesPreferredIdentifier).ToString());
            myTestServices.LogMessage("ValueConstraint should be a string type: " + valueConstraint.Text);

            myTestServices.LogMessage("Scenario 2: Make 5->3 preferred path, downstream subtypes are no ambiguous");
            DomainTypeDescriptor.CreatePropertyDescriptor(FiveToThree, SubtypeFact.ProvidesPreferredIdentifierDomainPropertyId).SetValue(FiveToThree, true);
            myTestServices.LogValidationErrors("Two errors expected");
            myTestServices.LogMessage("5->2, 5->4, 6->5, 6->7 are not preferred: " + (!(FiveToTwo.ProvidesPreferredIdentifier || FiveToFour.ProvidesPreferredIdentifier || SixToFive.ProvidesPreferredIdentifier || SixToSeven.ProvidesPreferredIdentifier)).ToString());

            myTestServices.LogMessage("Scenario 3: Make 6->5 preferred path");
            DomainTypeDescriptor.CreatePropertyDescriptor(SixToFive, SubtypeFact.ProvidesPreferredIdentifierDomainPropertyId).SetValue(SixToFive, true);
            myTestServices.LogValidationErrors("No errors expected");
            myTestServices.LogMessage("6->7 is not on the preferred path: " + (!SixToSeven.ProvidesPreferredIdentifier).ToString());
            myTestServices.LogMessage("ValueConstraint should be a number type: " + valueConstraint.Text);

            myTestServices.LogMessage("Scenario 4: Make 6->7 preferred path");
            DomainTypeDescriptor.CreatePropertyDescriptor(SixToSeven, SubtypeFact.ProvidesPreferredIdentifierDomainPropertyId).SetValue(SixToSeven, true);
            myTestServices.LogValidationErrors("No errors expected");
            myTestServices.LogMessage("6->5 is not on the preferred path: " + (!SixToFive.ProvidesPreferredIdentifier).ToString());
            myTestServices.LogMessage("ValueConstraint should be a string type: " + valueConstraint.Text);

            myTestServices.LogMessage("Scenario 5: Delete 7->4 to break subtype structure");
            using (Transaction t = store.TransactionManager.BeginTransaction("Break graph"))
            {
                SevenToFour.Delete();
                t.Commit();
            }
            myTestServices.LogValidationErrors("Expecting invalid graph, detached valuetype, and no reference scheme errors");

            myTestServices.LogMessage("Scenario 6: Delete 6->5 to make graph valid");
            using (Transaction t = store.TransactionManager.BeginTransaction("Graph OK"))
            {
                SixToFive.Delete();
                t.Commit();
            }
            myTestServices.LogValidationErrors("Expecting detached valuetype and no reference scheme errors");

            myTestServices.LogMessage("Scenario 7: Set identifier on 7 to clear errors");
            using (Transaction t = store.TransactionManager.BeginTransaction("Clear errors"))
            {
                SixToSeven.Supertype.ReferenceModeString = "id";
                t.Commit();
            }
            myTestServices.LogValidationErrors("No errors expected");

            myTestServices.LogValidationErrors("Scenario 8: (Undo scenarios 5-7) Make 5->4 preferred path and give 4 an explicit id in one transaction");
            store.UndoManager.Undo();
            store.UndoManager.Undo();
            store.UndoManager.Undo();
            using (Transaction t = store.TransactionManager.BeginTransaction("Change id and make preferred in one transaction"))
            {
                // Note that doing this in the opposite order in two transactions has the same result
                FiveToFour.ProvidesPreferredIdentifier   = true;
                FiveToFour.Supertype.ReferenceModeString = "id";
                t.Commit();
            }
            myTestServices.LogValidationErrors("No errors expected");

            myTestServices.LogValidationErrors("Scenario 9: (Undo scenario 8) Make 5->4 preferred path then give 4 an explicit id to make 5 and 6 ambiguous");
            store.UndoManager.Undo();
            using (Transaction t = store.TransactionManager.BeginTransaction("Change preferred path"))
            {
                FiveToFour.ProvidesPreferredIdentifier = true;
                t.Commit();
            }
            using (Transaction t = store.TransactionManager.BeginTransaction("Introduce id that interferes with split identifier path"))
            {
                FiveToFour.Supertype.ReferenceModeString = "id";
                t.Commit();
            }
        }