예제 #1
0
        public void FlushCacheOnInit()
        {
            var database = this.CreateDatabase();

            database.Init();

            using (ISession session = database.CreateSession())
            {
                var c1a = C1.Create(session);
                var c2a = C2.Create(session);
                c1a.C1C2one2one = c2a;
                session.Commit();

                // load cache
                c2a = c1a.C1C2one2one;
            }

            database.Init();

            using (ISession session = database.CreateSession())
            {
                var c1a = C1.Create(session);
                var c1b = C1.Create(session);

                session.Commit();

                c1a = C1.Instantiate(session, c1a.Id);

                Assert.IsNull(c1a.C1C2one2one);
            }
        }
예제 #2
0
        public void LoadSpecial()
        {
            foreach (var init in this.Inits)
            {
                init();

                var savePopulation = this.CreatePopulation();
                var saveSession    = savePopulation.CreateSession();

                try
                {
                    this.c1A = C1.Create(saveSession);
                    this.c1A.C1AllorsString  = "> <";
                    this.c1A.I12AllorsString = "< >";
                    this.c1A.I1AllorsString  = "& &&";
                    this.c1A.S1AllorsString  = "' \" ''";

                    this.c1Empty = C1.Create(saveSession);

                    saveSession.Commit();

                    var stringWriter = new StringWriter();
                    using (var writer = XmlWriter.Create(stringWriter))
                    {
                        savePopulation.Save(writer);
                    }

                    //writer = XmlWriter.Create(@"population.xml", Encoding.UTF8);
                    //saveSession.Population.Save(writer);
                    //writer.Close();

                    var stringReader = new StringReader(stringWriter.ToString());
                    using (var reader = XmlReader.Create(stringReader))
                    {
                        this.Population.Load(reader);
                    }

                    using (var session = this.Population.CreateSession())
                    {
                        var copyValues = C1.Instantiate(session, this.c1A.Strategy.ObjectId);

                        Assert.Equal(this.c1A.C1AllorsString, copyValues.C1AllorsString);
                        Assert.Equal(this.c1A.I12AllorsString, copyValues.I12AllorsString);
                        Assert.Equal(this.c1A.I1AllorsString, copyValues.I1AllorsString);
                        Assert.Equal(this.c1A.S1AllorsString, copyValues.S1AllorsString);

                        var c1EmptyLoaded = C1.Instantiate(session, this.c1Empty.Strategy.ObjectId);
                        Assert.NotNull(c1EmptyLoaded);
                    }
                }
                finally
                {
                    saveSession.Rollback();
                }
            }
        }
예제 #3
0
        public void LoadBinary()
        {
            foreach (var init in this.Inits)
            {
                init();

                var otherPopulation = this.CreatePopulation();
                var otherSession    = otherPopulation.CreateSession();

                try
                {
                    this.c1A = C1.Create(otherSession);
                    this.c1B = C1.Create(otherSession);
                    this.c1C = C1.Create(otherSession);

                    this.c1A.C1AllorsBinary = new byte[0];
                    this.c1B.C1AllorsBinary = new byte[] { 1, 2, 3, 4 };
                    this.c1C.C1AllorsBinary = null;

                    otherSession.Commit();

                    var stringWriter = new StringWriter();
                    using (var writer = XmlWriter.Create(stringWriter))
                    {
                        otherPopulation.Save(writer);
                    }

                    var xml = stringWriter.ToString();

                    var stringReader = new StringReader(stringWriter.ToString());
                    using (var reader = XmlReader.Create(stringReader))
                    {
                        this.Population.Load(reader);
                    }

                    using (var session = this.Population.CreateSession())
                    {
                        var c1ACopy = C1.Instantiate(session, this.c1A.Strategy.ObjectId);
                        var c1BCopy = C1.Instantiate(session, this.c1B.Strategy.ObjectId);
                        var c1CCopy = C1.Instantiate(session, this.c1C.Strategy.ObjectId);

                        Assert.Equal(this.c1A.C1AllorsBinary, c1ACopy.C1AllorsBinary);
                        Assert.Equal(this.c1B.C1AllorsBinary, c1BCopy.C1AllorsBinary);
                        Assert.Equal(this.c1C.C1AllorsBinary, c1CCopy.C1AllorsBinary);
                    }
                }
                finally
                {
                    otherSession.Commit();
                }
            }
        }
예제 #4
0
        public override void SortDifferentSession()
        {
            foreach (var init in this.Inits)
            {
                init();

                var c1A = C1.Create(this.Session);
                var c1B = C1.Create(this.Session);
                var c1C = C1.Create(this.Session);
                var c1D = C1.Create(this.Session);

                c1A.C1AllorsString = "2";
                c1B.C1AllorsString = "1";
                c1C.C1AllorsString = "3";

                var extent = this.Session.Extent(M.C1.Class);
                extent.AddSort(M.C1.C1AllorsString, SortDirection.Ascending);

                var sortedObjects = (C1[])extent.ToArray(typeof(C1));

                var names = sortedObjects.Select(v => v.C1AllorsString).ToArray();

                Assert.Equal(4, sortedObjects.Length);
                Assert.Equal(c1D, sortedObjects[0]);
                Assert.Equal(c1B, sortedObjects[1]);
                Assert.Equal(c1A, sortedObjects[2]);
                Assert.Equal(c1C, sortedObjects[3]);

                var c1AId = c1A.Id;

                this.Session.Commit();

                using (var session2 = this.CreateSession())
                {
                    c1A = (C1)session2.Instantiate(c1AId);

                    extent = session2.Extent(M.C1.Class);
                    extent.AddSort(M.C1.C1AllorsString, SortDirection.Ascending);

                    sortedObjects = (C1[])extent.ToArray(typeof(C1));

                    names = sortedObjects.Select(v => v.C1AllorsString).ToArray();

                    Assert.Equal(4, sortedObjects.Length);
                    Assert.Equal(c1D, sortedObjects[0]);
                    Assert.Equal(c1B, sortedObjects[1]);
                    Assert.Equal(c1A, sortedObjects[2]);
                    Assert.Equal(c1C, sortedObjects[3]);
                }
            }
        }
예제 #5
0
        public void CacheUnitRole()
        {
            var database = this.CreateDatabase();

            database.Init();

            using (var session = database.CreateSession())
            {
                var c1 = C1.Create(session);
                c1.C1AllorsString = "Test";

                session.Commit();
            }
        }
        public void SessionEvent()
        {
            foreach (var init in this.Inits)
            {
                init();

                var c1         = C1.Create(this.Session);
                var subscriber = new Subscriber();
                this.Session["subscriber"] = subscriber;
                c1.Broadcast("Hello Subscriber");

                Assert.AreEqual("Hello Subscriber", subscriber.Message);
            }
        }
예제 #7
0
        public void DeleteAssociations()
        {
            foreach (var init in this.Inits)
            {
                init();

                var c1A = C1.Create(this.Session);
                var c1B = C1.Create(this.Session);
                c1A.C1C1many2one = c1B;

                foreach (C1 c in c1B.C1sWhereC1C1many2one)
                {
                    c.Strategy.Delete();
                }

                Assert.False(c1B.ExistC1sWhereC1C1many2one);
            }
        }
