Example #1
0
        internal AssociationType(RelationType relationType, Guid id)
            : base(relationType.MetaPopulation)
        {
            this.relationType = relationType;

            this.Id = id;

            relationType.MetaPopulation.OnAssociationTypeCreated(this);
        }
Example #2
0
 private IObject[] CreateRolesWithSameClass(RelationType relationType, ObjectType roleClass)
 {
     return this.CreateRolesWithSameClass(this.GetSession(), relationType, roleClass);
 }
Example #3
0
        private IObject[] CreateRolesWithDifferentClass(ISession session, RelationType relationType)
        {
            IObject[] allRoles = this.CreateArray(relationType.RoleType.ObjectType, this.GetRoleCount());
            var concreteClasses = relationType.RoleType.ObjectType.ConcreteClasses;
            for (int i = 0; i < allRoles.Length; i++)
            {
                int classIndex = i % concreteClasses.Length;
                ObjectType roleType = concreteClasses[classIndex];
                allRoles[i] = session.Create(roleType);
            }

            return allRoles;
        }
Example #4
0
 private IObject[] CreateRolesWithDifferentClass(RelationType relationType)
 {
     return this.CreateRolesWithDifferentClass(this.GetSession(), relationType);
 }
Example #5
0
            private void AssertExclusiveRelation(RelationType relationType, IObject[] associations, IObject association, IObject role, bool transactionFlag, int testRepeat, int assertRepeat)
            {
                for (int testRepeatIndex = 0; testRepeatIndex < testRepeat; testRepeatIndex++)
                {
                    for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                    {
                        Assert.Contains(role, (IObject[])association.Strategy.GetCompositeRoles(relationType.RoleType));
                    }

                    for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                    {
                        Assert.AreEqual(1, ((IObject[])association.Strategy.GetCompositeRoles(relationType.RoleType)).Length);
                    }

                    for (int iAssociation = 0; iAssociation < associations.Length; iAssociation++)
                    {
                        IObject testAssociation = associations[iAssociation];
                        for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                        {
                            if (testAssociation.Equals(association))
                            {
                                Assert.AreEqual(association, role.Strategy.GetCompositeAssociation(relationType.AssociationType));
                            }
                            else
                            {
                                Assert.IsEmpty((IObject[])testAssociation.Strategy.GetCompositeRoles(relationType.RoleType));
                            }
                        }
                    }

                    this.Commit(transactionFlag);
                }
            }
Example #6
0
 public Tree Add(RelationType relationType, Tree tree)
 {
     return(this.Add(relationType.RoleType, tree));
 }
