void DoTest_HackOneSeqDeep(StackConsts.SDP_Data_Element_Type expectedET, byte[] expectedDataValue, ServiceRecord r) { var stuff = BluetopiaTesting.InitMockery_SdpCreator(); // const UInt16 attrId = 0xF234; var expectedElement = new Structs.SDP_Data_Element__Class_ElementArray( StackConsts.SDP_Data_Element_Type.Sequence, 1, new Structs.SDP_Data_Element__Class[] { new Structs.SDP_Data_Element__Class_InlineByteArray( 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); }
public void CallingTwice() { // Haven't decided whether to keep the instance to hold one // live record or like the base to create multiple records, // probably the first. // var stuff = BluetopiaTesting.InitMockery_SdpCreator(); try { stuff.DutSdpCreator.CreateServiceRecord(BluetopiaTesting.HackAddSvcClassList(new ServiceRecord())); stuff.DutSdpCreator.CreateServiceRecord(BluetopiaTesting.HackAddSvcClassList(new ServiceRecord())); } finally { VerifyDispose(stuff); } }
// The tests are included in the base class. protected override void DoTest(byte[] expectedRecordBytes, ServiceRecord record) { byte[] buf = new byte[1024]; var stuff = BluetopiaTesting.InitMockery_SdpCreator(); // if (expectedRecordBytes == Data_SdpCreator_SingleElementTests.RecordBytes_Empty) { Debug.Assert(!resultMap.ContainsKey(expectedRecordBytes), "manually handled!"); } else { // All other expected results are in the mapping table. // Next can throw KeyNotFoundException. SdpServiceExpectedCall expected = resultMap[expectedRecordBytes]; Expect.Once.On(stuff.MockApi2).Method("SDP_Add_Attribute") .With( Is.Anything, Is.Anything, expected.attrId, expected.element ) .Will(Return.Value(BluetopiaError.OK)); } //== record = BluetopiaTesting.HackAddSvcClassList(record); //== stuff.DutSdpCreator.CreateServiceRecord(record); stuff.Mockery_VerifyAllExpectationsHaveBeenMet(); // Expect.Once.On(stuff.MockApi2).Method("SDP_Delete_Service_Record") .With( Is.Anything, Is.Anything) .Will(Return.Value(BluetopiaError.OK)); stuff.DutSdpCreator.Dispose(); stuff.Mockery_VerifyAllExpectationsHaveBeenMet(); }
public void RecordA() { var stuff = BluetopiaTesting.InitMockery_SdpCreator(); var bldr = new ServiceRecordBuilder(); bldr.AddServiceClass(BluetoothService.Wap); bldr.AddBluetoothProfileDescriptor(BluetoothService.WapClient, 0x1, 0x2); // Expect.AtLeastOnce.On(stuff.MockApi2).Method("SDP_Add_Attribute") .With( stuff.StackId, stuff.SrHandle, (ushort)UniversalAttributeId.ProtocolDescriptorList, //Is.Anything new Structs.SDP_Data_Element__Class_ElementArray( StackConsts.SDP_Data_Element_Type.Sequence, 2, new Structs.SDP_Data_Element__Class_ElementArray( StackConsts.SDP_Data_Element_Type.Sequence, 1, new Structs.SDP_Data_Element__Class_InlineByteArray( StackConsts.SDP_Data_Element_Type.UUID_16, 2, new byte[] { 0x01, 0x00 } ) ), new Structs.SDP_Data_Element__Class_ElementArray( StackConsts.SDP_Data_Element_Type.Sequence, 2, new Structs.SDP_Data_Element__Class_InlineByteArray( StackConsts.SDP_Data_Element_Type.UUID_16, 2, new byte[] { 0x00, 0x03 } ), new Structs.SDP_Data_Element__Class_InlineByteArray( StackConsts.SDP_Data_Element_Type.UnsignedInteger1Byte, 1, new byte[] { 0 } ) ) ) ) .Will(Return.Value(BluetopiaError.OK)); Expect.AtLeastOnce.On(stuff.MockApi2).Method("SDP_Add_Attribute") .With( stuff.StackId, stuff.SrHandle, (ushort)UniversalAttributeId.BluetoothProfileDescriptorList, new Structs.SDP_Data_Element__Class_ElementArray( StackConsts.SDP_Data_Element_Type.Sequence, 1, new Structs.SDP_Data_Element__Class_ElementArray( StackConsts.SDP_Data_Element_Type.Sequence, 2, new Structs.SDP_Data_Element__Class_InlineByteArray( StackConsts.SDP_Data_Element_Type.UUID_16, 2, new byte[] { 0x11, 0x14, } ), new Structs.SDP_Data_Element__Class_InlineByteArray( StackConsts.SDP_Data_Element_Type.UnsignedInteger2Bytes, 2, new byte[] { 0x02, 0x01, } //endian! ) ) ) ) .Will(Return.Value(BluetopiaError.OK)); // stuff.DutSdpCreator.CreateServiceRecord(bldr.ServiceRecord); //-- VerifyDispose(stuff); }