public void VersionCountsTest()
        {
            //Arrange
            var config = new Config();
            IItemVersionHandler versionHandler       = new ItemVersionHandler(config);
            IItemVersionHandler cachedVersionHandler = new TestCachedItemVersionHandler(new ConcurrentDictionaryCacheManager(), config);
            var  warmupItem = _db.GetItem(new ID(_id));
            bool result1    = false;
            bool result2    = false;


            //Act
            _glassWatch.Start();
            var sitecoreItem = _db.GetItem(new ID(_id));

            for (var i = 0; i < 10000; i++)
            {
                result1 = versionHandler.VersionCountEnabledAndHasVersions(sitecoreItem);
            }
            _glassWatch.Stop();
            Console.WriteLine(_glassWatch.ElapsedMilliseconds);

            _glassWatch.Reset();
            _glassWatch.Start();
            for (var i = 0; i < 10000; i++)
            {
                result2 = cachedVersionHandler.VersionCountEnabledAndHasVersions(sitecoreItem);
            }
            _glassWatch.Stop();
            Console.WriteLine(_glassWatch.ElapsedMilliseconds);

            //Assert
            Assert.IsTrue(result1);
            Assert.IsTrue(result2);
        }
Example #2
0
        public void VersionCountsTest_IncorrectLanguage()
        {
            //Arrange
            var config = new Config();
            IItemVersionHandler versionHandler       = new ItemVersionHandler(config);
            IItemVersionHandler cachedVersionHandler = new TestCachedItemVersionHandler(new NetMemoryCacheManager(), config);
            var  warmupItem = _database.GetItem(new ID(_id));
            bool result1    = false;
            bool result2    = false;


            //Act
            _glassWatch.Start();
            for (var i = 0; i < 10000; i++)
            {
                var sitecoreItem = _database.GetItem(new ID(_id), Language.Parse("de-DE"));
                result1 = versionHandler.VersionCountEnabledAndHasVersions(sitecoreItem);
            }
            _glassWatch.Stop();
            Console.WriteLine(_glassWatch.ElapsedMilliseconds);

            _glassWatch.Reset();
            _glassWatch.Start();
            for (var i = 0; i < 10000; i++)
            {
                var sitecoreItem = _database.GetItem(new ID(_id), Language.Parse("de-DE"));
                result2 = cachedVersionHandler.VersionCountEnabledAndHasVersions(sitecoreItem);
            }
            _glassWatch.Stop();
            Console.WriteLine(_glassWatch.ElapsedMilliseconds);

            //Assert
            Assert.IsFalse(result1);
            Assert.IsFalse(result2);
        }
        public void DoVersionCheck_DefaultValues_ReturnTrue()
        {
            //Arrange
            var config = new Config();
            IItemVersionHandler versionHandler = new ItemVersionHandler(config);

            //Act
            var result = versionHandler.VersionCountEnabled();

            //Assert
            Assert.IsTrue(result);
        }
        public void DoVersionCheck_DisableVersionCount_ReturnFalse()
        {
            //Arrange
            var config = new Config();

            config.DisableVersionCount = true;
            IItemVersionHandler versionHandler = new ItemVersionHandler(config);

            //Act
            var result = versionHandler.VersionCountEnabled();

            //Assert
            Assert.IsFalse(result);
        }
 public DependencyResolver(Config config)
 {
     Config                       = config;
     Log                          = new Log();
     CacheManager                 = () => new NetMemoryCacheManager();
     QueryParameterFactory        = new QueryParameterConfigFactory();
     DataMapperResolverFactory    = new DataMapperTaskConfigFactory();
     DataMapperFactory            = new DataMapperConfigFactory(QueryParameterFactory);
     ConfigurationResolverFactory = new ConfigurationResolverConfigFactory();
     ObjectConstructionFactory    = new ObjectConstructionTaskConfigFactory(this);
     ObjectSavingFactory          = new ObjectSavingTaskConfigFactory();
     ConfigurationMapFactory      = new ConfigurationMapConfigFactory();
     GlassHtmlFactory             = new GlassHtmlFactory();
     ItemVersionHandler           = new ItemVersionHandler(config);
 }
 public DependencyResolver(Config config)
 {
     Config = config;
     Log = new Log();
     CacheManager = () => new NetMemoryCacheManager();
     QueryParameterFactory = new QueryParameterConfigFactory();
     DataMapperResolverFactory = new DataMapperTaskConfigFactory();
     DataMapperFactory = new DataMapperConfigFactory(QueryParameterFactory);
     ConfigurationResolverFactory = new ConfigurationResolverConfigFactory();
     ObjectConstructionFactory = new ObjectConstructionTaskConfigFactory(this);
     ObjectSavingFactory = new ObjectSavingTaskConfigFactory();
     ConfigurationMapFactory = new ConfigurationMapConfigFactory();
     GlassHtmlFactory = new GlassHtmlFactory();
     ItemVersionHandler = new ItemVersionHandler(config);
 }
        public void VersionCountsTest_IncorrectLanguage()
        {
            //Arrange
            var config = new Config();
            IItemVersionHandler versionHandler = new ItemVersionHandler(config);
            IItemVersionHandler cachedVersionHandler = new TestCachedItemVersionHandler(new NetMemoryCacheManager(), config);
            var warmupItem = _database.GetItem(new ID(_id));
            bool result1 = false;
            bool result2 = false;


            //Act
            _glassWatch.Start();
            for (var i = 0; i < 10000; i++)
            {
                var sitecoreItem = _database.GetItem(new ID(_id), Language.Parse("de-DE"));
                result1 = versionHandler.VersionCountEnabledAndHasVersions(sitecoreItem);
            }
            _glassWatch.Stop();
            Console.WriteLine(_glassWatch.ElapsedMilliseconds);

            _glassWatch.Reset();
            _glassWatch.Start();
            for (var i = 0; i < 10000; i++)
            {
                var sitecoreItem = _database.GetItem(new ID(_id), Language.Parse("de-DE"));
                result2 = cachedVersionHandler.VersionCountEnabledAndHasVersions(sitecoreItem);
            }
            _glassWatch.Stop();
            Console.WriteLine(_glassWatch.ElapsedMilliseconds);

            //Assert
            Assert.IsFalse(result1);
            Assert.IsFalse(result2);
        }
        public void DoVersionCheck_VersionCountDisabler_ReturnFalse()
        {
            //Arrange
            var config = new Config();
            config.DisableVersionCount = true;
            IItemVersionHandler versionHandler = new ItemVersionHandler(config);

            var result = true;

            //Act
            using (new VersionCountDisabler())
            {
                result = versionHandler.VersionCountEnabled();
            }

            //Assert
            Assert.IsFalse(result);
        }
        public void DoVersionCheck_DefaultValues_ReturnTrue()
        {
            //Arrange
            var config = new Config();
            IItemVersionHandler versionHandler = new ItemVersionHandler(config);

            //Act
            var result = versionHandler.VersionCountEnabled();

            //Assert
            Assert.IsTrue(result);
        }
        public void VersionCountsTest()
        {
            //Arrange
            var config = new Config();
            IItemVersionHandler versionHandler = new ItemVersionHandler(config);
            IItemVersionHandler cachedVersionHandler = new TestCachedItemVersionHandler(new ConcurrentDictionaryCacheManager(), config);
            var warmupItem = _db.GetItem(new ID(_id));
            bool result1 = false;
            bool result2 = false;


            //Act
            _glassWatch.Start();
            var sitecoreItem = _db.GetItem(new ID(_id));

            for (var i = 0; i < 10000; i++)
            {
                result1 = versionHandler.VersionCountEnabledAndHasVersions(sitecoreItem);
            }
            _glassWatch.Stop();
            Console.WriteLine(_glassWatch.ElapsedMilliseconds);

            _glassWatch.Reset();
            _glassWatch.Start();
            for (var i = 0; i < 10000; i++)
            {
                result2 = cachedVersionHandler.VersionCountEnabledAndHasVersions(sitecoreItem);
            }
            _glassWatch.Stop();
            Console.WriteLine(_glassWatch.ElapsedMilliseconds);

            //Assert
            Assert.IsTrue(result1);
            Assert.IsTrue(result2);
        }