Example #7
0
            public void Test(RelationType relationType, IObject association, IObject[] roles, IObject[] emptyRoles, IObject[] rolesOtherDatabase, bool transactionFlag, int repeat, int testRepeat, int assertRepeat)
            {
                this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);

                // Add Null
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.AddCompositeRole(relationType.RoleType, null);
                    this.Commit(transactionFlag);

                    this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);
                }

                // Add Empty
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.AddCompositeRole(relationType.RoleType, null);
                    this.Commit(transactionFlag);

                    this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);
                }

                // Add
                for (int i = 0; i < roles.Length; i++)
                {
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        var role = roles[i];
                        association.Strategy.AddCompositeRole(relationType.RoleType, role);
                        this.Commit(transactionFlag);

                        this.AssertRelationForwardExists(relationType, association, roles, i, transactionFlag, testRepeat, assertRepeat);
                    }
                }

                // Add Null
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.AddCompositeRole(relationType.RoleType, null);
                    this.Commit(transactionFlag);

                    this.AssertRelationExists(relationType, association, roles, transactionFlag, testRepeat, assertRepeat);
                }

                // Add Empty
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.AddCompositeRole(relationType.RoleType, null);
                    this.Commit(transactionFlag);

                    this.AssertRelationExists(relationType, association, roles, transactionFlag, testRepeat, assertRepeat);
                }

                // Remove Null
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.RemoveCompositeRole(relationType.RoleType, null);
                    this.Commit(transactionFlag);

                    this.AssertRelationExists(relationType, association, roles, transactionFlag, testRepeat, assertRepeat);
                }

                // Remove Forwards
                for (int i = 0; i < roles.Length; i++)
                {
                    var role = roles[i];
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        association.Strategy.RemoveCompositeRole(relationType.RoleType, role);
                        this.Commit(transactionFlag);

                        this.AssertRelationForwardNotExists(relationType, association, roles, i, transactionFlag, testRepeat, assertRepeat);
                    }
                }

                this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);

                // Add
                for (int i = 0; i < roles.Length; i++)
                {
                    var role = roles[i];
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        association.Strategy.AddCompositeRole(relationType.RoleType, role);
                        this.Commit(transactionFlag);

                        this.AssertRelationForwardExists(relationType, association, roles, i, transactionFlag, testRepeat, assertRepeat);
                    }
                }

                // Remove Backwards
                for (int i = roles.Length - 1; i >= 0; i--)
                {
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        var role = roles[i];
                        association.Strategy.RemoveCompositeRole(relationType.RoleType, role);
                        this.Commit(transactionFlag);

                        this.AssertRelationBackwardsNotExists(relationType, association, roles, i, transactionFlag, testRepeat, assertRepeat);
                    }
                }

                this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);

                // Add
                for (int i = 0; i < roles.Length; i++)
                {
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        var role = roles[i];
                        association.Strategy.AddCompositeRole(relationType.RoleType, role);
                        this.Commit(transactionFlag);

                        this.AssertRelationForwardExists(relationType, association, roles, i, transactionFlag, testRepeat, assertRepeat);
                    }
                }

                // RemoveAll
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.RemoveCompositeRoles(relationType.RoleType);
                    this.Commit(transactionFlag);
                    this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);
                }

                // Add
                for (int i = 0; i < roles.Length; i++)
                {
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        var role = roles[i];
                        association.Strategy.AddCompositeRole(relationType.RoleType, role);
                        this.Commit(transactionFlag);

                        this.AssertRelationForwardExists(relationType, association, roles, i, transactionFlag, testRepeat, assertRepeat);
                    }
                }

                // Set Null
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.SetCompositeRoles(relationType.RoleType, (IObject[])null);
                    this.Commit(transactionFlag);

                    this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);
                }

                // Add
                for (int i = 0; i < roles.Length; i++)
                {
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        var role = roles[i];
                        association.Strategy.AddCompositeRole(relationType.RoleType, role);
                        this.Commit(transactionFlag);

                        this.AssertRelationForwardExists(relationType, association, roles, i, transactionFlag, testRepeat, assertRepeat);
                    }
                }

                // Set Empty Array
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.SetCompositeRoles(relationType.RoleType, emptyRoles);
                    this.Commit(transactionFlag);
                    this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);
                }

                // Add different Population
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    try
                    {
                        association.Strategy.AddCompositeRole(relationType.RoleType, rolesOtherDatabase[0]);
                        Assert.Fail();
                    }
                    catch (ArgumentException exception)
                    {
                        Assert.IsNotNull(exception);
                    }

                    this.Commit(transactionFlag);

                    for (int testRepeatIndex = 0; testRepeatIndex < testRepeat; testRepeatIndex++)
                    {
                        this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);
                    }
                }

                // Set different Population
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    try
                    {
                        association.Strategy.SetCompositeRoles(relationType.RoleType, rolesOtherDatabase);
                        Assert.Fail();
                    }
                    catch (ArgumentException exception)
                    {
                        Assert.IsNotNull(exception);
                    }

                    this.Commit(transactionFlag);

                    for (int testRepeatIndex = 0; testRepeatIndex < testRepeat; testRepeatIndex++)
                    {
                        this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);
                    }
                }

                // TODO: (Exist)
            }
