private IResourcePathContextBuilder <TParentBuilder> AddPath(IResourceType resourceType, Type clrResourceType, string apiId, string rel) { Contract.Requires(resourceType != null); Contract.Requires(clrResourceType != null); Contract.Requires(String.IsNullOrWhiteSpace(apiId) == false); Contract.Requires(String.IsNullOrWhiteSpace(rel) == false); this.EnsureBasePathsExist(); var nextRelationship = resourceType.GetRelationshipInfo(rel); var nextRelationshipCanonicalRelPathMode = nextRelationship.ToCanonicalRelPathMode; if (nextRelationshipCanonicalRelPathMode == RelationshipCanonicalRelPathMode.DropPreviousPathSegments) { _resourceCanonicalBasePath.Clear(); _resourceCanonicalPathMode = default(ResourcePathMode); _resourceCanonicalPreviousRelationship = null; } else { AddPath(resourceType, clrResourceType, apiId, nextRelationship, ref _resourceCanonicalBasePath, ref _resourceCanonicalPathMode, ref _resourceCanonicalPreviousRelationship); } AddPath(resourceType, clrResourceType, apiId, nextRelationship, ref _resourceSelfBasePath, ref _resourceSelfPathMode, ref _resourceSelfPreviousRelationship); return(this); }
public void TestResourceTypeGetRelationshipInfo(string name, bool relationshipExists, IResourceType resourceType, string rel, IRelationshipInfo expected) { this.Output.WriteLine("Test Name: {0}", name); this.Output.WriteLine(String.Empty); // Arrange // Act if (!relationshipExists) { Assert.Throws <ServiceModelException>(() => resourceType.GetRelationshipInfo(rel)); return; } var actual = resourceType.GetRelationshipInfo(rel); // Assert RelationshipInfoAssert.Equal(expected, actual); }