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

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

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

            // --- Assert
            resource.ShouldEqual("Cat1Value1-hu-hu");
        }
예제 #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();
        }
예제 #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();
        }