public void EnIsSimple()
        {
            String expectedEn = "abcd";
            String expectedIs = "abce";

            byte[]        buffer = RecordBytesEnIs;
            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.GetAttributeByIndex(1);
            ServiceAttribute attrIs = record.GetAttributeByIndex(2);

            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 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);
        }
Esempio n. 3
0
        public void TwoItemsAsArrayToParse()
        {
            ServiceRecord record = new ServiceRecordParser().Parse(Data_LanguageBaseList.RecordTwoItemsAsBytes);

            LanguageBaseItem[] items = record.GetLanguageBaseList();
            Assert.AreEqual(2, items.Length);
            //
            Assert.AreEqual(Data_LanguageBaseList.LangStringEn, items[0].NaturalLanguage, "NaturalLanguage");
            Assert.AreEqual(Data_LanguageBaseList.EncUtf8, items[0].EncodingId, "EncodingId");
            Assert.AreEqual((ServiceAttributeId)0x0100, items[0].AttributeIdBase, "AttributeIdBase");
            //
            Assert.AreEqual(Data_LanguageBaseList.LangStringFr, items[1].NaturalLanguage, "NaturalLanguage");
            Assert.AreEqual(Data_LanguageBaseList.EncWindows1252, items[1].EncodingId, "EncodingId");
            Assert.AreEqual((ServiceAttributeId)0x0110, items[1].AttributeIdBase, "AttributeIdBase");
        }
        public void EnIsEncodingsRecordGetStringByIdAndLangNoLangBaseItems()
        {
            String expectedEn = "ab\u2020cd";

            byte[]        buffer = RecordBytesEnIsEncodingsNoLangBaseItems;
            ServiceRecord record = new ServiceRecordParser().Parse(buffer);

            //
            LanguageBaseItem[] langList = record.GetLanguageBaseList();
            Assert.AreEqual(0, langList.Length, "#LangItems==0");
            //
            String resultEnPrimary = record.GetPrimaryMultiLanguageStringAttributeById(0);

            Assert.AreEqual(expectedEn, resultEnPrimary);
        }
        public void BadNonStringAttributePrimary()
        {
            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.GetPrimaryMultiLanguageStringAttributeById((ServiceAttributeId)0x101);

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