Example #1
0
        public void LoadTest()
        {
            GenieLamp lamp = InitializationTest.LoadTestProject("TestProject.xml");

            Assert.AreEqual("Test", lamp.ProjectName);
            Assert.AreEqual("Warehouse", lamp.Model.DefaultSchema);
        }
Example #2
0
        public void ImplicitlyCreatedMetaobjectsTest()
        {
            GenieLamp lamp  = InitializationTest.LoadTestProject("TestProject.xml");
            Model     model = lamp.Model;

            Entity storeDoc = model.Entities.GetByName(QualName.MakeFullName(model.DefaultSchema, "StoreDoc"));

            Assert.IsNotNull(storeDoc, "Entity not exists");
            Generator gen = model.Generators.GetByName(QualName.MakeFullName(storeDoc.Schema, Generator.DefaultName(storeDoc)));

            Assert.IsNotNull(gen, "Implicit generator");
            Assert.AreEqual("SEQ_STORE_DOC", gen.Persistence.Name, "Implicit generator persistence name");
            Assert.AreEqual(Int32.MaxValue, gen.MaxValue, "Max value");
        }
Example #3
0
        public void MaxValueTest()
        {
            GenieLamp lamp = InitializationTest.LoadTestProject("TestProject.xml");

            lamp.Init();

            TypeDefinition tdFixed = new TypeDefinition(false, 1, false, 0, false, true, false, false, false, "");

            StdType t1 = new StdType(lamp.Model, "", "testType1", BaseType.TypeInt, tdFixed);

            Assert.IsNotNull(t1.MaxValue, "Has not max value");
            Assert.AreEqual(byte.MaxValue, t1.MaxValue.Value);

            tdFixed.Length = 2;
            StdType t2 = new StdType(lamp.Model, "", "testType2", BaseType.TypeInt, tdFixed);

            Assert.IsNotNull(t2.MaxValue, "Has not max value");
            Assert.AreEqual(Int16.MaxValue, t2.MaxValue.Value);

            tdFixed.Length = 4;
            StdType t3 = new StdType(lamp.Model, "", "testType3", BaseType.TypeInt, tdFixed);

            Assert.IsNotNull(t3.MaxValue, "Has not max value");
            Assert.AreEqual(Int32.MaxValue, t3.MaxValue.Value);

            tdFixed.Length = 8;
            StdType t4 = new StdType(lamp.Model, "", "testType4", BaseType.TypeInt, tdFixed);

            Assert.IsNotNull(t4.MaxValue, "Has not max value");
            Assert.AreEqual(Int64.MaxValue, t4.MaxValue.Value);

            tdFixed.Length = 20;
            StdType t5 = new StdType(lamp.Model, "", "testType5", BaseType.TypeDecimal, tdFixed);

            Assert.IsNotNull(t5.MaxValue, "Has not max value");
            Assert.AreEqual(Convert.ToDecimal(Math.Pow(10, 20)), t5.MaxValue.Value);

            StdType t6 = new StdType(lamp.Model, "", "testType6", BaseType.TypeCurrency, tdFixed);

            Assert.IsNull(t6.MaxValue, "Has max value");
        }
Example #4
0
        public void IndexesTest()
        {
            GenieLamp lamp  = InitializationTest.LoadTestProject("TestProject.xml");
            Model     model = lamp.Model;

            Entity en = model.Entities.GetByName(QualName.MakeFullName(model.DefaultSchema, "StoreDoc"));

            Assert.IsNotNull(en, "Entity not exists");
            int  indexCount        = 0;
            bool hasCompositeIndex = false;

            foreach (Index ix in model.PhysicalModel.Indexes.GetByEntity(en))
            {
                if (ix.DefinedInModel)
                {
                    Assert.IsTrue(ix.Generate, "Index should be generated");
                    indexCount++;
                    if (ix.Columns.Count == 1)
                    {
                        if (ix.Columns[0].Attribute.Name == "RefNum")
                        {
                            Assert.IsTrue(ix.Unique, "Index should be unique");
                            Assert.AreEqual(ColumnOrder.Desc, ix.Columns[0].Order);
                        }
                        else if (ix.Columns[0].Attribute.Name == "Name")
                        {
                            Assert.IsFalse(ix.Unique, "Index should be not unique");
                            Assert.AreEqual(ColumnOrder.Asc, ix.Columns[0].Order);
                        }
                    }
                    else if (ix.Columns.Count > 1)
                    {
                        hasCompositeIndex = true;
                    }
                }
            }
            Assert.AreEqual(3, indexCount, "Invalid index count");
            Assert.IsTrue(hasCompositeIndex, "Composite index absent");
        }
Example #5
0
        public void ConstraintIndexPersistentNameTest()
        {
            GenieLamp lamp  = InitializationTest.LoadTestProject("TestProject.xml");
            Model     model = lamp.Model;

            Entity en = model.Entities.GetByName(QualName.MakeFullName(model.DefaultSchema, "ProductType"));

            Assert.IsNotNull(en, "ProductType entity not exists");
            UniqueId u = null;

            foreach (UniqueId u2 in en.Constraints.UniqueIds)
            {
                if (u2.Attributes.Count == 1 && u2.Attributes[0].Name == "Code")
                {
                    u = u2;
                    break;
                }
            }
            Assert.IsNotNull(u, "Constraint not found");
            Assert.IsTrue(u.Persistence.NameDefined, "Constraint does not have index name");
            Assert.AreEqual("IX_CUSTOM_PRODUCT_TYPE", u.Persistence.Name, "Constraint index name was changed");
            Assert.IsNotNull(u.Index, "Relation does not have index");
            Assert.AreEqual(u.Persistence.Name, u.Index.Name, "Relation persistent name was changed");
        }
Example #6
0
        public void ForeignKeyAndIndexPersistentNameTest()
        {
            GenieLamp lamp  = InitializationTest.LoadTestProject("TestProject.xml");
            Model     model = lamp.Model;

            Relation r = null;

            foreach (Relation r2 in model.Relations)
            {
                if (r2.Name == "Doc" && r2.Name2 == "Lines")
                {
                    r = r2;
                    break;
                }
            }
            Assert.IsNotNull(r, "Relation not found");
            Assert.AreEqual("FK_CUSTOM_NAME", r.Persistence.Name, "Relation persistent name was changed");
            Assert.IsNotNull(r.ForeignKey, "Relation does not have FK");
            Assert.AreEqual(r.Persistence.Name, r.ForeignKey.Name, "Foreign key custom name is not set correctly");

            Assert.AreEqual("IX_CUSTOM_NAME", r.IndexName, "Relation index name was changed");
            Assert.IsTrue(r.ForeignKey.HasIndex, "Foreign key does not have index");
            Assert.AreEqual(r.IndexName, r.ForeignKey.Index.Name, "Foreign key custom index name is not set corectly");
        }
Example #7
0
 public void TestSetup()
 {
     lamp = InitializationTest.LoadTestProject("TestProject.xml");
     Assert.IsNotNull(lamp, "Lamp was not created");
     lamp.Init();
 }