static StuffRadio Create_Radio_A(Params p) { var stuff = new StuffRadio(); //. const uint StackId = 1; var addrBytes = new byte[] { 0xA4, 0x24, 0x4C, 0x98, 0x24, 0x08 }; var ExpectedAddress = BluetoothAddress.Parse("08:24:98:4C:24:A4"); var nameBytes = new byte[] { (byte)'A', (byte)'b', (byte)'c', 0 }; var ExpectedName = "Abc"; var codStruct = (uint)0x20104; var ExpectedCod = new ClassOfDevice(0x20104); // BluetopiaTesting.InitMockery(stuff, StackId); Expect.Once.On(stuff.MockedApi).Method("GAP_Query_Local_BD_ADDR") .With(StackId, new byte[6]) .Will( FillArrayIndexedParameterAction.Fill(1, addrBytes, true), Return.Value(BluetopiaError.OK)); Expect.Once.On(stuff.MockedApi).Method("GAP_Query_Local_Device_Name") .With(StackId, 248, new byte[248]) .Will( FillArrayIndexedParameterAction.Fill(2, nameBytes, false), Return.Value(BluetopiaError.OK)); Expect.Once.On(stuff.MockedApi).Method("GAP_Query_Class_Of_Device") .With(StackId, Is.Out) .Will( new SetIndexedParameterAction(1, codStruct), Return.Value(BluetopiaError.OK)); if (p.AccessesVersionsOrManufacturer) { Expect.Once.On(stuff.MockedApi).Method("HCI_Read_Local_Version_Information") .With(StackId, Is.Out, Is.Out, Is.Out, Is.Out, Is.Out, Is.Out) .Will( new SetIndexedParameterAction(1, (StackConsts.HCI_ERROR_CODE) 0), new SetIndexedParameterAction(2, (HciVersion)0), new SetIndexedParameterAction(3, (UInt16)0), new SetIndexedParameterAction(4, (LmpVersion)0), new SetIndexedParameterAction(5, Manufacturer.Zeevo), new SetIndexedParameterAction(6, (UInt16)0), Return.Value(BluetopiaError.OK)); } //-- BluetopiaTesting.HackAllowShutdownCall(stuff.MockedApi); BluetopiaFactory fcty = new BluetopiaFactory(stuff.MockedApi); IBluetoothRadio r = stuff.Radio = fcty.DoGetPrimaryRadio(); Assert.AreEqual(Manufacturer.StonestreetOne, r.SoftwareManufacturer, "SoftwareManufacturer"); Assert.AreEqual(ExpectedAddress, r.LocalAddress, "LocalAddress"); Assert.AreEqual(ExpectedName, r.Name, "Name"); Assert.AreEqual(ExpectedCod, r.ClassOfDevice, "ClassOfDevice"); // return(stuff); }
private void ExpectGetDeviceInfo(IBluesoleilApi api, UInt32 hDev) { Expect.Once.On(api).Method("Btsdk_GetRemoteDeviceHandle") .With(ArrayMatcher.MatchContentExactly(AddrABytes)) .Will(Return.Value(hDev)); Expect.Once.On(api).Method("Btsdk_GetRemoteDeviceAddress") .WithAnyArguments() .Will(Return.Value(BtSdkError.OK), FillArrayIndexedParameterAction.Fill(1, AddrABytes, true) ); Expect.Once.On(api).Method("Btsdk_GetRemoteDeviceClass") .WithAnyArguments() .Will(Return.Value(BtSdkError.NOTFOUND), //??what code new NMock2.Actions.SetIndexedParameterAction(1, (uint)0) ); }
private static byte[] SendReceiveTen(StuffClientBluetopia stuff) { byte[] srcBuf = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA }; bool isMustBeSameLength = false; int sizeOfReaderBuffer = 10; Expect.Once.On(stuff.MockedApi).Method("SPP_Data_Read") .With(stuff.StackId, stuff.DutConn.Testing_GetPortId(), (ushort)sizeOfReaderBuffer, new byte[sizeOfReaderBuffer]) .Will(Return.Value(srcBuf.Length), FillArrayIndexedParameterAction.Fill(3, srcBuf, isMustBeSameLength)); using (var ctor = new SppEventCreator()) { var eventData = ctor.CreateDataIndication(stuff.DutConn.Testing_GetPortId(), srcBuf.Length); ClientTestingBluetopia.RaiseSppEvent(stuff, eventData); } stuff.Mockery_VerifyAllExpectationsHaveBeenMet(); return(srcBuf); }