Example #8
0
            private void AssertRelationForwardNotExists(RelationType relationType, IObject[] associations, IObject[] roles, int index, bool transactionFlag, int testRepeat)
            {
                for (int testRepeatIndex = 0; testRepeatIndex < testRepeat; testRepeatIndex++)
                {
                    for (int k = 0; k < associations.Length; k++)
                    {
                        IObject testAssociation = associations[k];
                        IObject testRole = roles[k];
                        if (k <= index)
                        {
                            Assert.AreEqual(0, ((IObject[])testAssociation.Strategy.GetCompositeRoles(relationType.RoleType)).Length);
                            CollectionAssert.DoesNotContain((IObject[])testAssociation.Strategy.GetCompositeRoles(relationType.RoleType), testRole);
                            Assert.IsNull(testRole.Strategy.GetCompositeAssociation(relationType.AssociationType));
                        }
                        else
                        {
                            Assert.AreEqual(1, ((IObject[])testAssociation.Strategy.GetCompositeRoles(relationType.RoleType)).Length);
                            Assert.Contains(testRole, (IObject[])testAssociation.Strategy.GetCompositeRoles(relationType.RoleType));
                            Assert.AreEqual(testAssociation, testRole.Strategy.GetCompositeAssociation(relationType.AssociationType));
                        }
                    }

                    this.Commit(transactionFlag);
                }
            }
Example #9
0
            private void AssertRelationNotExists(RelationType relationType, IObject association, IObject role, bool transactionFlag, int testRepeat, int assertRepeat)
            {
                for (int testRepeatIndex = 0; testRepeatIndex < testRepeat; testRepeatIndex++)
                {
                    for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                    {
                        Assert.IsEmpty((IObject[])association.Strategy.GetCompositeRoles(relationType.RoleType));
                    }

                    for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                    {
                        Assert.IsNull(role.Strategy.GetCompositeAssociation(relationType.AssociationType));
                    }

                    this.Commit(transactionFlag);
                }
            }
Example #10
0
            public void Test(RelationType relationType, IObject association, IObject[] roles, IObject[] emptyRoles, bool transactionFlag, int repeat, int testRepeat, int assertRepeat)
            {
                this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);

                // Add Null
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.AddCompositeRole(relationType.RoleType, null);
                    this.Commit(transactionFlag);

                    this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);
                }

                // Add Empty
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.AddCompositeRole(relationType.RoleType, null);
                    this.Commit(transactionFlag);

                    this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);
                }

                // Set
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.SetCompositeRoles(relationType.RoleType, roles);
                    this.Commit(transactionFlag);

                    this.AssertRelationExists(relationType, association, roles, transactionFlag, testRepeat, assertRepeat);
                }

                // Add Null
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.AddCompositeRole(relationType.RoleType, null);
                    this.Commit(transactionFlag);

                    this.AssertRelationExists(relationType, association, roles, transactionFlag, testRepeat, assertRepeat);
                }

                // Add Empty
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.AddCompositeRole(relationType.RoleType, null);
                    this.Commit(transactionFlag);

                    this.AssertRelationExists(relationType, association, roles, transactionFlag, testRepeat, assertRepeat);
                }

                // Remove Null
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.RemoveCompositeRole(relationType.RoleType, null);
                    this.Commit(transactionFlag);

                    this.AssertRelationExists(relationType, association, roles, transactionFlag, testRepeat, assertRepeat);
                }

                // Remove
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.RemoveCompositeRoles(relationType.RoleType);
                    this.Commit(transactionFlag);

                    this.AssertRelationNotExists(relationType, association, roles, transactionFlag, testRepeat, assertRepeat);
                }

                // Set
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.SetCompositeRoles(relationType.RoleType, roles);
                    this.Commit(transactionFlag);

                    this.AssertRelationExists(relationType, association, roles, transactionFlag, testRepeat, assertRepeat);
                }

                // Remove All
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.RemoveCompositeRoles(relationType.RoleType);
                    this.Commit(transactionFlag);

                    this.AssertRelationNotExists(relationType, association, roles, transactionFlag, testRepeat, assertRepeat);
                }

                // Add
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.SetCompositeRoles(relationType.RoleType, roles);
                    this.Commit(transactionFlag);

                    this.AssertRelationExists(relationType, association, roles, transactionFlag, testRepeat, assertRepeat);
                }

                // Remove All
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.RemoveCompositeRoles(relationType.RoleType);
                    this.Commit(transactionFlag);
                    this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);
                }

                // Set
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.SetCompositeRoles(relationType.RoleType, roles);
                    this.Commit(transactionFlag);

                    this.AssertRelationExists(relationType, association, roles, transactionFlag, testRepeat, assertRepeat);
                }

                // Set Null
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.SetCompositeRoles(relationType.RoleType, (IObject[])null);
                    this.Commit(transactionFlag);
                    this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);
                }

                // Set
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.SetCompositeRoles(relationType.RoleType, roles);
                    this.Commit(transactionFlag);

                    this.AssertRelationExists(relationType, association, roles, transactionFlag, testRepeat, assertRepeat);
                }

                // Set Empty Array
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.SetCompositeRoles(relationType.RoleType, emptyRoles);
                    this.Commit(transactionFlag);
                    this.AssertRelationNotExists(relationType, association, roles, transactionFlag, assertRepeat, testRepeat);
                }

                // TODO: (Exist)
            }
