/// <summary> /// Initializes a new instance of the <see cref="KeyValuePathSegmentTemplate"/> class. /// </summary> /// <param name="keyValueSegment">The key value segment to be parsed as a template.</param> public KeyValuePathSegmentTemplate(KeyValuePathSegment keyValueSegment) { if (keyValueSegment == null) { throw Error.ArgumentNull("keyValueSegment"); } ParameterMappings = BuildParameterMappings(keyValueSegment.Values, keyValueSegment.Value); }
public void TryMatch_SingleKey_ReturnsTrueOnMatch() { KeyValuePathSegmentTemplate template = new KeyValuePathSegmentTemplate(new KeyValuePathSegment("{ID}")); KeyValuePathSegment segment = new KeyValuePathSegment("123"); // Act Dictionary<string, object> values = new Dictionary<string, object>(); bool result = template.TryMatch(segment, values); // Assert Assert.True(result); Assert.Equal("123", values["ID"]); }
public void TryMatch_MultiKey_ReturnsTrueOnMatch() { KeyValuePathSegmentTemplate template = new KeyValuePathSegmentTemplate(new KeyValuePathSegment("FirstName={key1},LastName={key2}")); KeyValuePathSegment segment = new KeyValuePathSegment("FirstName=abc,LastName=xyz"); // Act Dictionary<string, object> values = new Dictionary<string, object>(); bool result = template.TryMatch(segment, values); // Assert Assert.True(result); Assert.Equal("abc", values["key1"]); Assert.Equal("xyz", values["key2"]); }