示例#1
0
        private void AssertPopulation(ISession session)
        {
            Assert.Equal(4, this.GetExtent(session, C1.Meta.ObjectType).Length);
            Assert.Equal(4, this.GetExtent(session, C2.Meta.ObjectType).Length);
            Assert.Equal(4, this.GetExtent(session, C3.Meta.ObjectType).Length);
            Assert.Equal(4, this.GetExtent(session, C4.Meta.ObjectType).Length);

            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);
            var c1DCopy = C1.Instantiate(session, this.c1D.Strategy.ObjectId);
            var c2ACopy = C2.Instantiate(session, this.c2A.Strategy.ObjectId);
            var c2BCopy = C2.Instantiate(session, this.c2B.Strategy.ObjectId);
            var c2CCopy = C2.Instantiate(session, this.c2C.Strategy.ObjectId);
            var c2DCopy = C2.Instantiate(session, this.c2D.Strategy.ObjectId);
            var c3ACopy = C3.Instantiate(session, this.c3A.Strategy.ObjectId);
            var c3BCopy = C3.Instantiate(session, this.c3B.Strategy.ObjectId);
            var c3CCopy = C3.Instantiate(session, this.c3C.Strategy.ObjectId);
            var c3DCopy = C3.Instantiate(session, this.c3D.Strategy.ObjectId);
            var c4ACopy = C4.Instantiate(session, this.c4A.Strategy.ObjectId);
            var c4BCopy = C4.Instantiate(session, this.c4B.Strategy.ObjectId);
            var c4CCopy = C4.Instantiate(session, this.c4C.Strategy.ObjectId);
            var c4DCopy = C4.Instantiate(session, this.c4D.Strategy.ObjectId);

            IObject[] everyC1     = { c1ACopy, c1BCopy, c1CCopy, c1DCopy };
            IObject[] everyC2     = { c2ACopy, c2BCopy, c2CCopy, c2DCopy };
            IObject[] everyC3     = { c3ACopy, c3BCopy, c3CCopy, c3DCopy };
            IObject[] everyC4     = { c4ACopy, c4BCopy, c4CCopy, c4DCopy };
            IObject[] everyObject =
            {
                c1ACopy, c1BCopy, c1CCopy, c1DCopy, c2ACopy, c2BCopy, c2CCopy, c2DCopy, c3ACopy,
                c3BCopy, c3CCopy, c3DCopy, c4ACopy, c4BCopy, c4CCopy, c4DCopy
            };

            foreach (var allorsObject in everyObject)
            {
                Assert.NotNull(allorsObject);
            }

            if (this.EmptyStringIsNull)
            {
                Assert.False(c1ACopy.ExistC1AllorsString);
            }
            else
            {
                Assert.Equal(this.c1A.C1AllorsString, string.Empty);
            }

            Assert.Equal(this.c1A.C1AllorsInteger, -1);
            Assert.Equal(1.1m, this.c1A.C1AllorsDecimal);
            Assert.Equal(1.1d, this.c1A.C1AllorsDouble);
            Assert.True(this.c1A.C1AllorsBoolean);
            Assert.Equal(this.c1A.C1AllorsDateTime, new DateTime(1973, 3, 27, 12, 1, 2, 3, DateTimeKind.Utc));
            Assert.Equal(this.c1A.C1AllorsUnique, new Guid(GuidString));

            Assert.Equal(this.c1A.C1AllorsBinary, new byte[0]);
            Assert.Equal(this.c1B.C1AllorsBinary, new byte[] { 0, 1, 2, 3 });
            Assert.Null(this.c1C.C1AllorsBinary);

            Assert.Equal("a1", c2ACopy.C1WhereC1C2one2one.C1AllorsString);
            Assert.Equal("a1", c2ACopy.C1WhereC1C2one2many.C1AllorsString);
            Assert.Equal("a1", c2BCopy.C1WhereC1C2one2many.C1AllorsString);

            Assert.Equal("c3a", c3ACopy.I34AllorsString);
            Assert.Equal("c4a", c4ACopy.I34AllorsString);

            Assert.Equal(2, c2ACopy.C1sWhereC1C2many2one.Count);
            Assert.Empty(c2BCopy.C1sWhereC1C2many2one);
            Assert.Single(c2ACopy.C1sWhereC1C2many2many);
            Assert.Single(c2BCopy.C1sWhereC1C2many2many);

            foreach (S1234 allorsObject in everyObject)
            {
                Assert.Equal(everyObject.Length, allorsObject.S1234many2manies.Count);
                foreach (S1234 addObject in everyObject)
                {
                    var objects = allorsObject.S1234many2manies.ToArray();
                    Assert.Contains(addObject, objects);
                }
            }
        }