예제 #1
0
        public void ResourceWithRelationshipsToResourceObject_DeviatingForeignKeyAndNoNavigationWhileRelationshipIncluded_IgnoresForeignKeyDuringBuild()
        {
            // Arrange
            var resource = new OneToOneDependent {
                Principal = null, PrincipalId = 123
            };
            var relationships = _resourceGraph.GetRelationships <OneToOneDependent>(tr => tr.Principal);

            // Act
            var resourceObject = _builder.Build(resource, relationships: relationships);

            // Assert
            Assert.Null(resourceObject.Relationships["principal"].Data);
        }
예제 #2
0
        public void ResourceWithRelationshipsToResourceObject_DeviatingForeignKeyWhileRelationshipIncluded_IgnoresForeignKeyDuringBuild()
        {
            // Arrange
            var resource = new OneToOneDependent {
                Principal = new OneToOnePrincipal {
                    Id = 10
                }, PrincipalId = 123
            };
            var relationships = _resourceGraph.GetRelationships <OneToOneDependent>(tr => tr.Principal);

            // Act
            var resourceObject = _builder.Build(resource, relationships: relationships);

            // Assert
            Assert.Single(resourceObject.Relationships);
            Assert.NotNull(resourceObject.Relationships["principal"].Data);
            var ro = (ResourceIdentifierObject)resourceObject.Relationships["principal"].Data;

            Assert.Equal("10", ro.Id);
        }