Exemple #1
0
        void DoTest(StackConsts.SDP_Data_Element_Type expectedET,
                    byte[] expectedDataValue, bool expectedValueInline,
                    ServiceRecord r)
        {
            var stuff = BluetopiaTesting.InitMockery_SdpCreator();
            //
            const UInt16 attrId = 0xF234;

            Structs.SDP_Data_Element__Class_ByteArray expectedElement;
            if (expectedValueInline)
            {
                expectedElement = new Structs.SDP_Data_Element__Class_InlineByteArray(
                    expectedET,
                    expectedDataValue.Length, expectedDataValue);
            }
            else
            {
                expectedElement = new Structs.SDP_Data_Element__Class_NonInlineByteArray(
                    expectedET,
                    expectedDataValue.Length, expectedDataValue);
            }
            Expect.Once.On(stuff.MockApi2).Method("SDP_Add_Attribute")
            .With(
                stuff.StackId, stuff.SrHandle,
                attrId,
                expectedElement
                )
            .Will(Return.Value(BluetopiaError.OK));
            //
            stuff.DutSdpCreator.CreateServiceRecord(r);
            stuff.Mockery_VerifyAllExpectationsHaveBeenMet();
            VerifyDispose(stuff);
        }
        private Structs.SDP_Data_Element__Class CreateExpected_ElementsAndVariableAndFixedInDeepTree1()
        {
            var str      = Data_SdpCreator_SingleElementTests.RecordBytes_OneString_StringValueAsBytes;
            var itemStr1 = new Structs.SDP_Data_Element__Class_NonInlineByteArray(
                StackConsts.SDP_Data_Element_Type.TextString, str.Length, str);
            var itemStr2 = new Structs.SDP_Data_Element__Class_NonInlineByteArray(
                StackConsts.SDP_Data_Element_Type.TextString, str.Length, str);
            //
            Uri uriU    = new Uri("http://example.com/foo.txt");
            var uri     = Encoding.ASCII.GetBytes(uriU.ToString());
            var itemUrl = new Structs.SDP_Data_Element__Class_NonInlineByteArray(
                StackConsts.SDP_Data_Element_Type.URL, uri.Length, uri);
            //
            var itemF1 = new Structs.SDP_Data_Element__Class_InlineByteArray(
                StackConsts.SDP_Data_Element_Type.UnsignedInteger2Bytes, 2, IntegralNetworkToApi(new byte[] { 0xfe, 0x12 }));
            var itemF2 = new Structs.SDP_Data_Element__Class_InlineByteArray(
                StackConsts.SDP_Data_Element_Type.UnsignedInteger2Bytes, 2, IntegralNetworkToApi(new byte[] { 0x12, 0x34 }));
            //
            var leaves2 = new List <Structs.SDP_Data_Element__Class>();

            leaves2.Add(itemStr1);
            leaves2.Add(itemUrl);
            leaves2.Add(itemF1);
            var e2 = new Structs.SDP_Data_Element__Class_ElementArray(
                StackConsts.SDP_Data_Element_Type.Sequence, leaves2.Count, leaves2.ToArray());
            //
            var e1 = new Structs.SDP_Data_Element__Class_ElementArray(
                StackConsts.SDP_Data_Element_Type.Sequence, 1, e2);
            //
            var leaves0 = new List <Structs.SDP_Data_Element__Class>();

            leaves0.Add(e1);
            leaves0.Add(itemStr2);
            leaves0.Add(itemF2);
            var e0 = new Structs.SDP_Data_Element__Class_ElementArray(
                StackConsts.SDP_Data_Element_Type.Alternative, leaves0.Count,
                leaves0.ToArray());

            return(e0);
        }