public void TestLogFileCreated()
        {
            var config = new LoggerConfiguration().ReadFrom.AppSettings();

            Log.Logger = config.CreateLogger();


            var provider = new RedisSessionStateStoreProvider();

            provider.Initialize("APP_NAME", new NameValueCollection()
            {
                { "Host", "9.9.9.9:999" },
                { "clientType", "pooled" }
            });
            Assert.IsInstanceOf <PooledRedisClientManager>(provider.ClientManager);

            var today = DateTime.Now;
            var path  = "D:\\Log\\HarbourSession\\test\\HarbourSessionProvider-" + today.ToString("yyyyMMdd") + ".txt";

            //TODO: Once we can upgrade to Serilog 2.0+, just remove the exception assertion but keep the guts
            Assert.Throws <IOException>(() =>
            {
                using (var fs = new StreamReader(path))
                {
                    Assert.IsNotEmpty(fs.ReadToEnd());
                }
            });
        }
 public void Initialize_with_no_configured_clients_manager_can_create_basic_clients_manager()
 {
     var provider = new RedisSessionStateStoreProvider();
     provider.Initialize("APP_NAME", new NameValueCollection()
     {
         { "Host", "9.9.9.9:999" },
         { "clientType", "basic" }
     });
     Assert.IsType<BasicRedisClientManager>(provider.ClientManager);
 }
        public void Initialize_with_no_configured_clients_manager_can_create_pooled_clients_manager()
        {
            var provider = new RedisSessionStateStoreProvider();

            provider.Initialize("APP_NAME", new NameValueCollection()
            {
                { "Host", "9.9.9.9:999" },
                { "clientType", "pooled" }
            });
            Assert.IsInstanceOf <PooledRedisClientManager>(provider.ClientManager);
        }
        private RedisSessionStateStoreProvider CreateProvider(string host = null)
        {
            var provider = new RedisSessionStateStoreProvider(ctx => new HttpStaticObjectsCollection());

            provider.Initialize(KeyName, new NameValueCollection()
            {
                { "Host", host ?? this.Host },
                { "clientType", "basic" }
            });

            return(provider);
        }
        public void Initialize_with_specified_clients_manager_should_not_manage_lifetime()
        {
            try
            {
                var clientManager = new Mock <IRedisClientsManager>();
                RedisSessionStateStoreProvider.SetClientManager(clientManager.Object);
                var provider = new RedisSessionStateStoreProvider();
                provider.Initialize(KeyName, new NameValueCollection());

                Assert.AreSame(clientManager.Object, provider.ClientManager);

                provider.Dispose();

                clientManager.Verify(m => m.Dispose(), Times.Never());
            }
            finally
            {
                RedisSessionStateStoreProvider.ResetClientManager();
            }
        }
        public void Initialize_with_specified_clients_manager_should_not_manage_lifetime()
        {
            try
            {
                var clientManager = new Mock<IRedisClientsManager>();
                RedisSessionStateStoreProvider.SetClientManager(clientManager.Object);
                var provider = new RedisSessionStateStoreProvider();
                provider.Initialize(KeyName, new NameValueCollection());

                Assert.Same(clientManager.Object, provider.ClientManager);

                provider.Dispose();

                clientManager.Verify(m => m.Dispose(), Times.Never());
            }
            finally
            {
                RedisSessionStateStoreProvider.ResetClientManager();
            }
        }
        private RedisSessionStateStoreProvider CreateProvider(string host = null)
        {
            var provider = new RedisSessionStateStoreProvider(ctx => new HttpStaticObjectsCollection());

            provider.Initialize(KeyName, new NameValueCollection()
            {
                { "Host", host ?? this.Host },
                { "clientType", "basic" }
            });

            return provider;
        }