Esempio n. 1
0
        public void Entity_GetIdentityDefault()
        {
            EntityNoKeyMembers e0 = new EntityNoKeyMembers();

            ExceptionHelper.ExpectArgumentException(() => { e0.GetIdentity(); }, Resource.EntityKey_EmptyKeyMembers, "keyValues");

            Entity1KeyMember e1 = new Entity1KeyMember()
            {
                K1 = 5
            };

            Entity1KeyMember ee1 = new Entity1KeyMember()
            {
                K1 = 5
            };

            EnsureEntityKeysEqual(e1, ee1);
            ee1.K1 = 7;
            EnsureEntityKeysNotEqual(e1, ee1);

            Entity2KeyMembers e2  = new Entity2KeyMembers(e1, "A");
            Entity2KeyMembers ee2 = new Entity2KeyMembers(e1, "A");

            EnsureEntityKeysEqual(e2, ee2);
            ee2.K2 = "B";
            EnsureEntityKeysNotEqual(e2, ee2);

            Entity3KeyMembers e3  = new Entity3KeyMembers(e2, 3.1m);
            Entity3KeyMembers ee3 = new Entity3KeyMembers(e2, 3.1m);

            EnsureEntityKeysEqual(e3, ee3);
            ee3.K3 = 4.2m;
            EnsureEntityKeysNotEqual(e3, ee3);

            DateTime          someDate = new DateTime(2009, 1, 1);
            Entity4KeyMembers e4       = new Entity4KeyMembers(e3, someDate);
            Entity4KeyMembers ee4      = new Entity4KeyMembers(e3, someDate);

            EnsureEntityKeysEqual(e4, ee4);
            ee4.K4 = new DateTime(2008, 1, 1);
            EnsureEntityKeysNotEqual(e4, ee4);

            Entity5KeyMembers e5  = new Entity5KeyMembers(e4, TimeSpan.FromHours(2));
            Entity5KeyMembers ee5 = new Entity5KeyMembers(e4, TimeSpan.FromHours(2));

            EnsureEntityKeysEqual(e5, ee5);
            ee5.K5 = TimeSpan.FromHours(3);
            EnsureEntityKeysNotEqual(e5, ee5);

            Guid someGuid         = Guid.NewGuid();
            Entity4KeyMembers e6  = new Entity6KeyMembers(e5, someGuid);
            Entity6KeyMembers ee6 = new Entity6KeyMembers(e5, someGuid);

            EnsureEntityKeysEqual(e6, ee6);
            ee6.K6 = Guid.NewGuid();
            EnsureEntityKeysNotEqual(e6, ee6);
        }
Esempio n. 2
0
 public Entity5KeyMembers(Entity4KeyMembers e4, TimeSpan k5)
     : base(e4, e4.K4)
 {
     this.K5 = k5;
 }