public void Failed_match_should_not_throw_on_dictionary_members() { // given var failure = UriTemplateMatches.Failure(); // then failure.Values.Should().BeEmpty(); failure.Keys.Should().BeEmpty(); failure.ContainsKey("whatever").Should().BeFalse(); object val; failure.TryGetValue("something", out val).Should().BeFalse(); failure.Count.Should().Be(0); failure.GetEnumerator().MoveNext().Should().BeFalse(); }
/// <inheritdoc/> public UriTemplateMatches Match <T>(Uri uri) { var template = uri.IsAbsoluteUri ? this.templates.GetAbsoluteTemplate(typeof(T)) : this.templates.GetTemplate(typeof(T)); var tunnelVisionMatches = new UriTemplate(template).Match(uri); if (tunnelVisionMatches != null) { var matchDict = tunnelVisionMatches.Bindings.Values.ToDictionary(m => m.Key.Name, m => m.Value); return(new UriTemplateMatches(matchDict)); } return(UriTemplateMatches.Failure()); }