Example #11
0
            private void AssertRelation(RelationType relationType, IObject association, IObject role, bool transactionFlag, int testRepeat, int assertRepeat)
            {
                for (int testRepeatIndex = 0; testRepeatIndex < testRepeat; testRepeatIndex++)
                {
                    for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                    {
                        Assert.AreEqual(1, ((IObject[])association.Strategy.GetCompositeRoles(relationType.RoleType)).Length);
                    }

                    for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                    {
                        Assert.Contains(role, (IObject[])association.Strategy.GetCompositeRoles(relationType.RoleType));
                    }

                    for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                    {
                        Assert.AreEqual(association, role.Strategy.GetCompositeAssociation(relationType.AssociationType));
                    }

                    this.Commit(transactionFlag);
                }
            }
Example #12
0
            public void Test(RelationType relationType, IObject association, IObject role, IObject[] roles, IObject[] emptyRoles, bool transactionFlag, int repeat, int testRepeat, int assertRepeat)
            {
                this.AssertRelationNotExists(relationType, association, role, transactionFlag, testRepeat, assertRepeat);

                // Add
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.AddCompositeRole(relationType.RoleType, role);
                    this.Commit(transactionFlag);
                    this.AssertRelation(relationType, association, role, transactionFlag, testRepeat, assertRepeat);
                }

                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.RemoveCompositeRoles(relationType.RoleType);
                    this.Commit(transactionFlag);
                    this.AssertRelationNotExists(relationType, association, role, transactionFlag, testRepeat, assertRepeat);
                }

                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.SetCompositeRoles(relationType.RoleType, roles);
                    this.Commit(transactionFlag);
                    this.AssertRelation(relationType, association, role, transactionFlag, testRepeat, assertRepeat);
                }

                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.RemoveCompositeRoles(relationType.RoleType);
                    this.Commit(transactionFlag);
                    this.AssertRelationNotExists(relationType, association, role, transactionFlag, testRepeat, assertRepeat);
                }

                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.SetCompositeRoles(relationType.RoleType, roles);
                    this.Commit(transactionFlag);
                    this.AssertRelation(relationType, association, role, transactionFlag, testRepeat, assertRepeat);
                }

                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.SetCompositeRoles(relationType.RoleType, (IObject[])null);
                    this.Commit(transactionFlag);
                    this.AssertRelationNotExists(relationType, association, role, transactionFlag, testRepeat, assertRepeat);
                }

                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    association.Strategy.SetCompositeRoles(relationType.RoleType, emptyRoles);
                    this.Commit(transactionFlag);
                    this.AssertRelationNotExists(relationType, association, role, transactionFlag, testRepeat, assertRepeat);
                }
            }
Example #13
0
            private void AssertRelationExists(RelationType relationType, IObject[] associations, IObject association, IObject[] roles, bool transactionFlag, int testRepeat, int assertRepeat)
            {
                for (int testRepeatIndex = 0; testRepeatIndex < testRepeat; testRepeatIndex++)
                {
                    for (int iAssociation = 0; iAssociation < associations.Length; iAssociation++)
                    {
                        IObject testAssociation = associations[iAssociation];
                        if (testAssociation.Equals(association))
                        {
                            for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                            {
                                Assert.AreEqual(this.GetRoleCount(), ((IObject[])association.Strategy.GetCompositeRoles(relationType.RoleType)).Length);
                            }

                            for (int iRole = 0; iRole < roles.Length; iRole++)
                            {
                                var role = roles[iRole];
                                for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                                {
                                    Assert.Contains(role, (IObject[])association.Strategy.GetCompositeRoles(relationType.RoleType));
                                }

                                for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                                {
                                    Assert.AreEqual(association, role.Strategy.GetCompositeAssociation(relationType.AssociationType));
                                }
                            }
                        }
                        else
                        {
                            for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                            {
                                Assert.AreEqual(0, ((IObject[])testAssociation.Strategy.GetCompositeRoles(relationType.RoleType)).Length);
                            }

                            for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                            {
                                Assert.IsEmpty((IObject[])testAssociation.Strategy.GetCompositeRoles(relationType.RoleType));
                            }
                        }
                    }

                    this.Commit(transactionFlag);
                }
            }
