示例#1
0
        private static AndroidMockValues GetOriginalValuesClass()
        {
            Android.Bluetooth.ServiceClass scIIII = Android.Bluetooth.ServiceClass.LimitedDiscoverability | Android.Bluetooth.ServiceClass.ObjectTransfer;
            var v = new AndroidMockValues
            {
                Radio_Address = "00:11:22:AA:BB:CC",
                Radio_Name    = "MyRadio1",
                // Adapter
                Radio_State    = Android.Bluetooth.State.On,
                Radio_ScanMode = Android.Bluetooth.ScanMode.Connectable,
                // Device
                Device1_Address   = "00:91:A2:2A:3B:4C",
                Device1_Name      = "TheRemoteDeviceName",
                Device1_BondState = Bond.None,
                // Class
                Device1_Class_DeviceClass  = Android.Bluetooth.DeviceClass.HealthPulseOximeter,
                Device1_Class_ServiceClass = scIIII,
            };

            return(v);
        }
示例#2
0
        private static Dictionary <KeyValuePair <string, string>, object> Convert(AndroidMockValues values)
        {
            Func <IMethodCallMessage, object> dlgt;
            var d = new Dictionary <KeyValuePair <string, string>, object>();
            //----
            const string _ServiceClass = "_ServiceClass";

            dlgt = (msg) =>
            {
                var sc = (Android.Bluetooth.ServiceClass)d[new KeyValuePair <string, string>(_ServiceClass, null)];
                return(DoHasServiceFunction(msg, sc));
            };
            d.Add(new KeyValuePair <string, string>("HasService", null), dlgt);
            //
            dlgt = _ => Create <BluetoothDevice>(d);
            d.Add(new KeyValuePair <string, string>("GetRemoteDevice", AdapterTypeName), dlgt);
            //
            dlgt = _ => Create <BluetoothClass>(d);
            d.Add(new KeyValuePair <string, string>("get_BluetoothClass", DeviceTypeName), dlgt);
            //
            dlgt = _ => new List <BluetoothDevice> {
                Create <BluetoothDevice>(d)
            };
            d.Add(new KeyValuePair <string, string>("get_BondedDevices", AdapterTypeName), dlgt);
            //----
            d.Add(new KeyValuePair <string, string>("get_Address", AdapterTypeName), values.Radio_Address);
            d.Add(new KeyValuePair <string, string>("get_Name", AdapterTypeName), values.Radio_Name);
            // Adapter
            d.Add(new KeyValuePair <string, string>("get_State", AdapterTypeName), values.Radio_State);
            d.Add(new KeyValuePair <string, string>("get_ScanMode", AdapterTypeName), values.Radio_ScanMode);
            // Device
            d.Add(new KeyValuePair <string, string>("get_Address", DeviceTypeName), values.Device1_Address);
            d.Add(new KeyValuePair <string, string>("get_Name", DeviceTypeName), values.Device1_Name);
            d.Add(new KeyValuePair <string, string>("get_BondState", DeviceTypeName), values.Device1_BondState);
            // Class
            d.Add(new KeyValuePair <string, string>("get_DeviceClass", null), values.Device1_Class_DeviceClass);
            d.Add(new KeyValuePair <string, string>(_ServiceClass, null), values.Device1_Class_ServiceClass);
            //
            return(d);
        }
 public AndroidBthMockFactory(AndroidMockValues values)
     : base(MockAndroidBth1.Create <BluetoothAdapter>(values))
 {
 }
示例#4
0
 public static T Create <T>(AndroidMockValues values)
     where T : MarshalByRefObject
 {
     return(Create <T>(Convert(values)));
 }