Exemplo n.º 1
0
        private static BlueSoleilSerialPortNetworkStream CreateConnectedStream(out BsTestNullApi api)
        {
            api = new BsTestNullApi();
            api.SetIsOpen();
            var fcty = new BluesoleilFactory(api);
            TestSerialPortWrapper port = new TestSerialPortWrapper();
            UInt32 hConn = 0;
            var    cli   = (BluesoleilClient)fcty.DoGetBluetoothClient();
            var    conn  = new BlueSoleilSerialPortNetworkStream(port, hConn, cli, fcty);

            return(conn);
        }
Exemplo n.º 2
0
 //--------
 private static void Create_BtCli(out Mockery mkry, out IBluesoleilApi api,
                                  out BluesoleilFactory fcty, out IBluetoothClient cli)
 {
     mkry = new Mockery();
     api  = mkry.NewMock <IBluesoleilApi>();
     //
     Expect.Exactly(2).On(api).Method("Btsdk_IsSDKInitialized")
     .WithAnyArguments()
     .Will(Return.Value(false));
     Expect.Once.On(api).Method("Btsdk_IsServerConnected")
     .WithAnyArguments()
     .Will(Return.Value(false));
     //
     Expect.AtLeastOnce.On(api).Method("Btsdk_Init")
     .WithAnyArguments()
     .Will(Return.Value(BtSdkError.OK));
     //
     //Expect.AtLeastOnce.On(api).Method("Btsdk_IsBluetoothReady")
     //    .WithAnyArguments()
     //    .Will(Return.Value(true));
     Expect.Once.On(api).Method("Btsdk_IsServerConnected")
     .WithAnyArguments()
     .Will(Return.Value(true));
     Expect.Once.On(api).Method("Btsdk_IsBluetoothHardwareExisted")
     .WithAnyArguments()
     .Will(Return.Value(true));
     Expect.AtLeastOnce.On(api).Method("Btsdk_IsSDKInitialized")
     .WithAnyArguments()
     .Will(Return.Value(true));
     Expect.AtLeastOnce.On(api).Method("Btsdk_IsServerConnected")
     .WithAnyArguments()
     .Will(Return.Value(true));
     //
     Expect.Once.On(api).Method("Btsdk_GetLocalDeviceAddress")
     .WithAnyArguments()
     .Will(Return.Value(BtSdkError.OK));
     Expect.Once.On(api).Method("Btsdk_GetLocalName")
     .WithAnyArguments()
     .Will(Return.Value(BtSdkError.OK));
     Expect.Once.On(api).Method("Btsdk_GetLocalDeviceClass")
     .With(Is.Out)
     .Will(Return.Value(BtSdkError.OK),
           new NMock2.Actions.SetIndexedParameterAction(0, (uint)0));
     Expect.Once.On(api).Method("Btsdk_GetLocalLMPInfo")
     .WithAnyArguments()
     .Will(Return.Value(BtSdkError.OK));
     //
     fcty = new BluesoleilFactory(api);
     mkry.VerifyAllExpectationsHaveBeenMet();
     cli = fcty.DoGetBluetoothClient();
     mkry.VerifyAllExpectationsHaveBeenMet();
 }