Example #14
0
        private IObject[] CreateRolesWithSameClass(ISession session, RelationType relationType, ObjectType roleClass)
        {
            IObject[] allRoles = this.CreateArray(relationType.RoleType.ObjectType, this.GetRoleCount());
            for (int i = 0; i < allRoles.Length; i++)
            {
                allRoles[i] = session.Create(roleClass);
            }

            return allRoles;
        }
Example #15
0
            private void AssertRelationForwardExists(RelationType relationType, IObject association, IObject[] roles, int roleIndex, bool transactionFlag, int testRepeat, int assertRepeat)
            {
                for (int testRepeatIndex = 0; testRepeatIndex < testRepeat; testRepeatIndex++)
                {
                    for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                    {
                        Assert.IsNotEmpty((IObject[])association.Strategy.GetCompositeRoles(relationType.RoleType));
                    }

                    for (int k = 0; k < roles.Length; k++)
                    {
                        IObject testRole = roles[k];
                        if (k <= roleIndex)
                        {
                            for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                            {
                                Assert.Contains(testRole, (IObject[])association.Strategy.GetCompositeRoles(relationType.RoleType));
                            }

                            for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                            {
                                Assert.AreEqual(association, testRole.Strategy.GetCompositeAssociation(relationType.AssociationType));
                            }
                        }
                        else
                        {
                            for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                            {
                                CollectionAssert.DoesNotContain((IObject[])association.Strategy.GetCompositeRoles(relationType.RoleType), testRole);
                            }

                            for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                            {
                                Assert.IsNull(testRole.Strategy.GetCompositeAssociation(relationType.AssociationType));
                            }
                        }
                    }

                    this.Commit(transactionFlag);
                }
            }
Example #16
0
            public void Test(RelationType relationType, IObject[] associations, IObject[] roles, bool transactionFlag, int repeat, int testRepeat, int assertRepeat)
            {
                this.AssertRelationNotExists(relationType, associations, roles, transactionFlag, assertRepeat, testRepeat);

                // Add Null
                for (int i = 0; i < associations.Length; i++)
                {
                    var association = associations[i];
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        association.Strategy.AddCompositeRole(relationType.RoleType, null);
                        this.Commit(transactionFlag);
                    }

                    this.AssertRelationNotExists(relationType, associations, roles, transactionFlag, testRepeat, assertRepeat);
                }

                // Remove Null
                for (int i = 0; i < associations.Length; i++)
                {
                    var association = associations[i];
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        association.Strategy.RemoveCompositeRole(relationType.RoleType, null);
                        this.Commit(transactionFlag);
                    }

                    this.AssertRelationNotExists(relationType, associations, roles, transactionFlag, testRepeat, assertRepeat);
                }

                // Add
                for (int i = 0; i < associations.Length; i++)
                {
                    var association = associations[i];
                    var role = roles[i];
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        association.Strategy.AddCompositeRole(relationType.RoleType, role);
                        this.Commit(transactionFlag);

                        this.AssertRelationForwardExists(relationType, associations, roles, i, transactionFlag, testRepeat);
                    }
                }

                // Remove Forward
                for (int i = 0; i < associations.Length; i++)
                {
                    var association = associations[i];
                    var role = roles[i];
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        association.Strategy.RemoveCompositeRole(relationType.RoleType, role);
                        this.Commit(transactionFlag);

                        this.AssertRelationForwardNotExists(relationType, associations, roles, i, transactionFlag, testRepeat);
                    }
                }

                // Add
                for (int i = 0; i < associations.Length; i++)
                {
                    var association = associations[i];
                    var role = roles[i];
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        association.Strategy.AddCompositeRole(relationType.RoleType, role);
                        this.Commit(transactionFlag);

                        this.AssertRelationForwardExists(relationType, associations, roles, i, transactionFlag, testRepeat);
                    }
                }

                // Remove Backward
                for (int i = associations.Length - 1; i >= 0; i--)
                {
                    var association = associations[i];
                    var role = roles[i];
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        association.Strategy.RemoveCompositeRole(relationType.RoleType, role);
                        this.Commit(transactionFlag);

                        this.AssertRelationBackwardNotExists(relationType, associations, roles, i, transactionFlag, testRepeat);
                    }
                }
            }