예제 #8
0
        public void PrefetchCompositesRole()
        {
            var database = this.CreateDatabase();

            database.Init();

            using (var session = database.CreateSession())
            {
                var c1a = C1.Create(session);
                var c1b = C1.Create(session);
                var c2a = C2.Create(session);
                var c2b = C2.Create(session);
                var c2c = C2.Create(session);

                c1a.AddC1C2one2many(c2a);
                c1a.AddC1C2one2many(c2b);

                session.Commit();

                c1a.RemoveC1C1one2manies();
                c1a.AddC1C2one2many(c2c);

                var extent = session.Extent <C1>();
                var array  = extent.ToArray();

                var nestedPrefetchPolicyBuilder = new PrefetchPolicyBuilder();
                nestedPrefetchPolicyBuilder.WithRule(M.C2.C2C2one2manies);
                var nestedPrefetchPolicy = nestedPrefetchPolicyBuilder.Build();

                var prefetchPolicyBuilder = new PrefetchPolicyBuilder();
                prefetchPolicyBuilder.WithRule(M.C1.C1C2one2manies, nestedPrefetchPolicy);
                var prefetchPolicy = prefetchPolicyBuilder.Build();
                session.Prefetch(prefetchPolicy, new[] { c1a, c1b });

                var result = c1a.C1C2one2manies;

                session.Rollback();

                Assert.Equal(2, c1a.C1C2one2manies.Count);
                Assert.Contains(c2a, c1a.C1C2one2manies.ToArray());
                Assert.Contains(c2b, c1a.C1C2one2manies.ToArray());
            }
        }
예제 #9
0
        public void InitDifferentDatabase()
        {
            var database = this.CreateDatabase();

            database.Init();

            using (ISession session = database.CreateSession())
            {
                var c1 = C1.Create(session);
                c1.C1AllorsString = "a";
                session.Commit();
            }

            using (ISession session = database.CreateSession())
            {
                var c1 = session.Extent <C1>().First;
                Assert.AreEqual("a", c1.C1AllorsString);
            }

            database.Init();

            var database2 = this.CreateDatabase();

            using (ISession session = database.CreateSession())
            {
                var c1 = C1.Create(session);
                c1.C1AllorsString = "b";
                session.Commit();
            }

            using (ISession session = database2.CreateSession())
            {
                var c1 = session.Extent <C1>().First;
                c1.C1AllorsString = "c";
            }

            using (ISession session = database.CreateSession())
            {
                var c1 = session.Extent <C1>().First;
                Assert.AreEqual("c", c1.C1AllorsString);
            }
        }
예제 #10
0
        public void PrefetchCompositeRole()
        {
            var database = this.CreateDatabase();

            database.Init();

            using (var session = database.CreateSession())
            {
                var c1a = C1.Create(session);
                var c1b = C1.Create(session);
                var c2a = C2.Create(session);
                var c2b = C2.Create(session);

                session.Commit();

                c1a.C1C2many2one = c2a;

                var extent = session.Extent <C1>();
                var array  = extent.ToArray();

                var nestedPrefetchPolicyBuilder = new PrefetchPolicyBuilder();
                nestedPrefetchPolicyBuilder.WithRule(M.C2.C2C2one2manies);
                var nestedPrefetchPolicy = nestedPrefetchPolicyBuilder.Build();

                var prefetchPolicyBuilder = new PrefetchPolicyBuilder();
                prefetchPolicyBuilder.WithRule(M.C1.C1C2many2one, nestedPrefetchPolicy);
                var prefetchPolicy = prefetchPolicyBuilder.Build();
                session.Prefetch(prefetchPolicy, new[] { c1a, c1b });

                var result = c1a.C1C2many2one;

                session.Rollback();

                Assert.False(c1a.ExistC1C2many2one);
            }
        }
