public void TestExportNullStore() { string languageIdString = "{CC60594B-6360-4770-8CF4-326A4381ADEE}"; Guid languageId = new Guid(languageIdString); PolicyLanguage testLanguage = new PolicyLanguage(languageId, "en"); testLanguage.Export(null); }
public void TestExportNoItems() { string languageIdString = "{CC60594B-6360-4770-8CF4-326A4381ADEE}"; Guid languageId = new Guid(languageIdString); XmlPolicyLanguageStore xmlPolicyLanguageStore = XmlPolicyLanguageStore.Instance(); xmlPolicyLanguageStore.Reset(); Assert.AreEqual("", xmlPolicyLanguageStore.GetXMLRepresentation(languageId)); PolicyLanguage testLanguage = new PolicyLanguage(languageId, "en"); testLanguage.Export(xmlPolicyLanguageStore); Assert.IsTrue(xmlPolicyLanguageStore.GetXMLRepresentation(languageId).Contains(languageIdString)); }
public void TestAddAndGetLanguage() { PolicyLanguageCache policyLanguageCache = PolicyLanguageCache.Instance; Guid languageId = new Guid("{7BFC41D3-01AA-4E98-A25B-C198F58BE78E}"); string languageName = "en"; IPolicyLanguage language = new PolicyLanguage(languageId, languageName); policyLanguageCache.AddLanguage(language); Guid itemId = new Guid("{C1DA3D8A-9281-4970-91D6-82842BEB57C1}"); string itemText = "This is a test"; language[itemId] = itemText; IPolicyLanguage cachedLanguage = policyLanguageCache.GetLanguage(languageId, languageName); Assert.AreSame(language, cachedLanguage); Assert.IsNotNull(cachedLanguage); Assert.IsTrue(cachedLanguage.ContainsItem(itemId)); Assert.AreEqual(itemText, cachedLanguage[itemId]); }
public void TestExportWithItems() { string languageIdString = "{CC60594B-6360-4770-8CF4-326A4381ADEE}"; Guid languageId = new Guid(languageIdString); XmlPolicyLanguageStore xmlPolicyLanguageStore = XmlPolicyLanguageStore.Instance(); xmlPolicyLanguageStore.Reset(); Assert.AreEqual("", xmlPolicyLanguageStore.GetXMLRepresentation(languageId)); PolicyLanguage testLanguage = new PolicyLanguage(languageId, "en"); string itemIdString = "{46EA5650-435E-45FB-ADFA-FDE1EC3BB922}"; string testString = "This is test"; testLanguage[new Guid(itemIdString)] = testString; testLanguage.Export(xmlPolicyLanguageStore); string languageXml = xmlPolicyLanguageStore.GetXMLRepresentation(languageId); Assert.IsTrue(languageXml.Contains(languageIdString)); Assert.IsTrue(languageXml.Contains(itemIdString)); Assert.IsTrue(languageXml.Contains(testString)); }
public void TestGetLanguageNoLanguageForName() { PolicyLanguageCache policyLanguageCache = PolicyLanguageCache.Instance; Guid languageId = new Guid("{7BFC41D3-01AA-4E98-A25B-C198F58BE78E}"); IPolicyLanguage language = new PolicyLanguage(languageId, "en"); language.DefaultLanguage = true; policyLanguageCache.AddLanguage(language); IPolicyLanguage language2 = policyLanguageCache.GetLanguage(languageId, "fr"); // If the required language does not exist, the GetLanguage should return the default language Assert.AreSame(language, language2); }
public void TestGetLanguageNoLanguageForNameAndNoDefaultLanguage() { PolicyLanguageCache policyLanguageCache = PolicyLanguageCache.Instance; Guid languageId = new Guid("{7BFC41D3-01AA-4E98-A25B-C198F58BE78E}"); IPolicyLanguage language = new PolicyLanguage(languageId, "en"); policyLanguageCache.AddLanguage(language); policyLanguageCache.GetLanguage(languageId, "fr"); }
public void TestReset() { PolicyLanguageCache policyLanguageCache = PolicyLanguageCache.Instance; Guid languageId = new Guid("{7BFC41D3-01AA-4E98-A25B-C198F58BE78E}"); string languageName = "en"; IPolicyLanguage language = new PolicyLanguage(languageId, languageName); policyLanguageCache.AddLanguage(language); Assert.AreEqual(1, policyLanguageCache.AvailableLanguageNames(languageId).Count); policyLanguageCache.Reset(); Assert.AreEqual(0, policyLanguageCache.AvailableLanguageNames(languageId).Count); }