Exemple #1
0
 private void WritesQueuedAtCloseLinger_AllSent_Finish(TestRfcommPort port, Stream strm, IAsyncResult ar1, IAsyncResult ar2)
 {
     Assert.IsTrue(ar1.IsCompleted, "WritesQueuedAtClose--IsComplete ar1 After close");
     Assert.IsTrue(ar2.IsCompleted, "WritesQueuedAtClose--IsComplete ar2 After close");
     port.AssertWrittenContent("WritesQueuedAtClose--written--after close",
                               First(Data30, 20), ExceptFirst(Data30, 20),
                               First(Data30, 20), ExceptFirst(Data30, 20)
                               );
     strm.EndWrite(ar1);
     strm.EndWrite(ar2);
 }
Exemple #2
0
        protected static IAsyncResult dlgt_BeginInvoke(Foo dlgt, TestRfcommPort port, PORT_EV eventId,
                                                       AsyncCallback callback, object state)
        {
#if true || PocketPC
            FooParams args = new FooParams(dlgt, port, eventId);
            AsyncNoResult <FooParams> ar = new AsyncNoResult <FooParams>(callback, state, args);
            ThreadPool.QueueUserWorkItem(dlgt_Runner, ar);
            return(ar);
#else
            arDlgt = dlgt.BeginInvoke(port, eventId, null, null); // NETCF-ok
#endif
        }
Exemple #3
0
        private void WritesQueuedAtCloseLinger_Init(out TestRfcommPort port, out Stream strm, out IAsyncResult ar1, out IAsyncResult ar2)
        {
            BluetoothClient cli;

            Create_ConnectedBluetoothClient_WritePartialsAcceptHalf(out port, out cli, out strm);
            cli.LingerState = new LingerOption(true, Test_LingerTimeSeconds);
            //
            ar1 = strm.BeginWrite(Data30, 0, Data30.Length, null, null);
            ar2 = strm.BeginWrite(Data30, 0, Data30.Length, null, null);
            Assert.IsFalse(ar1.IsCompleted, "WritesQueuedAtClose--IsComplete ar1");
            port.AssertWrittenContent("WritesQueuedAtClose--written--before", First(Data30, 20));
            Assert.IsFalse(ar2.IsCompleted, "WritesQueuedAtClose--IsComplete ar2");
        }
            public BluetoothClientTestSocketPair()
            {
                TestRfCommIf    rfcommIf;
                TestRfcommPort  port;
                BluetoothClient cli;
                Stream          strm2;

                WidcommBluetoothClientCommsTest.Create_ConnectedBluetoothClient(
                    out rfcommIf, out port, out cli, out strm2);
                m_cliA     = new BluetoothClientWrapper(cli);
                m_port     = port;
                m_rfcommIf = rfcommIf;
            }
Exemple #5
0
        private static void Create_BluetoothClient_WritePartialsAcceptHalfB(WidcommBtInterface btIface,
                                                                            out TestRfcommPort port, out BluetoothClient cli, out Stream strm2)
        {
            WidcommFactoryGivenInstances fcty = new WidcommFactoryGivenInstances();

            port = new TestRfcommPort_WritePartials_AcceptHalf();
            TestRfCommIf            rfCommIf = new TestRfCommIf();
            WidcommRfcommStreamBase strm     = new WidcommRfcommStream(port, rfCommIf, fcty);

            fcty.AddRfcommStream(strm);
            fcty.SetBtInterface(btIface);
            WidcommBluetoothClient wcli = new WidcommBluetoothClient(fcty);

            cli   = new BluetoothClient(wcli);
            strm2 = strm;
        }
