コード例 #1
0
        public void EnIsEncodingsRecordGetStringByIdAndLang()
        {
            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);
            //
            // Here's the stuff really tested here!!!!
            String resultEn = record.GetMultiLanguageStringAttributeById(0, langEn);
            String resultIs = record.GetMultiLanguageStringAttributeById(0, langIs);

            Assert.AreEqual(expectedEn, resultEn);
            Assert.AreEqual(expectedIs, resultIs);
            String resultEnPrimary = record.GetPrimaryMultiLanguageStringAttributeById(0);

            Assert.AreEqual(expectedEn, resultEnPrimary);
        }
コード例 #2
0
        public void BadGetStringByIdAndLang_LangNull()
        {
            byte[]        buffer = RecordBytesEnIsEncodings;
            ServiceRecord record = new ServiceRecordParser().Parse(buffer);

            record.GetMultiLanguageStringAttributeById(0, null);
        }
コード例 #3
0
        public void BadNonStringAttribute()
        {
            byte[]        buffer = Data_CompleteThirdPartyRecords.Xp1Sdp;
            ServiceRecord record = new ServiceRecordParser().Parse(buffer);

            LanguageBaseItem[] langList = record.GetLanguageBaseList();
            //
            LanguageBaseItem langEn = langList[0];

            Assert.AreEqual("en", langEn.NaturalLanguage);
            //
            // There's a attribute 0x0201 of type UInt32, accessing it should fail
            String resultEn = record.GetMultiLanguageStringAttributeById((ServiceAttributeId)0x101, langEn);

            Assert.Fail("should have thrown!");
        }