public void Clear_PropertyStorage_AlreadyEmpty() { // Arrange var dict = new DispatcherValueCollection(new { }); // Act dict.Clear(); // Assert Assert.Empty(dict); Assert.IsType <DispatcherValueCollection.PropertyStorage>(dict._storage); }
public void Clear_PropertyStorage() { // Arrange var dict = new DispatcherValueCollection(new { key = "value" }); // Act dict.Clear(); // Assert Assert.Empty(dict); Assert.IsType <DispatcherValueCollection.ListStorage>(dict._storage); }
public void Clear_EmptyStorage() { // Arrange var dict = new DispatcherValueCollection(); // Act dict.Clear(); // Assert Assert.Empty(dict); Assert.IsType <DispatcherValueCollection.EmptyStorage>(dict._storage); }
public override async Task MatchAsync(MatcherContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } EnsureTreeMatcherServicesInitialized(context); var cache = LazyInitializer.EnsureInitialized(ref _cache, ref _dataInitialized, ref _lock, _initializer); var values = new DispatcherValueCollection(); context.Values = values; for (var i = 0; i < cache.Trees.Length; i++) { var tree = cache.Trees[i]; var tokenizer = new PathTokenizer(context.HttpContext.Request.Path); var treenumerator = new TreeEnumerator(tree.Root, tokenizer); while (treenumerator.MoveNext()) { var node = treenumerator.Current; foreach (var item in node.Matches) { var entry = item.Entry; var matcher = item.RoutePatternMatcher; values.Clear(); if (!matcher.TryMatch(context.HttpContext.Request.Path, values)) { continue; } Logger.MatchedRoute(entry.RoutePattern.RawText); if (!MatchConstraints(context.HttpContext, values, entry.Constraints)) { continue; } await SelectEndpointAsync(context, (entry.Endpoints)); if (context.ShortCircuit != null) { Logger.RequestShortCircuited(context); return; } if (context.Endpoint != null) { if (context.Endpoint is IRoutePatternEndpoint templateEndpoint) { foreach (var kvp in templateEndpoint.Values) { if (!context.Values.ContainsKey(kvp.Key)) { context.Values[kvp.Key] = kvp.Value; } } } return; } } } } }