Exemple #6
0
 private void WritesQueuedAtCloseLinger_OneMoreSent_Finish(TestRfcommPort port, Stream strm, IAsyncResult ar1, IAsyncResult ar2)
 {
     Assert.IsTrue(ar1.IsCompleted, "WritesQueuedAtClose--IsComplete ar1 After close");
     Assert.IsTrue(ar2.IsCompleted, "WritesQueuedAtClose--IsComplete ar2 After close");
     port.AssertWrittenContent("WritesQueuedAtClose--written--after close",
                               First(Data30, 20), ExceptFirst(Data30, 20),
                               First(Data30, 20)
                               );
     strm.EndWrite(ar1);
     try {
         strm.EndWrite(ar2);
         Assert.Fail("should have thrown");
     } catch (IOException ioex) {
         Assert.IsInstanceOfType(typeof(SocketException), ioex.InnerException);
         SocketException ex = (SocketException)ioex.InnerException;
         Assert.AreEqual(SocketError_NotConnected, ex.ErrorCode);
     }
 }
Exemple #7
0
        private static void ConnectBluetoothClient(TestRfcommPort port, BluetoothClient cli)
        {
            BluetoothEndPoint bep = new BluetoothEndPoint(BluetoothAddress.Parse("00:1F:2E:3D:4C:5B"),
                                                          InTheHand.Net.Bluetooth.BluetoothService.Empty, 5);

            byte[]    AddressInWidcomm = CanonicalOrderBytes(bep.Address);
            const int ChannelNumber    = 5;
            //
            IAsyncResult ar;

            //
            // Success
            port.SetOpenClientResult(PORT_RETURN_CODE.SUCCESS);
            ar = cli.BeginConnect(bep, null, null);
            port.AssertOpenClientCalledAndClear(AddressInWidcomm, ChannelNumber);
            port.NewEvent(PORT_EV.CONNECTED);
            TestsApmUtils.SafeNoHangWaitShort(ar, "Connect 1");
            Assert.IsTrue(ar.IsCompleted, "Connect 1 completed");
            cli.EndConnect(ar);
        }
Exemple #8
0
 public EventFirer(TestRfcommPort port)
 {
     this.port = port;
 }
Exemple #9
0
 public WidcommPortBuffers(TestRfcommPort port)
 {
     _port = port;
 }
Exemple #10
0
 //----
 internal void Create_ConnectedBluetoothClient(out TestRfCommIf rfcommIf, out TestRfcommPort port, out BluetoothClient cli, out Stream strm2)
 {
     WidcommBluetoothClientCommsTest.Create_ConnectedBluetoothClient(
         out rfcommIf, out port, out cli, out strm2);
 }
Exemple #11
0
 private static void Create_BluetoothClient_WritePartialsAcceptHalfA(
     out TestRfcommPort port, out BluetoothClient cli, out Stream strm2)
 {
     Create_BluetoothClient_WritePartialsAcceptHalfB(null, out port, out cli, out strm2);
 }
Exemple #12
0
 private void Create_ConnectedBluetoothClient_WritePartialsAcceptHalf(
     out TestRfcommPort port, out BluetoothClient cli, out Stream strm2)
 {
     Create_BluetoothClient_WritePartialsAcceptHalfA(out port, out cli, out strm2);
     ConnectBluetoothClient(port, cli);
 }
Exemple #13
0
 public FireOpenReceiveCloseEvents(TestRfcommPort port)
     : base(port)
 {
 }
Exemple #14
0
 public OneEvent100msFirer(TestRfcommPort port)
     : base(port)
 {
     preEventDelayMilliseconds = 100;
 }
Exemple #15
0
 internal TestRfcommStream_WriteEventAfterEachBeginWrite(TestRfcommPort port, IRfCommIf iface, WidcommBluetoothFactoryBase fcty)
     : base(port, iface, fcty)
 {
     m_port = port;
 }
Exemple #16
0
 public OneEventFirer(TestRfcommPort port, int preEventDelayMilliseconds)
     : base(port)
 {
     this.preEventDelayMilliseconds = preEventDelayMilliseconds;
 }
Exemple #17
0
 public OneEventFirer(TestRfcommPort port)
     : base(port)
 {
 }
Exemple #18
0
 public FooParams(Foo dlgt, TestRfcommPort port, PORT_EV eventId)
 {
     this.dlgt    = dlgt;
     this.port    = port;
     this.eventId = eventId;
 }