Example #17
0
        private IObject[] CreateAssociationsWithDifferentClass(RelationType relationType)
        {
            IObject[] associations = this.CreateArray(relationType.AssociationType.ObjectType, this.GetAssociationCount());
            var concreteClasses = relationType.AssociationType.ObjectType.ConcreteClasses;
            for (int i = 0; i < associations.Length; i++)
            {
                int classIndex = i % concreteClasses.Length;
                var associationType = concreteClasses[classIndex];
                associations[i] = this.GetSession().Create(associationType);
            }

            return associations;
        }
Example #18
0
            private void AssertRelationNotExists(RelationType relationType, IObject[] associations, IObject[] roles, bool transactionFlag, int testRepeat, int assertRepeat)
            {
                for (int testRepeatIndex = 0; testRepeatIndex < testRepeat; testRepeatIndex++)
                {
                    for (int iAssociation = 0; iAssociation < associations.Length; iAssociation++)
                    {
                        var association = associations[iAssociation];
                        for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                        {
                            Assert.IsEmpty((IObject[])association.Strategy.GetCompositeRoles(relationType.RoleType));
                        }
                    }

                    for (int iRole = 0; iRole < roles.Length; iRole++)
                    {
                        IObject testRole = roles[iRole];
                        for (int assertRepeateIndex = 0; assertRepeateIndex < assertRepeat; assertRepeateIndex++)
                        {
                            Assert.IsNull(testRole.Strategy.GetCompositeAssociation(relationType.AssociationType));
                        }
                    }

                    if (transactionFlag)
                    {
                        this.GetSession().Commit();
                    }
                }
            }
Example #19
0
        private IObject[] CreateAssociationsWithSameClass(RelationType relationType, ObjectType associationClass)
        {
            IObject[] associations = this.CreateArray(relationType.AssociationType.ObjectType, this.GetAssociationCount());
            for (int i = 0; i < this.GetAssociationCount(); i++)
            {
                associations[i] = this.GetSession().Create(associationClass);
            }

            return associations;
        }
Example #20
0
        internal void OnRelationTypeCreated(RelationType relationType)
        {
            this.relationTypes.Add(relationType);
            this.metaObjectById.Add(relationType.Id, relationType);

            this.Stale();
        }
Example #21
0
 private IObject[] CreateRoles(RelationType relationType, IObject role)
 {
     IObject[] roles = this.CreateArray(relationType.RoleType.ObjectType, 1);
     roles[0] = role;
     return roles;
 }
Example #22
0
 public Tree Add(RelationType relationType, Tree tree)
 {
     return this.Add(relationType.RoleType, tree);
 }
