public void Get_Default_CreateNew_Test()
        {
            var option = new FastDFSOption()
            {
                ClusterConfigurations = new List <ClusterConfiguration>()
                {
                    new ClusterConfiguration()
                    {
                        Name     = "cluster1",
                        Trackers = new List <Tracker>()
                        {
                            new Tracker("127.0.0.1", 22122)
                        }
                    }
                }
            };

            var options = Options.Create <FastDFSOption>(option);

            var mockCluster = new Mock <ICluster>();

            mockCluster.Setup(x => x.Name).Returns("cluster1");

            var mockScopeServiceProvider = new Mock <IServiceProvider>();

            mockScopeServiceProvider.Setup(x => x.GetService(typeof(ICluster)))
            .Returns(mockCluster.Object);

            mockScopeServiceProvider.Setup(x => x.GetService(typeof(ClusterConfiguration)))
            .Returns(option.ClusterConfigurations.FirstOrDefault());

            var mockServiceScope = new Mock <IServiceScope>();

            mockServiceScope.Setup(x => x.ServiceProvider)
            .Returns(mockScopeServiceProvider.Object);

            var mockScopeFactory = new Mock <IServiceScopeFactory>();

            mockScopeFactory.Setup(x => x.CreateScope())
            .Returns(mockServiceScope.Object);

            var mockServiceProvider = new Mock <IServiceProvider>();

            mockServiceProvider.Setup(x => x.GetService(typeof(IServiceScopeFactory)))
            .Returns(mockScopeFactory.Object);

            var mockClusterSelector = new Mock <IClusterSelector>();

            mockClusterSelector.Setup(x => x.Get("cluster1")).Returns(option.ClusterConfigurations.FirstOrDefault());


            IClusterFactory clusterFactory = new DefaultClusterFactory(_mockLogger.Object, mockServiceProvider.Object, options, mockClusterSelector.Object);

            var cluster = clusterFactory.Get("");

            mockClusterSelector.Verify(x => x.Get("cluster1"), Times.Once);
            mockScopeServiceProvider.Verify(x => x.GetService(typeof(ICluster)), Times.Once);
            mockScopeServiceProvider.Verify(x => x.GetService(typeof(ClusterConfiguration)), Times.Once);

            var cluster2 = clusterFactory.Get("");

            Assert.Equal("cluster1", cluster2.Name);
        }
 protected virtual ICluster BuildDefaultCluster(CassandraClusterElement clusterConfig, ILogger logger)
 {
     DefaultClusterFactory clusterFactory = new DefaultClusterFactory();
     clusterFactory.Logger = logger;
     clusterFactory.FriendlyName = clusterConfig.FriendlyName;
     clusterFactory.PoolManager = this.buildPoolManager(clusterConfig, logger, clusterFactory.FriendlyName);
     return clusterFactory.Create();
 }