예제 #11
0
        public override void AllorsDateTime()
        {
            // year, day & month
            {
                C1 values = C1.Create(this.Session);
                values.C1AllorsDateTime = new DateTime(1973, 03, 27);
                values.I1AllorsDateTime = new DateTime(1973, 03, 27);
                Assert.AreEqual(new DateTime(1973, 03, 27), values.C1AllorsDateTime);
                Assert.AreEqual(new DateTime(1973, 03, 27), values.I1AllorsDateTime);
            }

            // Minimum
            {
                C1 values = C1.Create(this.Session);
                values.C1AllorsDateTime = MINIMUM_DATETIME;
                values.I1AllorsDateTime = MINIMUM_DATETIME;
                Assert.AreEqual(MINIMUM_DATETIME, values.C1AllorsDateTime);
                Assert.AreEqual(MINIMUM_DATETIME, values.I1AllorsDateTime);
            }

            // Maximum
            {
                C1 values = C1.Create(this.Session);
                values.C1AllorsDateTime = MAXIMUM_DATETIME;
                values.I1AllorsDateTime = MAXIMUM_DATETIME;
                Assert.AreEqual(MAXIMUM_DATETIME, values.C1AllorsDateTime);
                Assert.AreEqual(MAXIMUM_DATETIME, values.I1AllorsDateTime);
            }

            // initial empty
            {
                C1 values = C1.Create(this.Session);

                DateTime value           = DateTime.Now;
                DateTime valueOld        = value;
                bool     exceptionThrown = false;
                try
                {
                    value = values.C1AllorsDateTime;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.I1AllorsDateTime;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.S1AllorsDateTime;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                Assert.AreEqual(valueOld, value);

                Assert.IsFalse(values.ExistC1AllorsDateTime);
                Assert.IsFalse(values.ExistI1AllorsDateTime);
                Assert.IsFalse(values.ExistS1AllorsDateTime);

                this.Session.Commit();

                value           = DateTime.Now;
                valueOld        = value;
                exceptionThrown = false;
                try
                {
                    value = values.C1AllorsDateTime;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.I1AllorsDateTime;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.S1AllorsDateTime;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                Assert.AreEqual(valueOld, value);

                Assert.IsFalse(values.ExistC1AllorsDateTime);
                Assert.IsFalse(values.ExistI1AllorsDateTime);
                Assert.IsFalse(values.ExistS1AllorsDateTime);
            }

            // reset empty
            {
                C1 values = C1.Create(this.Session);
                values.C1AllorsDateTime = DateTime.Now;
                values.I1AllorsDateTime = DateTime.Now;
                values.S1AllorsDateTime = DateTime.Now;

                this.Session.Commit();
                ;

                Assert.IsTrue(values.ExistC1AllorsDateTime);
                Assert.IsTrue(values.ExistI1AllorsDateTime);
                Assert.IsTrue(values.ExistS1AllorsDateTime);

                values.RemoveC1AllorsDateTime();
                values.RemoveI1AllorsDateTime();
                values.RemoveS1AllorsDateTime();

                DateTime value           = DateTime.Now;
                DateTime valueOld        = value;
                bool     exceptionThrown = false;
                try
                {
                    value = values.C1AllorsDateTime;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.I1AllorsDateTime;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.S1AllorsDateTime;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                Assert.AreEqual(valueOld, value);

                Assert.IsFalse(values.ExistC1AllorsDateTime);
                Assert.IsFalse(values.ExistI1AllorsDateTime);
                Assert.IsFalse(values.ExistS1AllorsDateTime);

                this.Session.Commit();

                value           = DateTime.Now;
                valueOld        = value;
                exceptionThrown = false;
                try
                {
                    value = values.C1AllorsDateTime;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.I1AllorsDateTime;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.S1AllorsDateTime;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                Assert.AreEqual(valueOld, value);

                Assert.IsFalse(values.ExistC1AllorsDateTime);
                Assert.IsFalse(values.ExistI1AllorsDateTime);
                Assert.IsFalse(values.ExistS1AllorsDateTime);
            }
        }
예제 #12
0
        public TestPopulation(ISession session)
        {
            this.C1A = C1.Create(session);
            this.C1B = C1.Create(session);
            this.C1C = C1.Create(session);
            this.C1D = C1.Create(session);
            this.C2A = C2.Create(session);
            this.C2B = C2.Create(session);
            this.C2C = C2.Create(session);
            this.C2D = C2.Create(session);
            this.C3A = C3.Create(session);
            this.C3B = C3.Create(session);
            this.C3C = C3.Create(session);
            this.C3D = C3.Create(session);
            this.C4A = C4.Create(session);
            this.C4B = C4.Create(session);
            this.C4C = C4.Create(session);
            this.C4D = C4.Create(session);

            // Names
            this.C1A.Name = "c1a";
            this.C1B.Name = "c1b";
            this.C1C.Name = "c1c";
            this.C1D.Name = "c1d";
            this.C2A.Name = "c2a";
            this.C2B.Name = "c2b";
            this.C2C.Name = "c2c";
            this.C2D.Name = "c2d";
            this.C3A.Name = "c3a";
            this.C3B.Name = "c3b";
            this.C3C.Name = "c3c";
            this.C3D.Name = "c3d";
            this.C4A.Name = "c4a";
            this.C4B.Name = "c4b";
            this.C4C.Name = "c4c";
            this.C4D.Name = "c4d";

            // String
            // class
            this.C1B.C1AllorsString = "ᴀbra";
            this.C1C.C1AllorsString = "ᴀbracadabra";
            this.C1D.C1AllorsString = "ᴀbracadabra";

            this.C1A.C1StringEquals = "ᴀbra";
            this.C1B.C1StringEquals = "ᴀbra";
            this.C1C.C1StringEquals = "ᴀbra";

            this.C2B.C2AllorsString = "ᴀbra";
            this.C2C.C2AllorsString = "ᴀbracadabra";
            this.C2D.C2AllorsString = "ᴀbracadabra";

            this.C3B.C3AllorsString = "ᴀbra";
            this.C3C.C3AllorsString = "ᴀbracadabra";
            this.C3D.C3AllorsString = "ᴀbracadabra";

            this.C3A.C3StringEquals = "ᴀbra";
            this.C3B.C3StringEquals = "ᴀbra";
            this.C3C.C3StringEquals = "ᴀbra";

            // exclusive interface
            this.C1B.I1AllorsString = "ᴀbra";
            this.C1C.I1AllorsString = "ᴀbracadabra";
            this.C1D.I1AllorsString = "ᴀbracadabra";

            this.C1A.I1StringEquals = "ᴀbra";
            this.C1B.I1StringEquals = "ᴀbra";
            this.C1C.I1StringEquals = "ᴀbra";

            this.C3B.I3AllorsString = "ᴀbra";
            this.C3C.I3AllorsString = "ᴀbracadabra";
            this.C3D.I3AllorsString = "ᴀbracadabra";

            this.C3A.I3StringEquals = "ᴀbra";
            this.C3B.I3StringEquals = "ᴀbra";
            this.C3C.I3StringEquals = "ᴀbra";

            // shared interface
            this.C1B.I12AllorsString = "ᴀbra";
            this.C1C.I12AllorsString = "ᴀbracadabra";
            this.C1D.I12AllorsString = "ᴀbracadabra";
            this.C2B.I12AllorsString = "ᴀbra";
            this.C2C.I12AllorsString = "ᴀbracadabra";
            this.C2D.I12AllorsString = "ᴀbracadabra";

            this.C2B.I23AllorsString = "ᴀbra";
            this.C2C.I23AllorsString = "ᴀbracadabra";
            this.C2D.I23AllorsString = "ᴀbracadabra";
            this.C3B.I23AllorsString = "ᴀbra";
            this.C3C.I23AllorsString = "ᴀbracadabra";
            this.C3D.I23AllorsString = "ᴀbracadabra";

            this.C3B.I34AllorsString = "ᴀbra";
            this.C3C.I34AllorsString = "ᴀbracadabra";
            this.C3D.I34AllorsString = "ᴀbracadabra";
            this.C4B.I34AllorsString = "ᴀbra";
            this.C4C.I34AllorsString = "ᴀbracadabra";
            this.C4D.I34AllorsString = "ᴀbracadabra";

            this.C1B.S1AllorsString = "ᴀbra";
            this.C1C.S1AllorsString = "ᴀbracadabra";
            this.C1D.S1AllorsString = "ᴀbracadabra";

            this.C1B.S1234AllorsString = "ᴀbra";
            this.C1C.S1234AllorsString = "ᴀbracadabra";
            this.C1D.S1234AllorsString = "ᴀbracadabra";
            this.C2B.S1234AllorsString = "ᴀbra";
            this.C2C.S1234AllorsString = "ᴀbracadabra";
            this.C2D.S1234AllorsString = "ᴀbracadabra";
            this.C3B.S1234AllorsString = "ᴀbra";
            this.C3C.S1234AllorsString = "ᴀbracadabra";
            this.C3D.S1234AllorsString = "ᴀbracadabra";
            this.C4B.S1234AllorsString = "ᴀbra";
            this.C4C.S1234AllorsString = "ᴀbracadabra";
            this.C4D.S1234AllorsString = "ᴀbracadabra";

            // Integer
            this.C1B.C1AllorsInteger = 1;
            this.C1C.C1AllorsInteger = 2;
            this.C1D.C1AllorsInteger = 2;

            this.C1B.C1IntegerLessThan = 0;
            this.C1C.C1IntegerLessThan = 2;
            this.C1D.C1IntegerLessThan = 4;

            this.C1B.C1IntegerGreaterThan = 0;
            this.C1C.C1IntegerGreaterThan = 2;
            this.C1D.C1IntegerGreaterThan = 4;

            this.C1B.C1IntegerBetweenA = -10;
            this.C1B.C1IntegerBetweenB = 0;
            this.C1C.C1IntegerBetweenA = 2;
            this.C1C.C1IntegerBetweenB = 2;
            this.C1D.C1IntegerBetweenA = 0;
            this.C1D.C1IntegerBetweenB = 10;

            this.C1B.I1AllorsInteger = 1;
            this.C1C.I1AllorsInteger = 2;
            this.C1D.I1AllorsInteger = 2;

            this.C1B.S1AllorsInteger = 1;
            this.C1C.S1AllorsInteger = 2;
            this.C1D.S1AllorsInteger = 2;

            this.C1B.I12AllorsInteger = 1;
            this.C1C.I12AllorsInteger = 2;
            this.C1D.I12AllorsInteger = 2;
            this.C2B.I12AllorsInteger = 1;
            this.C2C.I12AllorsInteger = 2;
            this.C2D.I12AllorsInteger = 2;

            this.C1B.S1234AllorsInteger = 1;
            this.C1C.S1234AllorsInteger = 2;
            this.C1D.S1234AllorsInteger = 2;
            this.C2B.S1234AllorsInteger = 1;
            this.C2C.S1234AllorsInteger = 2;
            this.C2D.S1234AllorsInteger = 2;
            this.C3B.S1234AllorsInteger = 1;
            this.C3C.S1234AllorsInteger = 2;
            this.C3D.S1234AllorsInteger = 2;
            this.C4B.S1234AllorsInteger = 1;
            this.C4C.S1234AllorsInteger = 2;
            this.C4D.S1234AllorsInteger = 2;

            // DateTime
            this.C1B.C1AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 4, DateTimeKind.Utc);
            this.C1C.C1AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C1D.C1AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);

            this.C1B.C1DateTimeLessThan = new DateTime(2000, 1, 1, 0, 0, 3, DateTimeKind.Utc);
            this.C1C.C1DateTimeLessThan = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C1D.C1DateTimeLessThan = new DateTime(2000, 1, 1, 0, 0, 7, DateTimeKind.Utc);

            this.C1B.C1DateTimeGreaterThan = new DateTime(2000, 1, 1, 0, 0, 3, DateTimeKind.Utc);
            this.C1C.C1DateTimeGreaterThan = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C1D.C1DateTimeGreaterThan = new DateTime(2000, 1, 1, 0, 0, 7, DateTimeKind.Utc);

            this.C1B.C1DateTimeBetweenA = new DateTime(2000, 1, 1, 0, 0, 1, DateTimeKind.Utc);
            this.C1B.C1DateTimeBetweenB = new DateTime(2000, 1, 1, 0, 0, 3, DateTimeKind.Utc);
            this.C1C.C1DateTimeBetweenA = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C1C.C1DateTimeBetweenB = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C1D.C1DateTimeBetweenA = new DateTime(2000, 1, 1, 0, 0, 3, DateTimeKind.Utc);
            this.C1D.C1DateTimeBetweenB = new DateTime(2000, 1, 1, 0, 0, 10, DateTimeKind.Utc);

            this.C1B.I1AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 4, DateTimeKind.Utc);
            this.C1C.I1AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C1D.I1AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);

            this.C1B.S1AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 4, DateTimeKind.Utc);
            this.C1C.S1AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C1D.S1AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);

            this.C1B.I12AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 4, DateTimeKind.Utc);
            this.C1C.I12AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C1D.I12AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C2B.I12AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 4, DateTimeKind.Utc);
            this.C2C.I12AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C2D.I12AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);

            this.C1B.S1234AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 4, DateTimeKind.Utc);
            this.C1C.S1234AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C1D.S1234AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C2B.S1234AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 4, DateTimeKind.Utc);
            this.C2C.S1234AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C2D.S1234AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C3B.S1234AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 4, DateTimeKind.Utc);
            this.C3C.S1234AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C3D.S1234AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C4B.S1234AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 4, DateTimeKind.Utc);
            this.C4C.S1234AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);
            this.C4D.S1234AllorsDateTime = new DateTime(2000, 1, 1, 0, 0, 5, DateTimeKind.Utc);

            // Float
            this.C1B.C1AllorsDouble = 1;
            this.C1C.C1AllorsDouble = 2;
            this.C1D.C1AllorsDouble = 2;

            this.C1B.C1FloatLessThan = 0;
            this.C1C.C1FloatLessThan = 2;
            this.C1D.C1FloatLessThan = 4;

            this.C1B.C1FloatGreaterThan = 0;
            this.C1C.C1FloatGreaterThan = 2;
            this.C1D.C1FloatGreaterThan = 4;

            this.C1B.C1FloatBetweenA = -10;
            this.C1B.C1FloatBetweenB = 0;
            this.C1C.C1FloatBetweenA = 2;
            this.C1C.C1FloatBetweenB = 2;
            this.C1D.C1FloatBetweenA = 0;
            this.C1D.C1FloatBetweenB = 10;

            this.C1B.I1AllorsDouble = 1;
            this.C1C.I1AllorsDouble = 2;
            this.C1D.I1AllorsDouble = 2;

            this.C1B.S1AllorsDouble = 1;
            this.C1C.S1AllorsDouble = 2;
            this.C1D.S1AllorsDouble = 2;

            this.C1B.I12AllorsDouble = 1;
            this.C1C.I12AllorsDouble = 2;
            this.C1D.I12AllorsDouble = 2;
            this.C2B.I12AllorsDouble = 1;
            this.C2C.I12AllorsDouble = 2;
            this.C2D.I12AllorsDouble = 2;

            this.C1B.S1234AllorsDouble = 1;
            this.C1C.S1234AllorsDouble = 2;
            this.C1D.S1234AllorsDouble = 2;
            this.C2B.S1234AllorsDouble = 1;
            this.C2C.S1234AllorsDouble = 2;
            this.C2D.S1234AllorsDouble = 2;
            this.C3B.S1234AllorsDouble = 1;
            this.C3C.S1234AllorsDouble = 2;
            this.C3D.S1234AllorsDouble = 2;
            this.C4B.S1234AllorsDouble = 1;
            this.C4C.S1234AllorsDouble = 2;
            this.C4D.S1234AllorsDouble = 2;

            // Decimal
            this.C1B.C1AllorsDecimal = 1;
            this.C1C.C1AllorsDecimal = 2;
            this.C1D.C1AllorsDecimal = 2;

            this.C1B.C1DecimalLessThan = 0;
            this.C1C.C1DecimalLessThan = 2;
            this.C1D.C1DecimalLessThan = 4;

            this.C1B.C1DecimalGreaterThan = 0;
            this.C1C.C1DecimalGreaterThan = 2;
            this.C1D.C1DecimalGreaterThan = 4;

            this.C1B.C1DecimalBetweenA = -10;
            this.C1B.C1DecimalBetweenB = 0;
            this.C1C.C1DecimalBetweenA = 2;
            this.C1C.C1DecimalBetweenB = 2;
            this.C1D.C1DecimalBetweenA = 0;
            this.C1D.C1DecimalBetweenB = 10;

            this.C1B.I1AllorsDecimal = 1;
            this.C1C.I1AllorsDecimal = 2;
            this.C1D.I1AllorsDecimal = 2;

            this.C1B.S1AllorsDecimal = 1;
            this.C1C.S1AllorsDecimal = 2;
            this.C1D.S1AllorsDecimal = 2;

            this.C1B.I12AllorsDecimal = 1;
            this.C1C.I12AllorsDecimal = 2;
            this.C1D.I12AllorsDecimal = 2;
            this.C2B.I12AllorsDecimal = 1;
            this.C2C.I12AllorsDecimal = 2;
            this.C2D.I12AllorsDecimal = 2;

            this.C1B.S1234AllorsDecimal = 1;
            this.C1C.S1234AllorsDecimal = 2;
            this.C1D.S1234AllorsDecimal = 2;
            this.C2B.S1234AllorsDecimal = 1;
            this.C2C.S1234AllorsDecimal = 2;
            this.C2D.S1234AllorsDecimal = 2;
            this.C3B.S1234AllorsDecimal = 1;
            this.C3C.S1234AllorsDecimal = 2;
            this.C3D.S1234AllorsDecimal = 2;
            this.C4B.S1234AllorsDecimal = 1;
            this.C4C.S1234AllorsDecimal = 2;
            this.C4D.S1234AllorsDecimal = 2;

            // Composites
            this.C1B.C1C1one2one = this.C1B;
            this.C1C.C1C1one2one = this.C1C;
            this.C1D.C1C1one2one = this.C1D;

            this.C1B.C1C2one2one = this.C2B;
            this.C1C.C1C2one2one = this.C2C;
            this.C1D.C1C2one2one = this.C2D;

            this.C1B.C1C3one2one = this.C3B;
            this.C1C.C1C3one2one = this.C3C;
            this.C1D.C1C3one2one = this.C3D;

            this.C3B.C3C4one2one = this.C4B;
            this.C3C.C3C4one2one = this.C4C;
            this.C3D.C3C4one2one = this.C4D;

            this.C1B.I1I2one2one = this.C2B;
            this.C1C.I1I2one2one = this.C2C;
            this.C1D.I1I2one2one = this.C2D;

            this.C1B.S1S2one2one = this.C2B;
            this.C1C.S1S2one2one = this.C2C;
            this.C1D.S1S2one2one = this.C2D;

            this.C1B.I12C2one2one = this.C2B;
            this.C1C.I12C2one2one = this.C2C;
            this.C1D.I12C2one2one = this.C2D;
            this.C2A.I12C2one2one = this.C2A;

            this.C1B.I12C3one2one = this.C3B;
            this.C1C.I12C3one2one = this.C3C;
            this.C1D.I12C3one2one = this.C3D;
            this.C2A.I12C3one2one = this.C3A;

            this.C1B.S1234C2one2one = this.C2B;
            this.C1C.S1234C2one2one = this.C2C;
            this.C1D.S1234C2one2one = this.C2D;
            this.C2A.S1234C2one2one = this.C2A;

            this.C1B.C1I12one2one = this.C1B;
            this.C1C.C1I12one2one = this.C2B;
            this.C1D.C1I12one2one = this.C2C;

            this.C1B.S1234one2one = this.C1B;
            this.C1C.S1234one2one = this.C2B;
            this.C1D.S1234one2one = this.C3B;
            this.C2B.S1234one2one = this.C1C;
            this.C2C.S1234one2one = this.C2C;
            this.C2D.S1234one2one = this.C3C;
            this.C3B.S1234one2one = this.C1D;
            this.C3C.S1234one2one = this.C2D;
            this.C3D.S1234one2one = this.C3D;

            this.C1B.AddC1C1one2many(this.C1B);
            this.C1C.AddC1C1one2many(this.C1C);
            this.C1C.AddC1C1one2many(this.C1D);

            this.C1B.AddC1C2one2many(this.C2B);
            this.C1C.AddC1C2one2many(this.C2C);
            this.C1C.AddC1C2one2many(this.C2D);

            this.C3B.AddC3C4one2many(this.C4B);
            this.C3C.AddC3C4one2many(this.C4C);
            this.C3C.AddC3C4one2many(this.C4D);

            this.C1B.AddI1I2one2many(this.C2B);
            this.C1C.AddI1I2one2many(this.C2C);
            this.C1C.AddI1I2one2many(this.C2D);

            this.C1B.AddS1S2one2many(this.C2B);
            this.C1C.AddS1S2one2many(this.C2C);
            this.C1C.AddS1S2one2many(this.C2D);

            this.C1B.AddI12C2one2many(this.C2B);
            this.C2C.AddI12C2one2many(this.C2C);
            this.C2C.AddI12C2one2many(this.C2D);

            this.C1B.AddS1234C2one2many(this.C2B);
            this.C3C.AddS1234C2one2many(this.C2C);
            this.C3C.AddS1234C2one2many(this.C2D);

            this.C1B.AddC1I12one2many(this.C1B);
            this.C1C.AddC1I12one2many(this.C2C);
            this.C1C.AddC1I12one2many(this.C2D);

            this.C1B.AddS1234one2many(this.C1B);
            this.C3C.AddS1234one2many(this.C1C);
            this.C3C.AddS1234one2many(this.C1D);

            this.C1B.C1C1many2one = this.C1B;
            this.C1C.C1C1many2one = this.C1C;
            this.C1D.C1C1many2one = this.C1C;

            this.C1B.C1C2many2one = this.C2B;
            this.C1C.C1C2many2one = this.C2C;
            this.C1D.C1C2many2one = this.C2C;

            this.C3B.C3C4many2one = this.C4B;
            this.C3C.C3C4many2one = this.C4C;
            this.C3D.C3C4many2one = this.C4C;

            this.C1B.I1I2many2one = this.C2B;
            this.C1C.I1I2many2one = this.C2C;
            this.C1D.I1I2many2one = this.C2C;

            this.C1B.S1S2many2one = this.C2B;
            this.C1C.S1S2many2one = this.C2C;
            this.C1D.S1S2many2one = this.C2C;

            this.C1B.I12C2many2one = this.C2B;
            this.C2C.I12C2many2one = this.C2C;
            this.C2D.I12C2many2one = this.C2C;

            this.C1B.S1234C2many2one = this.C2B;
            this.C3C.S1234C2many2one = this.C2C;
            this.C3D.S1234C2many2one = this.C2C;

            this.C1B.C1I12many2one = this.C1B;
            this.C1C.C1I12many2one = this.C2C;
            this.C1D.C1I12many2one = this.C2C;

            this.C1B.S1234many2one = this.C1B;
            this.C3C.S1234many2one = this.C1C;
            this.C3D.S1234many2one = this.C1C;

            this.C1B.I12I34many2one = this.C3B;
            this.C2B.I12I34many2one = this.C4B;
            this.C2D.I12I34many2one = this.C4B;

            this.C1B.AddC1C1many2many(this.C1B);
            this.C1C.AddC1C1many2many(this.C1B);
            this.C1D.AddC1C1many2many(this.C1B);
            this.C1C.AddC1C1many2many(this.C1C);
            this.C1D.AddC1C1many2many(this.C1C);
            this.C1D.AddC1C1many2many(this.C1D);

            this.C1B.AddC1C2many2many(this.C2B);
            this.C1C.AddC1C2many2many(this.C2B);
            this.C1D.AddC1C2many2many(this.C2B);
            this.C1C.AddC1C2many2many(this.C2C);
            this.C1D.AddC1C2many2many(this.C2C);
            this.C1D.AddC1C2many2many(this.C2D);

            this.C1B.AddI1I2many2many(this.C2B);
            this.C1C.AddI1I2many2many(this.C2B);
            this.C1C.AddI1I2many2many(this.C2C);
            this.C1D.AddI1I2many2many(this.C2B);
            this.C1D.AddI1I2many2many(this.C2C);
            this.C1D.AddI1I2many2many(this.C2D);

            this.C1B.AddS1S2many2many(this.C2B);
            this.C1C.AddS1S2many2many(this.C2B);
            this.C1C.AddS1S2many2many(this.C2C);
            this.C1D.AddS1S2many2many(this.C2B);
            this.C1D.AddS1S2many2many(this.C2C);
            this.C1D.AddS1S2many2many(this.C2D);

            this.C1B.AddI12C2many2many(this.C2B);
            this.C1C.AddI12C2many2many(this.C2B);
            this.C1C.AddI12C2many2many(this.C2C);
            this.C1D.AddI12C2many2many(this.C2B);
            this.C1D.AddI12C2many2many(this.C2C);
            this.C1D.AddI12C2many2many(this.C2D);
            this.C2A.AddI12C2many2many(this.C2A);
            this.C2A.AddI12C2many2many(this.C2B);
            this.C2A.AddI12C2many2many(this.C2C);
            this.C2A.AddI12C2many2many(this.C2D);

            this.C1B.AddI12I34many2many(this.C3B);
            this.C1C.AddI12I34many2many(this.C3B);
            this.C1C.AddI12I34many2many(this.C3C);
            this.C1D.AddI12I34many2many(this.C3B);
            this.C1D.AddI12I34many2many(this.C3C);
            this.C1D.AddI12I34many2many(this.C3D);
            this.C2A.AddI12I34many2many(this.C4A);
            this.C2A.AddI12I34many2many(this.C4B);
            this.C2A.AddI12I34many2many(this.C4C);
            this.C2A.AddI12I34many2many(this.C4D);

            this.C1B.AddS1234C2many2many(this.C2B);
            this.C1C.AddS1234C2many2many(this.C2B);
            this.C1C.AddS1234C2many2many(this.C2C);
            this.C1D.AddS1234C2many2many(this.C2B);
            this.C1D.AddS1234C2many2many(this.C2C);
            this.C1D.AddS1234C2many2many(this.C2D);
            this.C2A.AddS1234C2many2many(this.C2A);
            this.C2A.AddS1234C2many2many(this.C2B);
            this.C2A.AddS1234C2many2many(this.C2C);
            this.C2A.AddS1234C2many2many(this.C2D);

            this.C1B.AddC1I12many2many(this.C1B);
            this.C1B.AddC1I12many2many(this.C2B);
            this.C1C.AddC1I12many2many(this.C2B);
            this.C1C.AddC1I12many2many(this.C2C);
            this.C1D.AddC1I12many2many(this.C2B);
            this.C1D.AddC1I12many2many(this.C2C);
            this.C1D.AddC1I12many2many(this.C2D);

            this.C1B.AddS1234many2many(this.C1B);
            this.C1B.AddS1234many2many(this.C1A);
            this.C1C.AddS1234many2many(this.C2B);
            this.C1C.AddS1234many2many(this.C1A);
            this.C1D.AddS1234many2many(this.C3B);
            this.C1D.AddS1234many2many(this.C1A);
            this.C2B.AddS1234many2many(this.C1C);
            this.C2B.AddS1234many2many(this.C1A);
            this.C2C.AddS1234many2many(this.C2C);
            this.C2C.AddS1234many2many(this.C1A);
            this.C2D.AddS1234many2many(this.C3C);
            this.C2D.AddS1234many2many(this.C1A);
            this.C3B.AddS1234many2many(this.C1D);
            this.C3B.AddS1234many2many(this.C1A);
            this.C3C.AddS1234many2many(this.C2D);
            this.C3C.AddS1234many2many(this.C1A);
            this.C3D.AddS1234many2many(this.C3D);
            this.C3D.AddS1234many2many(this.C1A);


            this.C1B.ClassName = "c1";
            this.C3B.ClassName = "c3";
        }
