public async Task SmokeTest() { var store1 = new RouteStore(); RouterConfig config = await store1.GetRouterConfigAsync("hub", CancellationToken.None); Assert.Equal(0, config.Routes.Count); Endpoint endpoint1 = new NullEndpoint("endpoint1"); Endpoint endpoint2 = new NullEndpoint("endpoint2"); IEnumerable <Endpoint> allEndpoints = new List <Endpoint> { endpoint1, endpoint2 }; var route1 = new Route("id1", "true", "hub", TelemetryMessageSource.Instance, new HashSet <Endpoint> { endpoint1 }); var route2 = new Route("id2", "false", "hub", TelemetryMessageSource.Instance, new HashSet <Endpoint> { endpoint2 }); IEnumerable <Route> allRoutes = new List <Route> { route1, route2 }; var store2 = new RouteStore( new Dictionary <string, RouterConfig> { { "hub", new RouterConfig(allEndpoints, allRoutes) } }); RouterConfig config2 = await store2.GetRouterConfigAsync("hub", CancellationToken.None); Assert.True(config2.Routes.SetEquals(new HashSet <Route> { route1, route2 })); RouterConfig config3 = await store2.GetRouterConfigAsync("hub2", CancellationToken.None); Assert.Equal(0, config3.Routes.Count); }
public List <Route> returnRoute() { var routesStore = new RouteStore() { Path = routePath }; var routeList = routesStore.GetCollection(); return(routeList); }
public async Task TestRules() { var store = new RouteStore(new Dictionary <string, RouterConfig> { { "hub1", new RouterConfig(AllEndpoints, new List <Route> { Route1 }) } }); var underlying = new Mock <IRoutingService>(); var client = new FilteringRoutingService(underlying.Object, store, NullNotifierFactory.Instance); await client.RouteAsync("hub1", new[] { Message1, Message2 }); underlying.Verify(s => s.RouteAsync("hub1", new[] { Message1 }), Times.Once); }
async Task ExecuteLoadItemsCommand() { IsBusy = true; try { Routes.Clear(); var items = await RouteStore.GetItemsAsync(true); foreach (var item in items) { Routes.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }