RecordLangBaseTests.cs :  » Business-Application » 32feet.NET » InTheHand » Net » Tests » Sdp2 » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Business Application » 32feet.NET 
32feet.NET » InTheHand » Net » Tests » Sdp2 » RecordLangBaseTests.cs
using System;
using NUnit.Framework;
//using System.Text;
#if FX1_1
using IList_ServiceElementSystem.Collections.IList;
using List_ServiceElementSystem.Collections.ArrayList;
using IList_ServiceAttributeSystem.Collections.IList;
using List_ServiceAttributeSystem.Collections.ArrayList;
#else
using IList_ServiceElementSystem.Collections.Generic.IListInTheHand.Net.Bluetooth.ServiceElement;
using List_ServiceElementSystem.Collections.Generic.ListInTheHand.Net.Bluetooth.ServiceElement;
using IList_ServiceAttributeSystem.Collections.Generic.IListInTheHand.Net.Bluetooth.ServiceAttribute;
using List_ServiceAttributeSystem.Collections.Generic.ListInTheHand.Net.Bluetooth.ServiceAttribute;
#endif
using InTheHand.Net.Bluetooth.AttributeIds;
using InTheHand.Net.Bluetooth;

namespace InTheHand.Net.Tests.Sdp2{

    [TestFixture]
    public class LanguageBase_RecordMethod_GetList
    {
        [Test]
        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");
        }

        [Test]
        public void NoSuchAttributeInRecord()
        {
            IList_ServiceAttribute list
                = new List_ServiceAttribute(0);
            ServiceRecord record = new ServiceRecord(list);
            LanguageBaseItem[] items = record.GetLanguageBaseList();
            Assert.IsNotNull(items, "GetLanguageBaseList() should never be null.");
            Assert.AreEqual(0, items.Length, "items.Length");
        }

        [Test]
        //[ExpectedException(typeof(System.Net.ProtocolViolationException), "LanguageBaseList attribute not of type ElementSequence.")]
        public void LangAttrNotElementTypeSeq()
        {
            List_ServiceAttribute list = new List_ServiceAttribute();
            list.Add(new ServiceAttribute(UniversalAttributeId.LanguageBaseAttributeIdList,
                new ServiceElement(ElementType.TextString, new byte[] { (byte)'f', (byte)'o', (byte)'o', })));
            ServiceRecord record = new ServiceRecord(list);
            LanguageBaseItem[] items = record.GetLanguageBaseList();
            Assert.IsNotNull(items, "GetLanguageBaseList() should never be null.");
            Assert.AreEqual(0, items.Length, "items.Length");
        }

        [Test]
        public void LangAttrInvalid()
        {
            IList_ServiceAttribute list = new List_ServiceAttribute();
            list.Add(Data_LanguageBaseList.AttrFourElements);
            ServiceRecord record = new ServiceRecord(list);
            LanguageBaseItem[] items = record.GetLanguageBaseList();
            Assert.IsNotNull(items, "GetLanguageBaseList() should never be null.");
            Assert.AreEqual(0, items.Length, "items.Length");
        }

    }//class


    [TestFixture]
    public class LanguageBase_RecordMethod_GetPrimary
    {
        [Test]
        public void TwoItemsAsArrayToParse()
        {
            ServiceRecord record = new ServiceRecordParser().Parse(Data_LanguageBaseList.RecordTwoItemsAsBytes);
            LanguageBaseItem item = record.GetPrimaryLanguageBaseItem();
            //
            Assert.AreEqual(Data_LanguageBaseList.LangStringEn, item.NaturalLanguage, "NaturalLanguage");
            Assert.AreEqual(Data_LanguageBaseList.EncUtf8, item.EncodingId, "EncodingId");
            Assert.AreEqual((ServiceAttributeId)0x0100, item.AttributeIdBase, "AttributeIdBase");
        }

        [Test]
        public void NoSuchAttributeInRecord()
        {
            IList_ServiceAttribute list
                = new List_ServiceAttribute(0);
            ServiceRecord record = new ServiceRecord(list);
            LanguageBaseItem item = record.GetPrimaryLanguageBaseItem();
            Assert.IsNull(item, "IsNull--item");
        }

        [Test]
        //[ExpectedException(typeof(System.Net.ProtocolViolationException), "LanguageBaseList attribute not of type ElementSequence.")]
        public void LangAttrNotElementTypeSeq()
        {
            List_ServiceAttribute list = new List_ServiceAttribute();
            list.Add(new ServiceAttribute(UniversalAttributeId.LanguageBaseAttributeIdList,
                new ServiceElement(ElementType.TextString, new byte[] { (byte)'f', (byte)'o', (byte)'o', })));
            ServiceRecord record = new ServiceRecord(list);
            LanguageBaseItem item = record.GetPrimaryLanguageBaseItem();
            Assert.IsNull(item, "GetPrimaryLanguageBaseItem() should be null.");
        }

        [Test]
        public void LangAttrInvalid()
        {
            IList_ServiceAttribute list = new List_ServiceAttribute();
            list.Add(Data_LanguageBaseList.AttrFourElements);
            ServiceRecord record = new ServiceRecord(list);
            LanguageBaseItem item = record.GetPrimaryLanguageBaseItem();
            Assert.IsNull(item, "GetPrimaryLanguageBaseItem() should be null.");
        }

        [Test]
        public void LangAttrNoPrimary0100Item()
        {
            IList_ServiceAttribute list = new List_ServiceAttribute();
            list.Add(Data_LanguageBaseList.AttrOneItemBadBaseZero);
            ServiceRecord record = new ServiceRecord(list);
            LanguageBaseItem item = record.GetPrimaryLanguageBaseItem();
            Assert.IsNull(item, "GetPrimaryLanguageBaseItem() should be null.");
        }

    }//class

}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.