コード例 #1
0
        public void SqlServerCacheFactory()
        {
            var factory = new SqlServerFactory(new Dictionary <string, string>
            {
                { "connection-string", "connection" },
                { "schema-name", "schema" },
                { "table-name", "table" },
                { "expired-items-deletion-interval", "5" }
            });
            var cache1 = factory.BuildCache();

            Assert.That(cache1, Is.Not.Null, "Factory has yielded null");
            Assert.That(cache1, Is.InstanceOf <SqlServerCache>(), "Unexpected cache");
            var cache2 = factory.BuildCache();

            Assert.That(cache2, Is.Not.EqualTo(cache1),
                        "The SQL Server cache factory is supposed to always yield a new instance");

            var options = SqlServerCacheOptionsField.GetValue(factory);

            Assert.That(options, Is.Not.Null, "Factory cache options not found");
            Assert.That(options, Is.InstanceOf <SqlServerCacheOptions>(), "Unexpected options type");
            var sqlServerOptions = (SqlServerCacheOptions)options;

            Assert.That(sqlServerOptions.ConnectionString, Is.EqualTo("connection"));
            Assert.That(sqlServerOptions.SchemaName, Is.EqualTo("schema"));
            Assert.That(sqlServerOptions.TableName, Is.EqualTo("table"));
            Assert.That(sqlServerOptions.ExpiredItemsDeletionInterval, Is.EqualTo(TimeSpan.FromMinutes(5)));
        }