public WithFragment ( string fragment, ExistingFragment handledAs = ExistingFragment.Throw ) : |
||
fragment | string | The fragment. |
handledAs | ExistingFragment | Instructs on how to behave when an URL has already a fragment. |
Résultat |
public void should_give_same_instance_if_no_fragments_are_given() { var expected = new HttpUrl(true, "http://temp.uri/", "http", "temp.uri", 80, "/", null, null); expected.WithFragment(null).Should().BeSameAs(expected); }
private static IApiDocumentation GetApiDocumentation(HttpUrl url) { string contentType; var responseStream = new UnclosableStream(GetResponse(Method, url, out contentType)); var container = UrsaConfigurationSection.InitializeComponentProvider(); container.Register<IHttpServerConfiguration>(new StaticHttpServerConfiguration((Uri)url)); var headers = new HeaderCollection(); if (!String.IsNullOrEmpty(contentType)) { ((IDictionary<string, string>)headers)[Header.Accept] = contentType; ((IDictionary<string, string>)headers)[Header.ContentType] = contentType; } var apiDocumentationId = url.WithFragment(String.Empty); var httpRequest = new RequestInfo(Verb.Parse(Method), apiDocumentationId, responseStream, new BasicClaimBasedIdentity(), headers); var converterProvider = container.Resolve<IConverterProvider>(); var converter = converterProvider.FindBestInputConverter<IApiDocumentation>(httpRequest); if (converter == null) { throw new NotSupportedException(String.Format("Content type of '{0}' is not supported.", contentType)); } converter.ConvertTo<IApiDocumentation>(httpRequest); return _container.Resolve<IEntityContext>().Load<IApiDocumentation>((Uri)apiDocumentationId); }