Exemplo n.º 1
0
        public void TestCreateAndFetchAndDeletePerDomain()
        {
            System.Guid id1 = System.Guid.NewGuid();
            System.Guid id2 = System.Guid.NewGuid();
            System.Guid id3 = System.Guid.NewGuid();
            System.Guid id4 = System.Guid.NewGuid();

            IContext context = ContextFactory.GetContext(this, "DogOwner");

            PerDomainA perDomainA1 = (PerDomainA)context.CreateObject(id1, typeof(PerDomainA));

            perDomainA1.Name = "Mats Helander";

            PerDomainA perDomainA2 = (PerDomainA)context.CreateObject(id2, typeof(PerDomainA));

            perDomainA2.Name = "Bo Helander";

            PerDomainB perDomainB1 = (PerDomainB)context.CreateObject(id3, typeof(PerDomainB));

            perDomainB1.Name = "John Doe";

            PerDomainB perDomainB2 = (PerDomainB)context.CreateObject(id4, typeof(PerDomainB));

            perDomainB2.Name = "Jane Doe";

            context.PersistAll();

            context.Dispose();

            IContext context2 = ContextFactory.GetContext(this, "DogOwner");

            PerDomainA perDomainA12 = (PerDomainA)context2.GetObject(id1, typeof(PerDomainA));
            PerDomainA perDomainA22 = (PerDomainA)context2.GetObject(id2, typeof(PerDomainA));
            PerDomainB perDomainB12 = (PerDomainB)context2.GetObject(id3, typeof(PerDomainB));
            PerDomainB perDomainB22 = (PerDomainB)context2.GetObject(id4, typeof(PerDomainB));

            perDomainA12.Name = "Mats Helander";
            perDomainA22.Name = "Bo Helander";
            perDomainB12.Name = "John Doe";
            perDomainB22.Name = "Jane Doe";

            Assert.AreEqual(id1, perDomainA12.Id);
            Assert.AreEqual(id2, perDomainA22.Id);
            Assert.AreEqual(id3, perDomainB12.Id);
            Assert.AreEqual(id4, perDomainB22.Id);

            Assert.AreEqual("Mats Helander", perDomainA12.Name);
            Assert.AreEqual("Bo Helander", perDomainA22.Name);
            Assert.AreEqual("John Doe", perDomainB12.Name);
            Assert.AreEqual("Jane Doe", perDomainB22.Name);

            context2.DeleteObject(perDomainA12);
            context2.DeleteObject(perDomainA22);
            context2.DeleteObject(perDomainB12);
            context2.DeleteObject(perDomainB22);

            context2.PersistAll();

            context2.Dispose();
        }
Exemplo n.º 2
0
        public void TestCreateAndFetchByNPathPerDomain()
        {
            string file = @"C:\Test\Xml\DogOwner.xml";

            if (File.Exists(file))
            {
                File.Delete(file);
            }

            System.Guid id1 = System.Guid.NewGuid();
            System.Guid id2 = System.Guid.NewGuid();
            System.Guid id3 = System.Guid.NewGuid();
            System.Guid id4 = System.Guid.NewGuid();

            IContext context = ContextFactory.GetContext(this, "DogOwner");

            PerDomainA perDomainA1 = (PerDomainA)context.CreateObject(id1, typeof(PerDomainA));

            perDomainA1.Name = "Mats Helander";

            PerDomainA perDomainA2 = (PerDomainA)context.CreateObject(id2, typeof(PerDomainA));

            perDomainA2.Name = "Bo Helander";

            PerDomainB perDomainB1 = (PerDomainB)context.CreateObject(id3, typeof(PerDomainB));

            perDomainB1.Name = "John Doe";

            PerDomainB perDomainB2 = (PerDomainB)context.CreateObject(id4, typeof(PerDomainB));

            perDomainB2.Name = "Jane Doe";

            context.PersistAll();

            context.Dispose();

            IContext context2 = ContextFactory.GetContext(this, "DogOwner");

            IList result = context2.GetObjectsByNPath("Select * From PerDomainA Where Name Like '%ts He%'", typeof(PerDomainA));

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("Mats Helander", ((PerDomainA)result[0]).Name);

            context2.Dispose();
        }
