コード例 #1
0
        public void DeviceNameErrorOnQuery_NOCALLBACK_DoRefresh()
        {
            var addr = BluetoothAddress.Parse("001122334455");
            //
            var stuff = new StuffStackBluetopia();

            BluetopiaTesting.InitMockery(stuff, 2);
            //
            var bdi = stuff.GetFactory().DoGetBluetoothDeviceInfo((BluetoothAddress)addr.Clone());

            //
            Assert.AreEqual(addr, bdi.DeviceAddress, "DeviceAddress");
            stuff.Mockery_VerifyAllExpectationsHaveBeenMet();
            ExpectQueryRemoteName(stuff, addr, BluetopiaError.OK);
            Assert.AreEqual(addr.ToString("C"), bdi.DeviceName, "DeviceName");
            //
            // When we get an error we set the name to the address and DO NOT
            // call GAP_Query_Remote_Device_Name again.
            // Unless we hit Refresh....
            bdi.Refresh();
            stuff.Mockery_VerifyAllExpectationsHaveBeenMet();
            // TO-DO This fails because the previous lookup is still pending
            // (no callback occurred) so we don't start another query!)
            ExpectQueryRemoteName(stuff, addr, BluetopiaError.OK);
            Assert.AreEqual(addr.ToString("C"), bdi.DeviceName, "DeviceName");
            //
            stuff.Mockery_VerifyAllExpectationsHaveBeenMet();
        }
コード例 #2
0
        public void DeviceNameErrorOnQuery_NoCallback_DoesntRefresh()
        {
            var addr       = BluetoothAddress.Parse("001122334455");
            var addrBytes8 = addr.ToByteArray();
            var addrBytes  = new byte[6];

            Array.Copy(addrBytes8, 0, addrBytes, 0, addrBytes.Length); // To-Do what endianism?
            //
            var stuff = new StuffStackBluetopia();

            BluetopiaTesting.InitMockery(stuff, 2);
            //
            var bdi = stuff.GetFactory().DoGetBluetoothDeviceInfo(
                (BluetoothAddress)addr.Clone());

            //
            Assert.AreEqual(addr, bdi.DeviceAddress, "DeviceAddress");
            stuff.Mockery_VerifyAllExpectationsHaveBeenMet();
            ExpectQueryRemoteName(stuff, addr, BluetopiaError.OK);
            Assert.AreEqual(addr.ToString("C"), bdi.DeviceName, "DeviceName");
            //
            // When we get an error we set the name to the address and DO NOT
            // call GAP_Query_Remote_Device_Name again.
            Assert.AreEqual(addr.ToString("C"), bdi.DeviceName, "DeviceName");
            //
            stuff.Mockery_VerifyAllExpectationsHaveBeenMet();
        }
コード例 #3
0
        // TODO (Mockery_VerifyAllExpectationsHaveBeenMet();
        // TODO (Uuid16).

        internal static StuffSdpQueryBluetopia Create_BluetopiaSdpQuery()
        {
            var stuff = new StuffSdpQueryBluetopia();

            BluetopiaTesting.InitMockery(stuff, 205);
            //
            stuff.SetDut(new BluetopiaSdpQuery(stuff.GetFactory()));
            return(stuff);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: BluetopiaTesting.cs プロジェクト: zhubin-12/32feet
        internal static StuffClientBluetopia InitMockery_Client(ClientTestingBluetopia.Behaviour behaviour)
        {
            StuffClientBluetopia stuff = new StuffClientBluetopia();

            stuff.Behaviour = behaviour;
            BluetopiaTesting.InitMockery(stuff, 10);
            if (stuff.Behaviour.MockIBtSecurity)
            {
                stuff.CreateMockedSecurityApi();
            }
            stuff.GetFactory();
            return(stuff);
        }
コード例 #6
0
        public void One()
        {
            var addr = BluetoothAddress.Parse("001122334455");
            //
            var stuff = new StuffStackBluetopia();

            BluetopiaTesting.InitMockery(stuff, 2);
            //
            var bdi = stuff.GetFactory().DoGetBluetoothDeviceInfo(
                (BluetoothAddress)addr.Clone());

            //
            Assert.AreEqual(addr, bdi.DeviceAddress, "DeviceAddress");
            stuff.Mockery_VerifyAllExpectationsHaveBeenMet();
            ExpectQueryRemoteName(stuff, addr, BluetopiaError.OK);
            Assert.AreEqual(addr.ToString("C"), bdi.DeviceName, "DeviceName");
            //
            stuff.Mockery_VerifyAllExpectationsHaveBeenMet();
        }
コード例 #7
0
        public void NoAccessToDeviceName()
        {
            var addr = BluetoothAddress.Parse("001122334455");
            //
            var stuff = new StuffStackBluetopia();

            BluetopiaTesting.InitMockery(stuff, 2);
            //
            var bdi = stuff.GetFactory().DoGetBluetoothDeviceInfo(
                (BluetoothAddress)addr.Clone());

            //
            Assert.AreEqual(addr, bdi.DeviceAddress, "DeviceAddress");
            Assert.IsFalse(bdi.Remembered, "Remembered");
            Assert.IsFalse(bdi.Authenticated, "Authenticated");
            Assert.IsFalse(bdi.Connected, "Connected");
            Assert.AreEqual(new ClassOfDevice(0), bdi.ClassOfDevice, "ClassOfDevice");
            Assert.AreEqual(DateTime.MinValue, bdi.LastSeen, "LastSeen");
            Assert.AreEqual(DateTime.MinValue, bdi.LastUsed, "LastUsed");
            //
            stuff.Mockery_VerifyAllExpectationsHaveBeenMet();
        }