public void ValidateDuplicateReverseRelationAndType() { var metaPopulation = new MetaPopulation(); var domain = new Domain(metaPopulation, Guid.NewGuid()) { Name = "Domain" }; var c1 = new ClassBuilder(domain, Guid.NewGuid()).WithSingularName("C1").WithPluralName("C1s").Build(); var c2 = new ClassBuilder(domain, Guid.NewGuid()).WithSingularName("C2").WithPluralName("C2s").Build(); var relationType = new RelationTypeBuilder(domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); relationType.AssociationType.ObjectType = c1; relationType.RoleType.ObjectType = c2; relationType.RoleType.AssignedSingularName = "bb"; relationType.RoleType.AssignedPluralName = "bbs"; Assert.IsTrue(metaPopulation.IsValid); var c1bb = new ClassBuilder(domain, Guid.NewGuid()).WithSingularName("bbC1").WithPluralName("YYY").Build(); Assert.IsFalse(metaPopulation.IsValid); c1bb.SingularName = "XXX"; Assert.IsTrue(metaPopulation.IsValid); c1bb.PluralName = "bbsC1"; }
public void ContainsAssociation() { this.Populate(); var c1 = this.Population.C1; var c2 = this.Population.C2; var c3 = this.Population.C3; var c4 = this.Population.C4; var c1_c2 = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); c1_c2.AssociationType.ObjectType = c1; c1_c2.RoleType.ObjectType = c2; Assert.IsFalse(c1.ExistAssociationType(c1_c2.AssociationType)); Assert.IsTrue(c2.ExistAssociationType(c1_c2.AssociationType)); Assert.IsFalse(c3.ExistAssociationType(c1_c2.AssociationType)); Assert.IsFalse(c4.ExistAssociationType(c1_c2.AssociationType)); var c1_c3 = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); c1_c3.AssociationType.ObjectType = c1; c1_c3.RoleType.ObjectType = c3; Assert.IsFalse(c1.ExistAssociationType(c1_c2.AssociationType)); Assert.IsTrue(c2.ExistAssociationType(c1_c2.AssociationType)); Assert.IsFalse(c3.ExistAssociationType(c1_c2.AssociationType)); Assert.IsFalse(c4.ExistAssociationType(c1_c2.AssociationType)); Assert.IsFalse(c1.ExistAssociationType(c1_c3.AssociationType)); Assert.IsFalse(c2.ExistAssociationType(c1_c3.AssociationType)); Assert.IsTrue(c3.ExistAssociationType(c1_c3.AssociationType)); Assert.IsFalse(c4.ExistAssociationType(c1_c3.AssociationType)); }
public void SingularPropertyName() { var company = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Company").WithPluralName("Companies").Build(); var person = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Person").WithPluralName("Persons").Build(); var companyPerson = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()) .WithObjectTypes(company, person) .Build(); Assert.AreEqual("Person", companyPerson.RoleType.SingularPropertyName); companyPerson.RoleType.AssignedPluralName = "Personen"; Assert.AreEqual("Person", companyPerson.RoleType.SingularPropertyName); companyPerson.RoleType.AssignedSingularName = "Persoon"; Assert.AreEqual("Persoon", companyPerson.RoleType.SingularPropertyName); var @interfaceWithoutLeafClass = new InterfaceBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Interface").WithPluralName("Interfaces").Build(); var interfaceWithoutLeafClassPerson = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()) .WithObjectTypes(@interfaceWithoutLeafClass, person) .Build(); Assert.AreEqual("Person", interfaceWithoutLeafClassPerson.RoleType.SingularPropertyName); interfaceWithoutLeafClassPerson.RoleType.AssignedPluralName = "Personen"; Assert.AreEqual("Person", interfaceWithoutLeafClassPerson.RoleType.SingularPropertyName); interfaceWithoutLeafClassPerson.RoleType.AssignedSingularName = "Persoon"; Assert.AreEqual("Persoon", interfaceWithoutLeafClassPerson.RoleType.SingularPropertyName); }
public void SingularPropertyNameWithInheritance() { var company = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Company").WithPluralName("Companies").Build(); var person = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Person").WithPluralName("Persons").Build(); var companyPerson = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()) .WithObjectTypes(company, person) .Build(); var super = new InterfaceBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Company").WithPluralName("Companies").Build(); new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(company).WithSupertype(super).Build(); var superPerson = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()) .WithObjectTypes(super, person) .Build(); Assert.AreEqual("CompanyPerson", companyPerson.RoleType.SingularPropertyName); Assert.AreEqual("CompanyPerson", superPerson.RoleType.SingularPropertyName); companyPerson.RoleType.AssignedPluralName = "Personen"; Assert.AreEqual("CompanyPerson", companyPerson.RoleType.SingularPropertyName); Assert.AreEqual("CompanyPerson", superPerson.RoleType.SingularPropertyName); companyPerson.RoleType.AssignedSingularName = "Persoon"; Assert.AreEqual("Persoon", companyPerson.RoleType.SingularPropertyName); Assert.AreEqual("Person", superPerson.RoleType.SingularPropertyName); }
public void Defaults() { this.Populate(); var thisType = new ClassBuilder(this.Domain, Guid.NewGuid()).Build(); thisType.SingularName = "ThisType"; thisType.PluralName = "TheseTypes"; var thatType = new ClassBuilder(this.Domain, Guid.NewGuid()).Build(); thatType.SingularName = "ThatType"; thatType.PluralName = "ThatTypes"; var supertype = new InterfaceBuilder(this.Domain, Guid.NewGuid()).Build(); supertype.SingularName = "Supertype"; supertype.PluralName = "Supertypes"; new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(thisType).WithSupertype(supertype).Build(); var relationTypeWhereAssociation = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); relationTypeWhereAssociation.AssociationType.ObjectType = thisType; relationTypeWhereAssociation.RoleType.ObjectType = thatType; var relationTypeWhereRole = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); relationTypeWhereRole.AssociationType.ObjectType = thatType; relationTypeWhereRole.RoleType.ObjectType = thisType; relationTypeWhereRole.RoleType.AssignedSingularName = "to"; relationTypeWhereRole.RoleType.AssignedPluralName = "tos"; Assert.IsTrue(this.MetaPopulation.IsValid); }
public void ContainsRole() { this.Populate(); var c1 = this.Population.C1; var c2 = this.Population.C2; var c3 = this.Population.C3; var c4 = this.Population.C4; var c1_c2 = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); c1_c2.AssociationType.ObjectType = c1; c1_c2.RoleType.ObjectType = c2; Assert.IsTrue(c1.ExistRoleType(c1_c2.RoleType)); Assert.IsFalse(c2.ExistRoleType(c1_c2.RoleType)); Assert.IsFalse(c3.ExistRoleType(c1_c2.RoleType)); Assert.IsFalse(c4.ExistRoleType(c1_c2.RoleType)); var c1_c3 = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); c1_c3.AssociationType.ObjectType = c1; c1_c3.RoleType.ObjectType = c3; Assert.IsTrue(c1.ExistRoleType(c1_c2.RoleType)); Assert.IsFalse(c2.ExistRoleType(c1_c2.RoleType)); Assert.IsFalse(c3.ExistRoleType(c1_c2.RoleType)); Assert.IsFalse(c4.ExistRoleType(c1_c2.RoleType)); Assert.IsTrue(c1.ExistRoleType(c1_c3.RoleType)); Assert.IsFalse(c2.ExistRoleType(c1_c3.RoleType)); Assert.IsFalse(c3.ExistRoleType(c1_c3.RoleType)); Assert.IsFalse(c4.ExistRoleType(c1_c3.RoleType)); }
public void CompositeCardinality() { this.Populate(); var relationType = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); relationType.AssociationType.ObjectType = this.Population.C1; relationType.RoleType.ObjectType = this.Population.C2; relationType.AssignedMultiplicity = Meta.Multiplicity.OneToOne; Assert.IsTrue(this.MetaPopulation.IsValid); relationType.AssignedMultiplicity = Meta.Multiplicity.ManyToOne; Assert.IsTrue(this.MetaPopulation.IsValid); relationType.AssignedMultiplicity = Meta.Multiplicity.OneToMany; Assert.IsTrue(this.MetaPopulation.IsValid); relationType.AssignedMultiplicity = Meta.Multiplicity.ManyToMany; Assert.IsTrue(this.MetaPopulation.IsValid); relationType.AssignedMultiplicity = Meta.Multiplicity.OneToOne; Assert.IsTrue(this.MetaPopulation.IsValid); }
public void ValidateNameMinimumLength() { this.Populate(); var relationType = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); var associationType = relationType.AssociationType; var role = relationType.RoleType; associationType.ObjectType = this.Population.C1; role.ObjectType = this.Population.C2; Assert.IsTrue(this.MetaPopulation.IsValid); role.AssignedSingularName = "E"; role.AssignedPluralName = "GH"; Assert.IsFalse(this.MetaPopulation.IsValid); role.AssignedSingularName = "EF"; Assert.IsTrue(this.MetaPopulation.IsValid); role.AssignedPluralName = "G"; Assert.IsFalse(this.MetaPopulation.IsValid); role.AssignedPluralName = "GH"; Assert.IsTrue(this.MetaPopulation.IsValid); }
public void Associations() { this.Populate(); var c1 = this.Population.C1; var c2 = this.Population.C2; var i1 = this.Population.I1; var i2 = this.Population.I2; Assert.AreEqual(0, c2.AssociationTypes.Count()); var c1_c2 = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); c1_c2.AssociationType.ObjectType = c1; c1_c2.RoleType.ObjectType = c2; Assert.AreEqual(1, c2.AssociationTypes.Count()); var i1_i2 = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); i1_i2.AssociationType.ObjectType = i1; i1_i2.RoleType.ObjectType = i2; Assert.AreEqual(2, c2.AssociationTypes.Count()); var ix = new InterfaceBuilder(this.Domain, Guid.NewGuid()).WithSingularName("ix").WithPluralName("ixs").Build(); var c1_ix = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); c1_ix.AssociationType.ObjectType = c1; c1_ix.RoleType.ObjectType = ix; Assert.AreEqual(2, c2.AssociationTypes.Count()); new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(c2).WithSupertype(ix).Build(); Assert.AreEqual(3, c2.AssociationTypes.Count()); }
public void Multiplicity() { this.Populate(); var relationType = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); var associationType = relationType.AssociationType; associationType.ObjectType = this.Population.C1; var roleType = relationType.RoleType; roleType.ObjectType = this.Population.C2; Assert.IsTrue(this.MetaPopulation.IsValid); Assert.IsTrue(relationType.IsOneToOne); relationType.AssignedMultiplicity = Meta.Multiplicity.OneToMany; Assert.IsTrue(relationType.IsOneToMany); relationType.AssignedMultiplicity = Meta.Multiplicity.ManyToMany; Assert.IsTrue(relationType.IsManyToMany); relationType.AssignedMultiplicity = Meta.Multiplicity.ManyToOne; Assert.IsTrue(relationType.IsManyToOne); }
public void Id() { this.Populate(); var associationId = Guid.NewGuid(); var relationType = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), associationId, Guid.NewGuid()).Build(); var associationType = relationType.AssociationType; Assert.AreEqual(associationId, associationType.Id); }
public void Id() { this.Populate(); var roleId = Guid.NewGuid(); var relationType = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), roleId).Build(); var roleType = relationType.RoleType; Assert.AreEqual(roleId, roleType.Id); }
public void Minimal() { this.Populate(); var relationType = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); relationType.AssociationType.ObjectType = this.Population.C1; relationType.RoleType.ObjectType = this.Population.C2; Assert.IsTrue(this.MetaPopulation.IsValid); }
public void PluralPropertyName() { var company = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Company").WithPluralName("Companies").Build(); var person = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Person").WithPluralName("Persons").Build(); var companyPerson = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()) .WithObjectTypes(company, person) .WithMultiplicity(Multiplicity.ManyToOne) .Build(); Assert.AreEqual("CompaniesWherePerson", companyPerson.AssociationType.PluralPropertyName); }
public void PluralName() { var company = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Company").WithPluralName("Companies").Build(); var person = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Person").WithPluralName("Persons").Build(); var companyPerson = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()) .WithObjectTypes(company, person) .WithMultiplicity(Multiplicity.ManyToOne) .Build(); Assert.AreEqual("Companies", companyPerson.AssociationType.PluralName); }
public void SingularPropertyName() { var company = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Company").WithPluralName("Companies").Build(); var person = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Person").WithPluralName("Persons").Build(); var companyPerson = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()) .WithObjectTypes(company, person) .Build(); var associationType = companyPerson.AssociationType; Assert.AreEqual("CompanyWherePerson", associationType.SingularPropertyName); }
public void DefaultName() { var relationType = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); var associationType = relationType.AssociationType; Assert.AreEqual(associationType.Id.ToString().ToLower(), associationType.SingularName); Assert.AreEqual(associationType.Id.ToString().ToLower(), associationType.PluralName); relationType.AssignedMultiplicity = Multiplicity.OneToOne; Assert.AreEqual(associationType.Id.ToString(), associationType.Name); relationType.AssignedMultiplicity = Multiplicity.OneToMany; Assert.AreEqual(associationType.Id.ToString(), associationType.Name); }
public void DefaultName() { var relationType = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); var roleType = relationType.RoleType; Assert.AreEqual(roleType.Id.ToString(), roleType.SingularName); Assert.AreEqual(roleType.Id.ToString(), roleType.PluralName); relationType.AssignedMultiplicity = Multiplicity.OneToOne; Assert.AreEqual(roleType.Id.ToString(), roleType.Name); relationType.AssignedMultiplicity = Multiplicity.OneToMany; Assert.AreEqual(roleType.Id.ToString(), roleType.Name); }
public void PluralPropertyName() { var company = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Company").WithPluralName("Companies").Build(); var person = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Person").WithPluralName("Persons").Build(); var companyPerson = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()) .WithObjectTypes(company, person) .WithMultiplicity(Multiplicity.OneToMany) .Build(); var super = new InterfaceBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Company").WithPluralName("Companies").Build(); new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(company).WithSupertype(super).Build(); var superPerson = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()) .WithObjectTypes(super, person) .Build(); Assert.AreEqual("CompanyPersons", companyPerson.RoleType.PluralPropertyName); Assert.AreEqual("CompanyPersons", superPerson.RoleType.PluralPropertyName); companyPerson.RoleType.AssignedSingularName = "Persoon"; Assert.AreEqual("CompanyPersons", companyPerson.RoleType.PluralPropertyName); Assert.AreEqual("CompanyPersons", superPerson.RoleType.PluralPropertyName); companyPerson.RoleType.AssignedPluralName = "Personen"; Assert.AreEqual("Personen", companyPerson.RoleType.PluralPropertyName); Assert.AreEqual("Persons", superPerson.RoleType.PluralPropertyName); var @interfaceWithoutLeafClass = new InterfaceBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Interface").WithPluralName("Interfaces").Build(); var interfaceWithoutLeafClassPerson = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()) .WithObjectTypes(@interfaceWithoutLeafClass, person) .WithMultiplicity(Multiplicity.OneToMany) .Build(); Assert.AreEqual("Persons", interfaceWithoutLeafClassPerson.RoleType.PluralPropertyName); interfaceWithoutLeafClassPerson.RoleType.AssignedSingularName = "Persoon"; Assert.AreEqual("Persons", interfaceWithoutLeafClassPerson.RoleType.PluralPropertyName); interfaceWithoutLeafClassPerson.RoleType.AssignedPluralName = "Personen"; Assert.AreEqual("Personen", interfaceWithoutLeafClassPerson.RoleType.PluralPropertyName); }
public void SingularFullName() { var company = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Company").WithPluralName("Companies").Build(); var person = new ClassBuilder(this.Domain, Guid.NewGuid()).WithSingularName("Person").WithPluralName("Persons").Build(); var companyPerson = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()) .WithObjectTypes(company, person) .Build(); Assert.AreEqual("CompanyPerson", companyPerson.RoleType.SingularFullName); companyPerson.RoleType.AssignedPluralName = "Personen"; Assert.AreEqual("CompanyPerson", companyPerson.RoleType.SingularFullName); companyPerson.RoleType.AssignedSingularName = "Persoon"; Assert.AreEqual("CompanyPersoon", companyPerson.RoleType.SingularFullName); }
public void ValidateDuplicateReverseRelation() { this.Populate(); var relationType = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); relationType.AssociationType.ObjectType = this.Population.C1; relationType.RoleType.ObjectType = this.Population.C2; Assert.IsTrue(this.MetaPopulation.IsValid); var otherRelationType = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); otherRelationType.AssociationType.ObjectType = this.Population.C2; otherRelationType.RoleType.ObjectType = this.Population.C1; Assert.IsFalse(this.MetaPopulation.IsValid); }
public void Is_Built_Correctly() { // Arrange const int id = 3; const string alias = "test"; const string name = "Test"; var key = Guid.NewGuid(); var createDate = DateTime.Now.AddHours(-2); var updateDate = DateTime.Now.AddHours(-1); var deleteDate = DateTime.Now; var parentObjectType = Guid.NewGuid(); var childObjectType = Guid.NewGuid(); const bool isBidirectional = true; const bool isDependency = true; var builder = new RelationTypeBuilder(); // Act var relationType = builder .WithId(id) .WithAlias(alias) .WithName(name) .WithKey(key) .WithCreateDate(createDate) .WithUpdateDate(updateDate) .WithDeleteDate(deleteDate) .WithParentObjectType(parentObjectType) .WithChildObjectType(childObjectType) .WithIsBidirectional(isBidirectional) .WithIsDependency(isDependency) .Build(); // Assert Assert.AreEqual(id, relationType.Id); Assert.AreEqual(alias, relationType.Alias); Assert.AreEqual(name, relationType.Name); Assert.AreEqual(key, relationType.Key); Assert.AreEqual(createDate, relationType.CreateDate); Assert.AreEqual(updateDate, relationType.UpdateDate); Assert.AreEqual(deleteDate, relationType.DeleteDate); Assert.AreEqual(parentObjectType, relationType.ParentObjectType); Assert.AreEqual(childObjectType, relationType.ChildObjectType); Assert.AreEqual(isBidirectional, relationType.IsBidirectional); Assert.AreEqual(isDependency, relationType.IsDependency); }
public void DeriveSize() { this.Populate(); var relationType = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()) .WithObjectTypes(this.Population.C1, this.Population.IntegerType) .Build(); Assert.IsFalse(relationType.RoleType.Size.HasValue); relationType.RoleType.ObjectType = this.Population.StringType; Assert.IsTrue(relationType.RoleType.Size.HasValue); Assert.AreEqual(256, relationType.RoleType.Size); relationType.RoleType.ObjectType = this.Population.IntegerType; Assert.IsFalse(relationType.RoleType.Size.HasValue); }
public void ValidateDuplicateRelation() { this.Populate(); var relationType = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); relationType.AssociationType.ObjectType = this.Population.C1; relationType.RoleType.ObjectType = this.Population.C2; relationType.RoleType.AssignedSingularName = "bb"; relationType.RoleType.AssignedPluralName = "bbs"; Assert.IsTrue(this.MetaPopulation.IsValid); var otherRelationType = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); otherRelationType.AssociationType.ObjectType = this.Population.C1; otherRelationType.RoleType.ObjectType = this.Population.C4; otherRelationType.RoleType.AssignedSingularName = "bb"; otherRelationType.RoleType.AssignedPluralName = "bbs"; Assert.IsFalse(this.MetaPopulation.IsValid); }
public void Roles() { this.Populate(); var c1 = this.Population.C1; var c2 = this.Population.C2; var i1 = this.Population.I1; var i2 = this.Population.I2; Assert.AreEqual(0, c1.RoleTypes.Count()); var c1_c2 = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); c1_c2.AssociationType.ObjectType = c1; c1_c2.RoleType.ObjectType = c2; Assert.AreEqual(1, c1.RoleTypes.Count()); var i1_i2 = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); i1_i2.AssociationType.ObjectType = i1; i1_i2.RoleType.ObjectType = i2; Assert.AreEqual(2, c1.RoleTypes.Count()); var ix = new InterfaceBuilder(this.Domain, Guid.NewGuid()).WithSingularName("ix").WithPluralName("ixs").Build(); var ix_c2 = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); ix_c2.AssociationType.ObjectType = ix; ix_c2.RoleType.ObjectType = c2; Assert.AreEqual(2, c1.RoleTypes.Count()); new InheritanceBuilder(this.Domain, Guid.NewGuid()).WithSubtype(c1).WithSupertype(ix).Build(); Assert.AreEqual(3, c1.RoleTypes.Count()); }
public void DerivePrecisionScale() { this.Populate(); var relationType = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()) .WithObjectTypes(this.Population.C1, this.Population.IntegerType) .Build(); Assert.IsFalse(relationType.RoleType.Precision.HasValue); Assert.IsFalse(relationType.RoleType.Scale.HasValue); relationType.RoleType.ObjectType = this.Population.DecimalType; Assert.IsTrue(relationType.RoleType.Precision.HasValue); Assert.AreEqual(19, relationType.RoleType.Precision); Assert.IsTrue(relationType.RoleType.Scale.HasValue); Assert.AreEqual(2, relationType.RoleType.Scale); relationType.RoleType.ObjectType = this.Population.IntegerType; Assert.IsFalse(relationType.RoleType.Precision.HasValue); Assert.IsFalse(relationType.RoleType.Scale.HasValue); }
public void HasExclusiveLeafClasses() { this.Populate(); var relationType = new RelationTypeBuilder(this.Domain, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()).Build(); Assert.IsFalse(relationType.ExistExclusiveLeafClasses); var association = relationType.AssociationType; Assert.IsFalse(relationType.ExistExclusiveLeafClasses); var role = relationType.RoleType; Assert.IsFalse(relationType.ExistExclusiveLeafClasses); association.ObjectType = this.Population.I1; role.ObjectType = this.Population.I2; Assert.IsTrue(relationType.ExistExclusiveLeafClasses); association.ObjectType = this.Population.I1; role.ObjectType = null; Assert.IsFalse(relationType.ExistExclusiveLeafClasses); association.ObjectType = null; role.ObjectType = this.Population.I2; Assert.IsFalse(relationType.ExistExclusiveLeafClasses); association.ObjectType = this.Population.I1; role.ObjectType = this.Population.I12; Assert.IsFalse(relationType.ExistExclusiveLeafClasses); }
public void SetUp() => _builder = new RelationTypeBuilder();