public void GetResourceFallsbackToLanguage() { // --- Act var resource = LocalizedResourceManager.GetResourceByLocale("de-au", "Cat1", "2"); // --- Assert resource.ShouldEqual("Cat1Value2-de"); }
public void NoLocaleFallsbackToDefaultLanguage() { // --- Act var resource = LocalizedResourceManager.GetResourceByLocale("", "Cat1", "1"); // --- Assert resource.ShouldEqual("Cat1Value1"); }
public void GetResourceWorksAsExpected() { // --- Act var resource = LocalizedResourceManager.GetResourceByLocale("hu-hu", "Cat1", "1"); // --- Assert resource.ShouldEqual("Cat1Value1-hu-hu"); }
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(); }
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(); }