public void Can_get_referencing_foreign_keys()
        {
            var entityType = new EntityType("Customer");
            var modelMock  = new Mock <Model>();

            entityType.Model = modelMock.Object;

            entityType.GetReferencingForeignKeys();

            modelMock.Verify(m => m.GetReferencingForeignKeys(entityType), Times.Once());
        }
Esempio n. 2
0
        public void Can_get_referencing_foreign_keys()
        {
            var model       = new Model();
            var entityType1 = new EntityType(typeof(Customer));
            var entityType2 = new EntityType(typeof(Order));
            var keyProperty = new Property("Id", typeof(Customer))
            {
                EntityType = entityType1
            };
            var fkProperty = new Property("CustomerId", typeof(Order))
            {
                EntityType = entityType2
            };
            var foreignKey = entityType2.AddForeignKey(new Key(new[] { keyProperty }), fkProperty);

            model.AddEntityType(entityType1);
            model.AddEntityType(entityType2);

            var referencingForeignKeys = model.GetReferencingForeignKeys(entityType1);

            Assert.Same(foreignKey, referencingForeignKeys.Single());
            Assert.Same(foreignKey, entityType1.GetReferencingForeignKeys().Single());
        }