public void When_the_path_has_a_trailing_slash_GetUrl_returns_the_path_appended_to_the_Context_base_uri_with_a_single_slash() { var baseUriString = Any.Uri(allowQuerystring: false).AbsoluteUri.TrimEnd('/'); var context = new DataServiceContextWrapper(new Uri(baseUriString + "/"), Any.EnumValue <ODataProtocolVersion>(), () => Task.FromResult(Any.String())); var fetcher = new TestRestShallowObjectFetcher(); fetcher.Initialize(context, _path); fetcher.GetUrl().AbsoluteUri .Should().Be(new Uri(baseUriString + "/" + _path).AbsoluteUri); }
public static TestRestShallowObjectFetcher CreateFetcher(DataServiceContextWrapper context, EntityBase entity) { var fetcher = new TestRestShallowObjectFetcher(); Uri fullUri; context.TryGetUri(entity, out fullUri); var baseUri = context.BaseUri.ToString().TrimEnd('/'); var resourcePath = fullUri.ToString().Substring(baseUri.Length + 1); fetcher.Initialize(context, resourcePath); return(fetcher); }
public Given_a_RestShallowObjectFetcher_Initialized() { _path = Any.String(1); _baseUri = Any.Uri(allowQuerystring: false); _context = new DataServiceContextWrapper(_baseUri, Any.EnumValue <ODataProtocolVersion>(), () => Task.FromResult(Any.String())); _fetcher = new TestRestShallowObjectFetcher(); _fetcher.Initialize(_context, _path); }