Example #1
0
        public void TestInitialization()
        {
            var stateProvider = new IgniteSessionStateStoreProvider();

            SessionStateActions actions;
            bool     locked;
            TimeSpan lockAge;
            object   lockId;

            // Not initialized.
            Assert.Throws <InvalidOperationException>(() =>
                                                      stateProvider.GetItem(HttpContext, Id, out locked, out lockAge, out lockId, out actions));

            // Invalid section.
            Assert.Throws <IgniteException>(() =>
                                            stateProvider.Initialize("testName", new NameValueCollection
            {
                { SectionNameAttr, "invalidSection" },
                { CacheNameAttr, CacheName }
            }));

            // Valid grid.
            stateProvider = GetProvider();

            CheckProvider(stateProvider);

            // Same grid once again.
            stateProvider = GetProvider();

            CheckProvider(stateProvider);
        }
Example #2
0
        public void TestInitialization()
        {
            var stateProvider = new IgniteSessionStateStoreProvider();

            SessionStateActions actions;
            bool     locked;
            TimeSpan lockAge;
            object   lockId;

            // Not initialized.
            Assert.Throws <InvalidOperationException>(() =>
                                                      stateProvider.GetItem(HttpContext, Id, out locked, out lockAge, out lockId, out actions));

            // Missing section.
            var ex = Assert.Throws <IgniteException>(() =>
                                                     stateProvider.Initialize("testName", new NameValueCollection
            {
                { SectionNameAttr, "missingSection" },
                { CacheNameAttr, CacheName }
            }));

            Assert.IsInstanceOf <ConfigurationErrorsException>(ex.InnerException);

            // Invalid section with missing content.
            stateProvider = new IgniteSessionStateStoreProvider();

            ex = Assert.Throws <IgniteException>(() =>
                                                 stateProvider.Initialize("testName", new NameValueCollection
            {
                { SectionNameAttr, "igniteConfigurationInvalid" },
                { CacheNameAttr, CacheName }
            }));

            Assert.IsInstanceOf <ConfigurationErrorsException>(ex.InnerException);

            // Valid grid.
            stateProvider = GetProvider();

            CheckProvider(stateProvider);

            // Same grid once again.
            stateProvider = GetProvider();

            CheckProvider(stateProvider);

            // Omitted cache name results in default cache name (not null).
            stateProvider = new IgniteSessionStateStoreProvider();

            stateProvider.Initialize("testName", new NameValueCollection
            {
                { GridNameAttr, GridName }
            });

            var cacheNames = Ignition.GetIgnite(GridName).GetCacheNames();

            Assert.IsFalse(cacheNames.Contains(null));
            Assert.IsTrue(cacheNames.Contains(IgniteSessionStateStoreProvider.DefaultCacheName));
        }
Example #3
0
        /// <summary>
        /// Gets the initialized provider.
        /// </summary>
        private static IgniteSessionStateStoreProvider GetProvider()
        {
            var stateProvider = new IgniteSessionStateStoreProvider();

            stateProvider.Initialize("testName", new NameValueCollection
            {
                { GridNameAttr, GridName },
                { CacheNameAttr, CacheName }
            });

            return(stateProvider);
        }
Example #4
0
        public void TestStartFromWebConfigSection()
        {
            var provider = new IgniteSessionStateStoreProvider();

            provider.Initialize("testName3", new NameValueCollection
            {
                { SectionNameAttr, "igniteConfiguration3" },
                { CacheNameAttr, "cacheName3" }
            });

            CheckProvider(provider);
        }
        /// <summary>
        /// Gets the initialized provider.
        /// </summary>
        private static IgniteSessionStateStoreProvider GetProvider()
        {
            var stateProvider = new IgniteSessionStateStoreProvider();

            stateProvider.Initialize("testName", new NameValueCollection
            {
                {GridNameAttr, GridName},
                {CacheNameAttr, CacheName}
            });

            return stateProvider;
        }
        public void TestStartFromWebConfigSection()
        {
            var provider = new IgniteSessionStateStoreProvider();

            provider.Initialize("testName3", new NameValueCollection
            {
                {SectionNameAttr, "igniteConfiguration3"},
                {CacheNameAttr, "cacheName3"}
            });

            CheckProvider(provider);
        }
        public void TestInitialization()
        {
            var stateProvider = new IgniteSessionStateStoreProvider();

            SessionStateActions actions;
            bool locked;
            TimeSpan lockAge;
            object lockId;

            // Not initialized.
            Assert.Throws<InvalidOperationException>(() =>
                    stateProvider.GetItem(HttpContext, Id, out locked, out lockAge, out lockId, out actions));

            // Invalid section.
            Assert.Throws<IgniteException>(() =>
                stateProvider.Initialize("testName", new NameValueCollection
                {
                    {SectionNameAttr, "invalidSection"},
                    {CacheNameAttr, CacheName}
                }));

            // Valid grid.
            stateProvider = GetProvider();

            CheckProvider(stateProvider);

            // Same grid once again.
            stateProvider = GetProvider();

            CheckProvider(stateProvider);

            // Omitted cache name results in default cache name (not null).
            stateProvider = new IgniteSessionStateStoreProvider();

            stateProvider.Initialize("testName", new NameValueCollection
            {
                {GridNameAttr, GridName}
            });

            var cacheNames = Ignition.GetIgnite(GridName).GetCacheNames();

            Assert.IsFalse(cacheNames.Contains(null));
            Assert.IsTrue(cacheNames.Contains(IgniteSessionStateStoreProvider.DefaultCacheName));
        }