AddOrReplaceRoutes() 공개 메소드

Adds or replaces a set of routes for a given group key. The route set is identified . If the method is called the first time with a given , the routes are added. If the method is called with the same multiple times, the routes registered previously under this key are replaced.
public AddOrReplaceRoutes ( string sourceKey, IList entries ) : void
sourceKey string Key for the route source.
entries IList Group entries.
리턴 void
        public void When_group_exists_should_replace_existing_routes()
        {
            var routingTable = new UnicastRoutingTable();
            var oldRoute = UnicastRoute.CreateFromEndpointName("Endpoint1");
            var newRoute = UnicastRoute.CreateFromEndpointName("Endpoint2");
            routingTable.AddOrReplaceRoutes("key", new List<RouteTableEntry>()
            {
                new RouteTableEntry(typeof(Command), oldRoute),
            });

            routingTable.AddOrReplaceRoutes("key", new List<RouteTableEntry>()
            {
                new RouteTableEntry(typeof(Command), newRoute),
            });

            var retrievedRoute = routingTable.GetRouteFor(typeof(Command));
            Assert.AreSame(newRoute, retrievedRoute);
        }
        public void When_routes_are_ambiguous_should_throw_exception()
        {
            var routingTable = new UnicastRoutingTable();
            var lowPriorityRoute = UnicastRoute.CreateFromEndpointName("Endpoint1");
            var highPriorityRoute = UnicastRoute.CreateFromEndpointName("Endpoint2");

            routingTable.AddOrReplaceRoutes("key2", new List<RouteTableEntry>()
            {
                new RouteTableEntry(typeof(Command), highPriorityRoute),
            });

            Assert.That(() =>
            {
                routingTable.AddOrReplaceRoutes("key1", new List<RouteTableEntry>()
                {
                    new RouteTableEntry(typeof(Command), lowPriorityRoute),
                });
            }, Throws.Exception);
        }