UtilsClassToAttributeIdListTests.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 » UtilsClassToAttributeIdListTests.cs
using System;
using NUnit.Framework;
#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;
using InTheHand.Net.Bluetooth.AttributeIds;

namespace InTheHand.Net.Tests.Sdp2{
    [TestFixture]
    public class UtilsClassToAttributeIdListTests
    {
        
        //--------------------------------------------------------------
        class GiveAccess_SdpClassToAttributeIdList : MapServiceClassToAttributeIdList
        {
            internal new Type GetAttributeIdEnumType(Guid uuid)
            {
                return base.GetAttributeIdEnumType(uuid);
            }

            public new Type GetAttributeIdEnumType(ServiceElement idElement)
            {
                return base.GetAttributeIdEnumType(idElement);
            }
        }//class

        [Test]
        public void FromRecord()
        {
            ServiceRecord record = new ServiceRecordParser().Parse(Data_CompleteThirdPartyRecords.XpFsquirtOpp);
            MapServiceClassToAttributeIdList mapper = new MapServiceClassToAttributeIdList();
            Type[] enums = mapper.GetAttributeIdEnumTypes(record);
            Assert.IsNotNull(enums);
            Assert.AreEqual(1, enums.Length);
            Assert.IsNotNull(enums[0]);
            Assert.AreEqual("ObexAttributeId", enums[0].Name);
        }

        [Test]
        public void FromUuid_Opp()
        {
            Type enumClass = new GiveAccess_SdpClassToAttributeIdList().GetAttributeIdEnumType(
                BluetoothService.CreateBluetoothUuid(0x1105));
            Assert.IsNotNull(enumClass);
            Assert.AreEqual("ObexAttributeId", enumClass.Name);
        }

        [Test]
        public void FromUuid_AgHandfree()
        {
            Type enumClass = new GiveAccess_SdpClassToAttributeIdList().GetAttributeIdEnumType(
                BluetoothService.CreateBluetoothUuid(0x111F));
            Assert.IsNotNull(enumClass);
            Assert.AreEqual("HandsFreeProfileAttributeId", enumClass.Name);
        }

        [Test]
        public void FromElement()
        {
            ServiceElement element = new ServiceElement(ElementType.Uuid16, (UInt16)0x1105);
            Type enumClass = new GiveAccess_SdpClassToAttributeIdList().GetAttributeIdEnumType(element);
            Assert.IsNotNull(enumClass);
            Assert.AreEqual("ObexAttributeId", enumClass.Name);
        }

        //--------------------------------------------------------------
        const string CrLf = "\r\n";

        [Test]
        [ExpectedException(typeof(ArgumentNullException), "Value cannot be null." + CrLf + "Parameter name: idElement")]
        public void BadElementNull()
        {
            ServiceElement element = null;
            new GiveAccess_SdpClassToAttributeIdList().GetAttributeIdEnumType(element);
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException), "Value cannot be null." + CrLf + "Parameter name: record")]
        public void BadRecordNull()
        {
            ServiceRecord record = null;
            new MapServiceClassToAttributeIdList().GetAttributeIdEnumTypes(record);
        }

        [Test]
        public void BadElementNotUuidChild()
        {
            ServiceElement element = new ServiceElement(ElementType.UInt16, (UInt16)0x1105);
            Type enumClass = new GiveAccess_SdpClassToAttributeIdList().GetAttributeIdEnumType(element);
            Assert.IsNull(enumClass);
        }

        [Test]
        public void BadRecordNotSeq()
        {
            IList_ServiceAttribute listA = new List_ServiceAttribute();
            listA.Add(new ServiceAttribute(UniversalAttributeId.ServiceClassIdList,
                new ServiceElement(ElementType.UInt32, (UInt32)0)));
            ServiceRecord record = new ServiceRecord(listA);
            MapServiceClassToAttributeIdList mapper = new MapServiceClassToAttributeIdList();
            Type[] enums = mapper.GetAttributeIdEnumTypes(record);
            Assert.IsNotNull(enums);
            Assert.AreEqual(0, enums.Length);
        }

        [Test]
        public void BadRecordNoSvcClassAttr()
        {
            IList_ServiceAttribute listA = new List_ServiceAttribute();
            ServiceRecord record = new ServiceRecord(listA);
            MapServiceClassToAttributeIdList mapper = new MapServiceClassToAttributeIdList();
            Type[] enums = mapper.GetAttributeIdEnumTypes(record);
            Assert.IsNotNull(enums);
            Assert.AreEqual(0, enums.Length);
        }

    }//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.