Пример #1
0
        public void Navigation_back_pointer_is_fixed_up_as_navigation_is_added_and_removed()
        {
            var entityType1 = new EntityType(typeof(Customer));

            entityType1.SetKey(entityType1.AddProperty(Customer.IdProperty));
            var entityType2 = new EntityType(typeof(Customer));

            var navigation
                = new Navigation(
                      new ForeignKey(
                          entityType1.GetKey(),
                          new[] { entityType1.AddProperty(Customer.IdProperty) }), "Nav", pointsToPrincipal: true);

            entityType1.AddNavigation(navigation);

            Assert.Same(entityType1, navigation.EntityType);

            entityType2.AddNavigation(navigation);

            Assert.Same(entityType2, navigation.EntityType);
            Assert.Empty(entityType1.Navigations);

            entityType2.RemoveNavigation(navigation);

            Assert.Empty(entityType2.Navigations);
            Assert.Null(navigation.EntityType);
        }