Exemple #1
0
        public void CanGetByName()
        {
            const string dsName1 = "TOPGIS.TLM_DATASET1";
            const string dsName2 = "TOPGIS.TLM_DATASET2";
            const string dsName3 = "TOPGIS.TLM_DATASET3";
            DdxModel     m       = CreateModel();

            m.AddDataset(CreateObjectDataset(dsName1));
            m.AddDataset(CreateObjectDataset(dsName2));
            m.AddDataset(CreateObjectDataset(dsName3));

            CreateSchema(m);

            UnitOfWork.NewTransaction(
                delegate
            {
                Assert.IsFalse(UnitOfWork.HasChanges);

                IList <Dataset> list = Repository.Get(dsName2);
                Assert.AreEqual(1, list.Count);

                var result = list[0] as VectorDataset;

                Assert.IsNotNull(result);
                Assert.AreEqual(dsName2, result.Name);
            });
        }
        public void CanGetByName()
        {
            const string dsName1 = "ds1";
            const string dsName2 = "ds2";
            DdxModel     m       = CreateModel();

            VectorDataset ds1 = m.AddDataset(CreateVectorDataset(dsName1));
            VectorDataset ds2 = m.AddDataset(CreateVectorDataset(dsName2));

            var             uuidType = new ObjectAttributeType("uuid", AttributeRole.UUID);
            ObjectAttribute pk1      =
                ds1.AddAttribute(new ObjectAttribute("pk1", FieldType.Text, uuidType));
            ObjectAttribute pk2 =
                ds2.AddAttribute(new ObjectAttribute("pk2", FieldType.Text, uuidType));

            const string asoName = "aso1";

            const string fk1Name = "fk1";
            const string fk2Name = "fk2";

            m.AddAssociation(
                new AttributedAssociation(
                    asoName, AssociationCardinality.ManyToMany,
                    fk1Name,
                    FieldType.Text, pk1,
                    fk2Name,
                    FieldType.Text, pk2));

            CreateSchema(uuidType, m);

            UnitOfWork.NewTransaction(
                delegate
            {
                AssertUnitOfWorkHasNoChanges();

                IList <Association> list = Repository.Get(asoName);
                Assert.AreEqual(1, list.Count);
                Association result = list[0] as AttributedAssociation;

                Assert.IsNotNull(result);
                Assert.AreEqual(asoName, result.Name);
                Assert.AreEqual(fk1Name, result.End1.ForeignKey.Name);
                Assert.AreEqual(fk2Name, result.End2.ForeignKey.Name);
                Assert.AreEqual(dsName1, result.End1.ObjectDataset.Name);
                Assert.AreEqual(dsName2, result.End2.ObjectDataset.Name);
            });
        }
Exemple #3
0
        public void CanGetAssociationEnds()
        {
            const string associationName = "relClass";
            const string dsName1         = "ds1";
            const string dsName2         = "ds2";
            DdxModel     m = CreateModel();

            ObjectDataset ds1 = m.AddDataset(CreateObjectDataset(dsName1));
            ObjectDataset ds2 = m.AddDataset(CreateObjectDataset(dsName2));

            ObjectAttribute fk = ds1.AddAttribute(
                new ObjectAttribute("fk", FieldType.Text));
            ObjectAttribute pk = ds2.AddAttribute(
                new ObjectAttribute("pk", FieldType.Text));

            m.AddAssociation(new ForeignKeyAssociation(associationName,
                                                       AssociationCardinality.OneToMany,
                                                       fk, pk));

            CreateSchema(m);

            UnitOfWork.NewTransaction(
                delegate
            {
                AssertUnitOfWorkHasNoChanges();

                IList <Dataset> list = Repository.Get(dsName1);
                Assert.AreEqual(1, list.Count);
                var result = list[0] as VectorDataset;

                Assert.IsNotNull(result);
                Assert.AreEqual(1, result.AssociationEnds.Count);
                Assert.AreEqual(
                    1, (new List <AssociationEnd>(result.GetAssociationEnds())).Count);
                AssociationEnd associationEnd = result.AssociationEnds[0];

                Assert.AreEqual(ds1, associationEnd.ObjectDataset);
                Assert.IsNotNull(associationEnd.Association);
                Assert.AreEqual(associationName, associationEnd.Association.Name);
                Assert.AreEqual(ds2, result.AssociationEnds[0].OppositeEnd.ObjectDataset);
            });
        }
Exemple #4
0
        public void CanGetAttributes()
        {
            const string dsName = "TOPGIS.TLM_DATASET";
            DdxModel     m      = CreateModel();

            ObjectDataset ds = m.AddDataset(CreateObjectDataset(dsName));

            ObjectAttribute oa1 = ds.AddAttribute(
                new ObjectAttribute("field1", FieldType.Text));
            ObjectAttribute oa2 = ds.AddAttribute(
                new ObjectAttribute("field2", FieldType.Text));

            oa1.ReadOnlyOverride = false;
            oa2.ReadOnlyOverride = true;

            CreateSchema(m);

            UnitOfWork.NewTransaction(
                delegate
            {
                AssertUnitOfWorkHasNoChanges();

                IList <Dataset> list = Repository.Get(dsName);
                Assert.AreEqual(1, list.Count);
                var result = list[0] as VectorDataset;

                Assert.IsNotNull(result);
                Assert.AreEqual(dsName, result.Name);
                Assert.AreEqual(2, ds.Attributes.Count);
                Assert.AreEqual(2, (new List <ObjectAttribute>(ds.GetAttributes())).Count);

                ObjectAttribute field1 = ds.GetAttribute("field1");
                ObjectAttribute field2 = ds.GetAttribute("field2");
                Assert.IsNotNull(field1, "field1");
                Assert.IsNotNull(field2, "field2");

                Assert.IsFalse(field1.ReadOnly);
                Assert.IsTrue(field2.ReadOnly);
            });
        }