예제 #1
0
        public void HasInverseEndMultiplicity_sets_the_InverseEndKind()
        {
            var configuration =
                new NavigationPropertyConfiguration(
                    typeof(LightweighEntity).GetDeclaredProperty("ValidNavigationProperty"));
            var lightweightConfiguration = new ConventionNavigationPropertyConfiguration(configuration, new ModelConfiguration());

            lightweightConfiguration.HasInverseEndMultiplicity(RelationshipMultiplicity.ZeroOrOne);
            Assert.Equal(RelationshipMultiplicity.ZeroOrOne, configuration.InverseEndKind);

            configuration.InverseEndKind = RelationshipMultiplicity.Many;
            lightweightConfiguration.HasInverseEndMultiplicity(RelationshipMultiplicity.ZeroOrOne);
            Assert.Equal(RelationshipMultiplicity.Many, configuration.InverseEndKind);
        }
예제 #2
0
        public void Methods_dont_throw_if_configuration_is_null()
        {
            var config = new ConventionNavigationPropertyConfiguration(null, null);

            Assert.Null(config.ClrPropertyInfo);
            config.HasConstraint <IndependentConstraintConfiguration>();
            config.HasDeleteAction(OperationAction.Cascade);
            config.HasInverseEndMultiplicity(RelationshipMultiplicity.ZeroOrOne);
            config.HasInverseNavigationProperty(p => new MockPropertyInfo());
            config.IsDeclaringTypePrincipal(true);
            config.HasRelationshipMultiplicity(RelationshipMultiplicity.ZeroOrOne);
        }
예제 #3
0
        public void HasInverseNavigationProperty_throws_on_incompatible_multiplicity()
        {
            var navigationProperty       = typeof(LightweighEntity).GetDeclaredProperty("ValidNavigationProperty");
            var configuration            = new NavigationPropertyConfiguration(navigationProperty);
            var modelConfiguration       = new ModelConfiguration();
            var lightweightConfiguration = new ConventionNavigationPropertyConfiguration(configuration, modelConfiguration);

            var inverseNavigationProperty =
                typeof(LightweighEntity).GetDeclaredProperty("ValidInverseNavigationProperty");

            lightweightConfiguration.HasInverseEndMultiplicity(RelationshipMultiplicity.Many);

            Assert.Equal(
                Strings.LightweightNavigationPropertyConfiguration_IncompatibleMultiplicity(
                    "*",
                    typeof(LightweighEntity).Name + "." + "ValidInverseNavigationProperty",
                    typeof(LightweighEntity).FullName),
                Assert.Throws <InvalidOperationException>(
                    () => lightweightConfiguration.HasInverseNavigationProperty(p => inverseNavigationProperty)).Message);
        }