예제 #13
0
        public override void AllorsDecimal()
        {
            // Positive
            {
                C1 values = C1.Create(this.Session);
                values.C1AllorsDecimal = 10.10m;
                values.I1AllorsDecimal = 10.10m;
                values.S1AllorsDecimal = 10.10m;

                this.Session.Commit();

                Assert.AreEqual(10.10m, values.C1AllorsDecimal);
                Assert.AreEqual(10.10m, values.I1AllorsDecimal);
                Assert.AreEqual(10.10m, values.S1AllorsDecimal);
            }

            // Negative
            {
                C1 values = C1.Create(this.Session);
                values.C1AllorsDecimal = -10.10m;
                values.I1AllorsDecimal = -10.10m;
                values.S1AllorsDecimal = -10.10m;

                this.Session.Commit();
                ;

                Assert.AreEqual(-10.10m, values.C1AllorsDecimal);
                Assert.AreEqual(-10.10m, values.I1AllorsDecimal);
                Assert.AreEqual(-10.10m, values.S1AllorsDecimal);
            }

            // Zero
            {
                C1 values = C1.Create(this.Session);
                values.C1AllorsDecimal = 0m;
                values.I1AllorsDecimal = 0m;
                values.S1AllorsDecimal = 0m;

                this.Session.Commit();
                ;

                Assert.AreEqual(0m, values.C1AllorsDecimal);
                Assert.AreEqual(0m, values.I1AllorsDecimal);
                Assert.AreEqual(0m, values.S1AllorsDecimal);
            }

            // initial empty
            {
                C1 values = C1.Create(this.Session);

                decimal?value           = -1;
                var     exceptionThrown = false;
                try
                {
                    value = values.C1AllorsDecimal;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.I1AllorsDecimal;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.S1AllorsDecimal;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                Assert.AreEqual(-1, value);

                Assert.IsFalse(values.ExistC1AllorsDecimal);
                Assert.IsFalse(values.ExistI1AllorsDecimal);
                Assert.IsFalse(values.ExistS1AllorsDecimal);

                this.Session.Commit();

                value           = -1;
                exceptionThrown = false;
                try
                {
                    value = values.C1AllorsDecimal;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.I1AllorsDecimal;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.S1AllorsDecimal;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                Assert.AreEqual(-1, value);

                Assert.IsFalse(values.ExistC1AllorsDecimal);
                Assert.IsFalse(values.ExistI1AllorsDecimal);
                Assert.IsFalse(values.ExistS1AllorsDecimal);
            }

            // reset empty
            {
                C1 values = C1.Create(this.Session);
                values.C1AllorsDecimal = 10.10m;
                values.I1AllorsDecimal = 10.10m;
                values.S1AllorsDecimal = 10.10m;

                this.Session.Commit();

                Assert.IsTrue(values.ExistC1AllorsDecimal);
                Assert.IsTrue(values.ExistI1AllorsDecimal);
                Assert.IsTrue(values.ExistS1AllorsDecimal);

                values.RemoveC1AllorsDecimal();
                values.RemoveI1AllorsDecimal();
                values.RemoveS1AllorsDecimal();

                decimal?value           = -1;
                var     exceptionThrown = false;
                try
                {
                    value = values.C1AllorsDecimal;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.I1AllorsDecimal;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.S1AllorsDecimal;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                Assert.AreEqual(-1, value);

                Assert.IsFalse(values.ExistC1AllorsDecimal);
                Assert.IsFalse(values.ExistI1AllorsDecimal);
                Assert.IsFalse(values.ExistS1AllorsDecimal);

                this.Session.Commit();
                value           = -1;
                exceptionThrown = false;
                try
                {
                    value = values.C1AllorsDecimal;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.I1AllorsDecimal;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.S1AllorsDecimal;
                }
                catch { exceptionThrown = true; }
                Assert.IsTrue(exceptionThrown);
                Assert.AreEqual(-1, value);

                Assert.IsFalse(values.ExistC1AllorsDecimal);
                Assert.IsFalse(values.ExistI1AllorsDecimal);
                Assert.IsFalse(values.ExistS1AllorsDecimal);
            }
        }
예제 #14
0
        public override void AllorsDecimal()
        {
            foreach (var init in this.Inits)
            {
                init();

                // Positive
                {
                    var values = C1.Create(this.Session);
                    values.C1AllorsDecimal = 10.10m;
                    values.I1AllorsDecimal = 10.10m;
                    values.S1AllorsDecimal = 10.10m;

                    this.Session.Commit();

                    Assert.Equal(10.10m, values.C1AllorsDecimal);
                    Assert.Equal(10.10m, values.I1AllorsDecimal);
                    Assert.Equal(10.10m, values.S1AllorsDecimal);
                }

                // Negative
                {
                    var values = C1.Create(this.Session);
                    values.C1AllorsDecimal = -10.10m;
                    values.I1AllorsDecimal = -10.10m;
                    values.S1AllorsDecimal = -10.10m;

                    this.Session.Commit();

                    Assert.Equal(-10.10m, values.C1AllorsDecimal);
                    Assert.Equal(-10.10m, values.I1AllorsDecimal);
                    Assert.Equal(-10.10m, values.S1AllorsDecimal);
                }

                // Zero
                {
                    var values = C1.Create(this.Session);
                    values.C1AllorsDecimal = 0m;
                    values.I1AllorsDecimal = 0m;
                    values.S1AllorsDecimal = 0m;

                    this.Session.Commit();

                    Assert.Equal(0m, values.C1AllorsDecimal);
                    Assert.Equal(0m, values.I1AllorsDecimal);
                    Assert.Equal(0m, values.S1AllorsDecimal);
                }

                // initial empty
                {
                    var values = C1.Create(this.Session);

                    decimal?value = null;

                    value = values.C1AllorsDecimal;
                    Assert.Null(value);

                    value = values.I1AllorsDecimal;
                    Assert.Null(value);

                    value = values.S1AllorsDecimal;
                    Assert.Null(value);

                    Assert.False(values.ExistC1AllorsDecimal);
                    Assert.False(values.ExistI1AllorsDecimal);
                    Assert.False(values.ExistS1AllorsDecimal);

                    this.Session.Commit();

                    value = values.C1AllorsDecimal;
                    Assert.Null(value);

                    value = values.I1AllorsDecimal;
                    Assert.Null(value);

                    value = values.S1AllorsDecimal;
                    Assert.Null(value);

                    Assert.False(values.ExistC1AllorsDecimal);
                    Assert.False(values.ExistI1AllorsDecimal);
                    Assert.False(values.ExistS1AllorsDecimal);
                }

                // reset empty
                {
                    var values = C1.Create(this.Session);
                    values.C1AllorsDecimal = 10.10m;
                    values.I1AllorsDecimal = 10.10m;
                    values.S1AllorsDecimal = 10.10m;

                    this.Session.Commit();

                    Assert.True(values.ExistC1AllorsDecimal);
                    Assert.True(values.ExistI1AllorsDecimal);
                    Assert.True(values.ExistS1AllorsDecimal);

                    values.RemoveC1AllorsDecimal();
                    values.RemoveI1AllorsDecimal();
                    values.RemoveS1AllorsDecimal();

                    decimal?value = null;
                    value = values.C1AllorsDecimal;
                    Assert.Null(value);

                    value = values.I1AllorsDecimal;
                    Assert.Null(value);

                    value = values.S1AllorsDecimal;
                    Assert.Null(value);

                    Assert.False(values.ExistC1AllorsDecimal);
                    Assert.False(values.ExistI1AllorsDecimal);
                    Assert.False(values.ExistS1AllorsDecimal);

                    this.Session.Commit();

                    value = values.C1AllorsDecimal;
                    Assert.Null(value);

                    value = values.I1AllorsDecimal;
                    Assert.Null(value);

                    value = values.S1AllorsDecimal;
                    Assert.Null(value);

                    Assert.False(values.ExistC1AllorsDecimal);
                    Assert.False(values.ExistI1AllorsDecimal);
                    Assert.False(values.ExistS1AllorsDecimal);
                }
            }
        }
예제 #15
0
        public void FailedCommit()
        {
            var database = this.CreateDatabase();

            database.Init();

            long c1Id = 0;
            long c2Id = 0;

            using (var session = database.CreateSession())
            {
                var c1 = C1.Create(session);
                var c2 = C2.Create(session);

                c1Id = c1.Id;
                c2Id = c2.Id;

                c1.C1C2one2one = c2;

                session.Commit();

                c1.C1AllorsString = "Session 1";

                using (var session2 = database.CreateSession())
                {
                    var session2C1 = (C1)session2.Instantiate(c1);
                    session2C1.C1AllorsString = "Session 2";

                    session2C1.C1C2one2one = null;

                    session2.Commit();

                    var session2C2 = (C2)session2.Instantiate(c2);
                    session2C2.Strategy.Delete();

                    session2.Commit();
                }

                var triggerCache = c1.C1C2one2one;

                var exceptionThrown = false;
                try
                {
                    session.Commit();
                }
                catch
                {
                    exceptionThrown = true;
                }

                Assert.True(exceptionThrown);
            }

            using (var session = database.CreateSession())
            {
                var c1 = (C1)session.Instantiate(c1Id);
                var c2 = session.Instantiate(c2Id);

                Assert.Null(c1.C1C2one2one);
            }
        }
예제 #16
0
        public override void AllorsDate()
        {
            {
// year, day & month
                C1 values = C1.Create(this.Session);
                values.C1AllorsDate = new DateTime(1973, 03, 27, 1, 1, 1);
                values.I1AllorsDate = new DateTime(1973, 03, 27, 2, 2, 2);
                Assert.AreEqual(new DateTime(1973, 03, 27), values.C1AllorsDate);
                Assert.AreEqual(new DateTime(1973, 03, 27), values.I1AllorsDate);
            }

            {
                // Minimum
                C1 values = C1.Create(this.Session);
                values.C1AllorsDate = this.MinimumDatetime;
                values.I1AllorsDate = this.MinimumDatetime;
                Assert.AreEqual(this.MinimumDatetime.Date, values.C1AllorsDate);
                Assert.AreEqual(this.MinimumDatetime.Date, values.I1AllorsDate);
            }

            {
                // Maximum
                C1 values = C1.Create(this.Session);
                values.C1AllorsDate = this.MaximumDatetime;
                values.I1AllorsDate = this.MaximumDatetime;
                Assert.AreEqual(this.MaximumDatetime.Date, values.C1AllorsDate);
                Assert.AreEqual(this.MaximumDatetime.Date, values.I1AllorsDate);
            }

            {
                // initial empty
                C1 values = C1.Create(this.Session);

                DateTime value           = DateTime.Now;
                DateTime valueOld        = value;
                bool     exceptionThrown = false;
                try
                {
                    value = values.C1AllorsDate;
                }
                catch
                {
                    exceptionThrown = true;
                }

                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.I1AllorsDate;
                }
                catch
                {
                    exceptionThrown = true;
                }

                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.S1AllorsDate;
                }
                catch
                {
                    exceptionThrown = true;
                }

                Assert.IsTrue(exceptionThrown);
                Assert.AreEqual(valueOld, value);

                Assert.IsFalse(values.ExistC1AllorsDate);
                Assert.IsFalse(values.ExistI1AllorsDate);
                Assert.IsFalse(values.ExistS1AllorsDate);

                this.Session.Commit();

                value           = DateTime.Now;
                valueOld        = value;
                exceptionThrown = false;
                try
                {
                    value = values.C1AllorsDate;
                }
                catch
                {
                    exceptionThrown = true;
                }

                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.I1AllorsDate;
                }
                catch
                {
                    exceptionThrown = true;
                }

                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.S1AllorsDate;
                }
                catch
                {
                    exceptionThrown = true;
                }

                Assert.IsTrue(exceptionThrown);
                Assert.AreEqual(valueOld, value);

                Assert.IsFalse(values.ExistC1AllorsDate);
                Assert.IsFalse(values.ExistI1AllorsDate);
                Assert.IsFalse(values.ExistS1AllorsDate);
            }

            {
                // reset empty
                C1 values = C1.Create(this.Session);
                values.C1AllorsDate = DateTime.Now;
                values.I1AllorsDate = DateTime.Now;
                values.S1AllorsDate = DateTime.Now;

                this.Session.Commit();

                Assert.IsTrue(values.ExistC1AllorsDate);
                Assert.IsTrue(values.ExistI1AllorsDate);
                Assert.IsTrue(values.ExistS1AllorsDate);

                values.RemoveC1AllorsDate();
                values.RemoveI1AllorsDate();
                values.RemoveS1AllorsDate();

                DateTime value           = DateTime.Now;
                DateTime valueOld        = value;
                bool     exceptionThrown = false;
                try
                {
                    value = values.C1AllorsDate;
                }
                catch
                {
                    exceptionThrown = true;
                }

                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.I1AllorsDate;
                }
                catch
                {
                    exceptionThrown = true;
                }

                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.S1AllorsDate;
                }
                catch
                {
                    exceptionThrown = true;
                }

                Assert.IsTrue(exceptionThrown);
                Assert.AreEqual(valueOld, value);

                Assert.IsFalse(values.ExistC1AllorsDate);
                Assert.IsFalse(values.ExistI1AllorsDate);
                Assert.IsFalse(values.ExistS1AllorsDate);

                this.Session.Commit();

                value           = DateTime.Now;
                valueOld        = value;
                exceptionThrown = false;
                try
                {
                    value = values.C1AllorsDate;
                }
                catch
                {
                    exceptionThrown = true;
                }

                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.I1AllorsDate;
                }
                catch
                {
                    exceptionThrown = true;
                }

                Assert.IsTrue(exceptionThrown);
                exceptionThrown = false;
                try
                {
                    value = values.S1AllorsDate;
                }
                catch
                {
                    exceptionThrown = true;
                }

                Assert.IsTrue(exceptionThrown);
                Assert.AreEqual(valueOld, value);

                Assert.IsFalse(values.ExistC1AllorsDate);
                Assert.IsFalse(values.ExistI1AllorsDate);
                Assert.IsFalse(values.ExistS1AllorsDate);
            }
        }
