예제 #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
        private void ExpectQueryRemoteName(StuffStackBluetopia stuff,
                                           BluetoothAddress expectedAddr, BluetopiaError whatRet)
        {
            Int64 expectedAddrBytes = expectedAddr.ToInt64();

            Expect.Once.On(stuff.MockedApi)
            .Method("GAP_Query_Remote_Device_Name")
            .With(stuff.StackId, expectedAddrBytes, Is.Anything, Is.Anything)
            .Will(Return.Value(whatRet));
        }
예제 #4
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();
        }
예제 #5
0
        internal static void InitMockery(StuffStackBluetopia stuff, uint stackId)
        {
            stuff.Mockery = new Mockery();
            stuff.StackId = stackId;
            var hackApi = stuff.MockedApi = stuff.Mockery.NewMock <IBluetopiaApi>();

            Expect.Once.On(hackApi).Method("BSC_Initialize")
            .WithAnyArguments()     // TO-DO
            .Will(Return.Value(checked ((int)stackId)));
            Expect.Once.On(hackApi).Method("GAP_Set_Pairability_Mode")
            .WithAnyArguments()     // TO-DO
            .Will(Return.Value(BluetopiaError.OK));
            Expect.Once.On(hackApi).Method("GAP_Register_Remote_Authentication")
            .WithAnyArguments()     // TO-DO
            .Will(Return.Value(BluetopiaError.OK));
            Expect.Once.On(hackApi).Method("GAP_Query_Local_Out_Of_Band_Data")
            .WithAnyArguments()     // TO-DO
            .Will(Return.Value(BluetopiaError.INVALID_PARAMETER));
        }
예제 #6
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();
        }