Example #23
0
            public void Test(RelationType relationType, IObject[] associations, IObject role, IObject[] roles, IObject[] emptyRoles, bool transactionFlag, int repeat, int testRepeat, int assertRepeat)
            {
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    this.AssertRelationNotExists(relationType, associations, role, transactionFlag, testRepeat, assertRepeat);
                }

                // Add Null
                for (int i = 0; i < associations.Length; i++)
                {
                    var association = associations[i];
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        association.Strategy.AddCompositeRole(relationType.RoleType, null);
                        this.Commit(transactionFlag);
                    }

                    this.AssertRelationNotExists(relationType, associations, role, transactionFlag, testRepeat, assertRepeat);
                }

                // Remove Null
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    var association = associations[this.GetAssociationCount() - 1];
                    association.Strategy.RemoveCompositeRole(relationType.RoleType, null);
                    this.Commit(transactionFlag);
                    this.AssertRelationNotExists(relationType, associations, role, transactionFlag, testRepeat, assertRepeat);
                }

                // Add
                for (int i = 0; i < associations.Length; i++)
                {
                    var association = associations[i];
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        association.Strategy.AddCompositeRole(relationType.RoleType, role);
                        this.Commit(transactionFlag);
                    }

                    this.AssertExclusiveRelation(relationType, associations, association, role, transactionFlag, testRepeat, assertRepeat);
                }

                // Add Null
                for (int i = 0; i < associations.Length; i++)
                {
                    var association = associations[i];
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        association.Strategy.AddCompositeRole(relationType.RoleType, null);
                        this.Commit(transactionFlag);
                    }

                    this.AssertExclusiveRelation(relationType, associations, associations[associations.Length - 1], role, transactionFlag, testRepeat, assertRepeat);
                }

                // Remove Null
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    var association = associations[this.GetAssociationCount() - 1];
                    association.Strategy.RemoveCompositeRole(relationType.RoleType, null);
                    this.Commit(transactionFlag);
                    this.AssertExclusiveRelation(relationType, associations, associations[associations.Length - 1], role, transactionFlag, testRepeat, assertRepeat);
                }

                // Remove
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    associations[this.GetAssociationCount() - 1].Strategy.RemoveCompositeRole(relationType.RoleType, role);
                    this.Commit(transactionFlag);
                    this.AssertRelationNotExists(relationType, associations, role, transactionFlag, testRepeat, assertRepeat);
                }

                // Remove Null
                for (int i = 0; i < associations.Length; i++)
                {
                    var association = associations[i];
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        association.Strategy.RemoveCompositeRole(relationType.RoleType, null);
                        this.Commit(transactionFlag);
                    }

                    this.AssertRelationNotExists(relationType, associations, role, transactionFlag, testRepeat, assertRepeat);
                }

                // Set All
                for (int i = 0; i < associations.Length; i++)
                {
                    var association = associations[i];
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        association.Strategy.SetCompositeRoles(relationType.RoleType, roles);
                        this.Commit(transactionFlag);
                    }

                    this.AssertExclusiveRelation(relationType, associations, association, role, transactionFlag, testRepeat, assertRepeat);
                }

                // Remove All
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    associations[this.GetAssociationCount() - 1].Strategy.RemoveCompositeRoles(relationType.RoleType);
                    this.Commit(transactionFlag);
                    this.AssertRelationNotExists(relationType, associations, role, transactionFlag, testRepeat, assertRepeat);
                }

                // Set
                for (int i = 0; i < associations.Length; i++)
                {
                    var association = associations[i];
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        association.Strategy.SetCompositeRoles(relationType.RoleType, roles);
                        this.Commit(transactionFlag);
                    }

                    this.AssertExclusiveRelation(relationType, associations, association, role, transactionFlag, testRepeat, assertRepeat);
                }

                // Set Null
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    associations[this.GetAssociationCount() - 1].Strategy.SetCompositeRoles(relationType.RoleType, (IObject[])null);
                    this.Commit(transactionFlag);
                    this.AssertRelationNotExists(relationType, associations, role, transactionFlag, testRepeat, assertRepeat);
                }

                // Set
                for (int i = 0; i < associations.Length; i++)
                {
                    var association = associations[i];
                    for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                    {
                        association.Strategy.SetCompositeRoles(relationType.RoleType, roles);
                        this.Commit(transactionFlag);
                    }

                    this.AssertExclusiveRelation(relationType, associations, association, role, transactionFlag, testRepeat, assertRepeat);
                }

                // Set Empty
                for (int repeatIndex = 0; repeatIndex < repeat; repeatIndex++)
                {
                    associations[this.GetAssociationCount() - 1].Strategy.SetCompositeRoles(relationType.RoleType, emptyRoles);
                    this.Commit(transactionFlag);
                    this.AssertRelationNotExists(relationType, associations, role, transactionFlag, testRepeat, assertRepeat);
                }
            }