Exemplo n.º 3
0
        public void TestCreatePerDomain()
        {
            IContext context = ContextFactory.GetContext(this, "DogOwner");

            PerDomainA perDomainA1 = (PerDomainA)context.CreateObject(System.Guid.NewGuid(), typeof(PerDomainA));

            perDomainA1.Name = "Mats Helander";

            PerDomainA perDomainA2 = (PerDomainA)context.CreateObject(System.Guid.NewGuid(), typeof(PerDomainA));

            perDomainA2.Name = "Bo Helander";

            PerDomainB perDomainB1 = (PerDomainB)context.CreateObject(System.Guid.NewGuid(), typeof(PerDomainB));

            perDomainB1.Name = "John Doe";

            PerDomainB perDomainB2 = (PerDomainB)context.CreateObject(System.Guid.NewGuid(), typeof(PerDomainB));

            perDomainB2.Name = "Jane Doe";

            context.PersistAll();

            context.Dispose();
        }
Exemplo n.º 4
0
        public void TestCreateAndFetchAllAndDeletePerDomain()
        {
            string file = @"C:\Test\Xml\DogOwner.xml";

            if (File.Exists(file))
            {
                File.Delete(file);
            }

            System.Guid id1 = System.Guid.NewGuid();
            System.Guid id2 = System.Guid.NewGuid();
            System.Guid id3 = System.Guid.NewGuid();
            System.Guid id4 = System.Guid.NewGuid();

            IContext context = ContextFactory.GetContext(this, "DogOwner");

            PerDomainA perDomainA1 = (PerDomainA)context.CreateObject(id1, typeof(PerDomainA));

            perDomainA1.Name = "Mats Helander";

            PerDomainA perDomainA2 = (PerDomainA)context.CreateObject(id2, typeof(PerDomainA));

            perDomainA2.Name = "Bo Helander";

            PerDomainB perDomainB1 = (PerDomainB)context.CreateObject(id3, typeof(PerDomainB));

            perDomainB1.Name = "John Doe";

            PerDomainB perDomainB2 = (PerDomainB)context.CreateObject(id4, typeof(PerDomainB));

            perDomainB2.Name = "Jane Doe";

            context.PersistAll();

            context.Dispose();

            IContext context2 = ContextFactory.GetContext(this, "DogOwner");

            IList perDomainA = context2.GetObjects(typeof(PerDomainA));
            IList perDomainB = context2.GetObjects(typeof(PerDomainB));

            Assert.AreEqual(2, perDomainA.Count);
            Assert.AreEqual(2, perDomainB.Count);

            PerDomainA perDomainA12 = (PerDomainA)perDomainA[0];
            PerDomainA perDomainA22 = (PerDomainA)perDomainA[1];
            PerDomainB perDomainB12 = (PerDomainB)perDomainB[0];
            PerDomainB perDomainB22 = (PerDomainB)perDomainB[1];

            perDomainA12.Name = "Mats Helander";
            perDomainA22.Name = "Bo Helander";
            perDomainB12.Name = "John Doe";
            perDomainB22.Name = "Jane Doe";

            Assert.AreEqual(id1, perDomainA12.Id);
            Assert.AreEqual(id2, perDomainA22.Id);
            Assert.AreEqual(id3, perDomainB12.Id);
            Assert.AreEqual(id4, perDomainB22.Id);

            Assert.AreEqual("Mats Helander", perDomainA12.Name);
            Assert.AreEqual("Bo Helander", perDomainA22.Name);
            Assert.AreEqual("John Doe", perDomainB12.Name);
            Assert.AreEqual("Jane Doe", perDomainB22.Name);

            context2.DeleteObject(perDomainA12);
            context2.DeleteObject(perDomainA22);
            context2.DeleteObject(perDomainB12);
            context2.DeleteObject(perDomainB22);

            context2.PersistAll();

            context2.Dispose();
        }