public void EnIsEncodingsById() { String expectedEn = "ab\u2020cd"; String expectedIs = "ab\u00D0c\u00DEe"; byte[] buffer = RecordBytesEnIsEncodings; ServiceRecord record = new ServiceRecordParser().Parse(buffer); LanguageBaseItem[] langList = record.GetLanguageBaseList(); // LanguageBaseItem langIs = langList[0]; Assert.AreEqual("is", langIs.NaturalLanguage); LanguageBaseItem langEn = langList[1]; Assert.AreEqual("en", langEn.NaturalLanguage); // ServiceAttribute attrEn = record.GetAttributeById(0, langEn); ServiceAttribute attrIs = record.GetAttributeById(0, langIs); Assert.AreEqual((ServiceAttributeId)0x0100, attrEn.Id); Assert.AreEqual((ServiceAttributeId)0x0110, attrIs.Id); String resultEn = attrEn.Value.GetValueAsString(langEn); String resultIs = attrIs.Value.GetValueAsString(langIs); Assert.AreEqual(expectedEn, resultEn); Assert.AreEqual(expectedIs, resultIs); }
public void BadStringEncodingNotAscii() { byte[] buffer = RecordBytesEnIsEncodings; ServiceRecord record = new ServiceRecordParser().Parse(buffer); // ServiceAttribute attr = record.GetAttributeById((ServiceAttributeId)0x0100); const ushort langEn = 0x656e; const ushort ietfAscii = 3; LanguageBaseItem langBase = new LanguageBaseItem(langEn, ietfAscii, (ServiceAttributeId)0x0999); String x = attr.Value.GetValueAsString(langBase); }