public void CanAddKeyValuePairToAutoDictionary() { AutoDictionary <string, bool> tested = new AutoDictionary <string, bool>(); tested.Add(new KeyValuePair <string, bool>("hello", true)); Assert.AreEqual(true, tested["hello"]); }
public void CanAddToAutoDictionary() { AutoDictionary <string, bool> tested = new AutoDictionary <string, bool>(); tested.Add("hello", true); Assert.AreEqual(true, tested["hello"]); }
public void SetUriPattern(string value) { uriPattern = value; if (Parameters == null && uriPattern != null) { string[] pathParts = Path.Split('?'); // parse UriPattern // UriPattern will be like: // "/rest/{version}/driver/{driverId}" string[] tokens = uriPattern.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); string[] values = pathParts[0].Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); if (tokens.Length != values.Length) { throw new InvalidOperationException("An error has occurred during validation of the URI Pattern"); } Parameters = new AutoDictionary <string, string>(); for (int i = 0; i < tokens.Length; i++) { string token = tokens[i]; if (token.StartsWith("{") && token.EndsWith("}")) { string key = token.Trim('{', '}'); Parameters.Add(key, Uri.UnescapeDataString(values[i])); } } // parse Get params if (pathParts.Length > 1) { string paramsString = pathParts[1]; ParseParameters(paramsString); } } }
public void Add(string key, string value) => inner.Add(key.ToLower(), value);