public void DbEntityPropertyPath_entity_path_no_property_path()
        {
            MockEntity entity           = new MockEntity();
            MockEntity relationalEntity = new MockEntity();

            entity.RelationalEntities.Add(relationalEntity);
            string         entityPath = ".RelationalEntities[Guid=" + relationalEntity.Guid + "]";
            PropertyChange change     = new PropertyChange(entityPath, string.Empty, string.Empty, null, null);

            Assert.AreEqual(entityPath, change.DbEntityPropertyPath(entity));
        }
        public void DbEntityPropertyPath_collection_entity_zero_or_null_primary_keys()
        {
            MockEntity entity           = new MockEntity();
            MockEntity relationalEntity = new MockEntity();

            entity.RelationalEntities.Add(relationalEntity);
            string         entityPath   = ".RelationalEntities[Guid=" + relationalEntity.Guid + "]";
            string         propertyName = "StringProperty";
            PropertyChange change       = new PropertyChange(entityPath, propertyName, string.Empty, string.Empty, false);
            string         path         = change.DbEntityPropertyPath(entity);

            Assert.AreEqual(entityPath + "." + propertyName, path);
        }
        public void DbEntityPropertyPath_non_collection_entity()
        {
            PropertyChange change = new PropertyChange(".RelationalEntity1", "StringProperty", string.Empty, string.Empty, "Changed", EntityState.New);
            string         path   = change.DbEntityPropertyPath(new MockEntity()
            {
                RelationalEntity1 = new MockEntity()
                {
                    StringProperty = "Changed"
                }
            });

            Assert.AreEqual(".RelationalEntity1.StringProperty", path);
        }
        public void DbEntityPropertyPath_entity_path_no_property_path_2()
        {
            MockEntity entity           = new MockEntity();
            MockEntity manyToManyEntity = new MockEntity();
            MockEntity oneToOneEntity   = new MockEntity();

            manyToManyEntity.RelationalEntities.Add(oneToOneEntity);
            MockEntity associativeEntity = new MockEntity()
            {
                RelationalEntity1 = manyToManyEntity
            };

            entity.RelationalEntities.Add(associativeEntity);
            string         entityPath = ".RelationalEntities[Guid=" + associativeEntity.Guid + "].RelationalEntity1.RelationalEntities[Guid=" + oneToOneEntity.Guid + "]";
            PropertyChange change     = new PropertyChange(entityPath, string.Empty, string.Empty, null, null);

            Assert.AreEqual(entityPath, change.DbEntityPropertyPath(entity));
        }
        public void DbEntityPropertyPath_multiple_collection_entitities_mixed_zero_non_zero_primary_keys()
        {
            MockEntity manyToOneRelation = new MockEntity();
            MockEntity oneToManyRelation = new MockEntity();

            manyToOneRelation.RelationalEntities.Add(oneToManyRelation);
            MockEntity manyToManyRelation = new MockEntity()
            {
                id = 2, RelationalEntity1 = manyToOneRelation
            };
            MockEntity entity = new MockEntity();

            entity.RelationalEntities.Add(manyToManyRelation);
            string         entityPath   = ".RelationalEntities[Guid=" + manyToManyRelation.Guid + "].RelationalEntity1.RelationalEntities[Guid=" + oneToManyRelation.Guid + "]";
            string         propertyName = "StringProperty";
            PropertyChange change       = new PropertyChange(entityPath, propertyName, string.Empty, 2, 3);
            string         path         = change.DbEntityPropertyPath(entity);

            Assert.AreEqual(".RelationalEntities[id=2].RelationalEntity1.RelationalEntities[Guid=" + oneToManyRelation.Guid + "]." + propertyName, path);
        }
        public void DbEntityPropertyPath_entity_path_no_property_path_3()
        {
            MockEntity entity1 = new MockEntity()
            {
                id = 1
            };

            entity1.MarkPersisted();
            MockEntity entity2 = new MockEntity()
            {
                id = 2
            };

            entity2.MarkPersisted();
            MockAssociativeEntity associativeEntity = new MockAssociativeEntity()
            {
                RelationalEntity1Id = entity1.id, RelationalEntity2Id = entity2.id, RelationalEntity2 = entity2
            };

            associativeEntity.MarkPersisted();
            entity1.AssociativeEntities.Add(associativeEntity);
            MockEntity entity3 = new MockEntity();

            entity2.RelationalEntity1 = entity3;
            MockEntity entity4 = new MockEntity()
            {
                id = 3, StringProperty = "3"
            };

            entity3.RelationalEntities.Add(entity4);
            string         entityPath         = ".AssociativeEntities[Guid=" + associativeEntity.Guid + "].RelationalEntity2.RelationalEntity1.RelationalEntities[Guid=" + entity4.Guid + "]";
            string         expectedEntityPath = ".AssociativeEntities[RelationalEntity1Id=" + entity1.id + ",RelationalEntity2Id=" + entity2.id + "].RelationalEntity2.RelationalEntity1.RelationalEntities[id=" + entity4.id + "]";
            PropertyChange change             = new PropertyChange(entityPath, string.Empty, string.Empty, null, null);

            Assert.AreEqual(expectedEntityPath, change.DbEntityPropertyPath(entity1));
        }