Example #1
0
        public void GetResourceFallsbackToLanguage()
        {
            // --- Act
            var resource = LocalizedResourceManager.GetResourceByLocale("de-au", "Cat1", "2");

            // --- Assert
            resource.ShouldEqual("Cat1Value2-de");
        }
Example #2
0
        public void NoLocaleFallsbackToDefaultLanguage()
        {
            // --- Act
            var resource = LocalizedResourceManager.GetResourceByLocale("", "Cat1", "1");

            // --- Assert
            resource.ShouldEqual("Cat1Value1");
        }
Example #3
0
        public void GetResourceWorksAsExpected()
        {
            // --- Act
            var resource = LocalizedResourceManager.GetResourceByLocale("hu-hu", "Cat1", "1");

            // --- Assert
            resource.ShouldEqual("Cat1Value1-hu-hu");
        }
Example #4
0
        public void CacheIsUsedAsExpected()
        {
            // --- Act
            var cacheHit1 = LocalizedResourceManager.IsCached("hu-hu", "Cat1");
            var resource  = LocalizedResourceManager.GetResourceByLocale("hu-hu", "Cat1", "1");
            var cacheHit2 = LocalizedResourceManager.IsCached("hu-hu", "Cat1");

            // --- Assert
            resource.ShouldEqual("Cat1Value1-hu-hu");
            cacheHit1.ShouldBeFalse();
            cacheHit2.ShouldBeTrue();
        }
Example #5
0
        public void ExpiredCacheItemIsRemoved()
        {
            // --- Arrange
            LocalizedResourceManager.Reset(TimeSpan.FromMilliseconds(100));

            // --- Act
            var cacheHit1 = LocalizedResourceManager.IsCached("hu-hu", "Cat1");

            LocalizedResourceManager.GetResourceByLocale("hu-hu", "Cat1", "1");
            var cacheHit2 = LocalizedResourceManager.IsCached("hu-hu", "Cat1");

            Thread.Sleep(200);
            var cacheHit3 = LocalizedResourceManager.IsCached("hu-hu", "Cat1");
            var resource  = LocalizedResourceManager.GetResourceByLocale("hu-hu", "Cat1", "1");

            // --- Assert
            resource.ShouldEqual("Cat1Value1-hu-hu");
            cacheHit1.ShouldBeFalse();
            cacheHit2.ShouldBeTrue();
            cacheHit3.ShouldBeFalse();
        }