예제 #17
0
        private void Populate(ISession session)
        {
            this.c1A = C1.Create(session);
            this.c1B = C1.Create(session);
            this.c1C = C1.Create(session);
            this.c1D = C1.Create(session);
            this.c2A = C2.Create(session);
            this.c2B = C2.Create(session);
            this.c2C = C2.Create(session);
            this.c2D = C2.Create(session);
            this.c3A = C3.Create(session);
            this.c3B = C3.Create(session);
            this.c3C = C3.Create(session);
            this.c3D = C3.Create(session);
            this.c4A = C4.Create(session);
            this.c4B = C4.Create(session);
            this.c4C = C4.Create(session);
            this.c4D = C4.Create(session);

            IObject[] allObjects =
            {
                this.c1A, this.c1B, this.c1C, this.c1D, this.c2A, this.c2B, this.c2C, this.c2D,
                this.c3A, this.c3B, this.c3C, this.c3D, this.c4A, this.c4B, this.c4C, this.c4D
            };

            this.c1A.C1AllorsString   = string.Empty; // emtpy string
            this.c1A.C1AllorsInteger  = -1;
            this.c1A.C1AllorsDecimal  = 1.1m;
            this.c1A.C1AllorsDouble   = 1.1d;
            this.c1A.C1AllorsBoolean  = true;
            this.c1A.C1AllorsDateTime = new DateTime(1973, 3, 27, 12, 1, 2, 3, DateTimeKind.Utc);
            this.c1A.C1AllorsUnique   = new Guid(GuidString);
            this.c1A.C1AllorsBinary   = new byte[0];

            this.c1B.C1AllorsString = "a1";
            this.c1B.C1AllorsBinary = new byte[] { 0, 1, 2, 3 };
            this.c1B.C1C2one2one    = this.c2A;
            this.c1B.C1C2many2one   = this.c2A;
            this.c1C.C1C2many2one   = this.c2A;
            this.c1B.AddC1C2one2many(this.c2A);
            this.c1B.AddC1C2one2many(this.c2B);
            this.c1B.AddC1C2one2many(this.c2C);
            this.c1B.AddC1C2one2many(this.c2D);
            this.c1B.AddC1C2many2many(this.c2A);
            this.c1B.AddC1C2many2many(this.c2B);
            this.c1B.AddC1C2many2many(this.c2C);
            this.c1B.AddC1C2many2many(this.c2D);

            this.c1C.C1AllorsString = "a2";
            this.c1C.C1AllorsBinary = null;

            this.c3A.I34AllorsString = "c3a";
            this.c4A.I34AllorsString = "c4a";

            foreach (S1234 allorsObject in allObjects)
            {
                foreach (S1234 addObject in allObjects)
                {
                    allorsObject.AddS1234many2many(addObject);
                }
            }

            session.Commit();
        }