Ejemplo n.º 1
0
        public async Task Route_TEST()
        {
            var queryable1    = _virtualDbContext.Set <SysUserMod>().Where(o => o.Id == "339");
            var routeResults1 = _routingRuleEngineFactory.Route(queryable1);

            Assert.Equal(1, routeResults1.Count());
            Assert.Equal(1, routeResults1.FirstOrDefault().ReplaceTables.Count());
            Assert.Equal("0", routeResults1.FirstOrDefault().ReplaceTables.FirstOrDefault().Tail);
            Assert.Equal(nameof(SysUserMod), routeResults1.FirstOrDefault().ReplaceTables.FirstOrDefault().OriginalName);
            var ids           = new[] { "339", "124", "142" };
            var queryable2    = _virtualDbContext.Set <SysUserMod>().Where(o => ids.Contains(o.Id));
            var routeResult2s = _routingRuleEngineFactory.Route(queryable2);

            Assert.Equal(2, routeResult2s.Count());
            Assert.Equal(1, routeResult2s.FirstOrDefault().ReplaceTables.Count());
            Assert.Equal(2, routeResult2s.SelectMany(o => o.ReplaceTables).Count());
            Assert.Equal(true, routeResult2s.SelectMany(o => o.ReplaceTables).All(o => new[] { "0", "1" }.Contains(o.Tail)));
        }
 public StreamMergeContext <T> Create <T>(IQueryable <T> queryable)
 {
     return(new StreamMergeContext <T>(queryable, _routingRuleEngineFactory.Route(queryable), _shardingParallelDbContextFactory, _shardingScopeFactory));
 }