Пример #1
0
        public void HasManyForeignKeysShouldBeTrue()
        {
            var multiKeyTags = this.entityTypeBuilder
                               .Name("My.Tags")
                               .WithProperty <int>("ID")
                               .WithProperty <int>("Post_00_ID")
                               .WithProperty <int>("Post_01_ID")
                               .WithKeys("ID")
                               .Build();

            var navigationProperty = this.builder
                                     .FromRole(this.posts, RelationshipMultiplicity.Many)
                                     .ToRole(multiKeyTags, RelationshipMultiplicity.One)
                                     .Map(new[] { "ID" }, new[] { "Post_00_ID", "Post_01_ID" })
                                     .Build();

            var testSubject = new MappingRelationshipForeignKeyMatcherHasForeignKey();

            testSubject.IsMatch(navigationProperty).Should().BeTrue();

            testSubject.ForeignKeys.Should().HaveCount(2);
            var foreignKeys = testSubject.ForeignKeys.ToArray();

            foreignKeys[0].Should().Be("Post_00_ID");
            foreignKeys[1].Should().Be("Post_01_ID");
        }
Пример #2
0
        public void HasForeignKeyShouldBeFalse()
        {
            var navigationProperty = this.builder
                                     .FromRole(this.posts, RelationshipMultiplicity.One)
                                     .ToRole(this.tags, RelationshipMultiplicity.Many)
                                     .Map("ID", "Post_ID")
                                     .Build();

            var testSubject = new MappingRelationshipForeignKeyMatcherHasForeignKey();

            testSubject.IsMatch(navigationProperty).Should().BeFalse();
            testSubject.ForeignKeys.Should().HaveCount(0);
        }