Exemplo n.º 1
0
 public void TestAsynchronousDisconnect()
 {
     Assert.Inconclusive();
     System.Threading.ThreadPool.GetAvailableThreads(out int workerThreads, out int completionPortThreads);
     Console.WriteLine("number of available threads worker= {0}; CompletionPort= {1}", workerThreads, completionPortThreads);
     Assert.IsFalse(myMachine.NeedsChannelAccess, "inconsistency of the myMachine.NeedsChannelAccess");
     myNumberOfThreads = workerThreads;
     for (int index = 0; index < myNumberOfThreads; index++)
     {
         System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(WaitCallbackHandle), this);
     }
     //
     System.Threading.ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads);
     Console.WriteLine("number of available threads worker= {0}; CompletionPort= {1}", workerThreads, completionPortThreads);
     Thread.Sleep(1000);
     System.Threading.ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads);
     Console.WriteLine("number of available threads worker= {0}; CompletionPort= {1}", workerThreads, completionPortThreads);
     //
     while (!Equals(myNumberOfThreads, 0))
     {
         MakeConnection();
         AssertKeepConnection();
         myMachine.DisconnectRequest();
         AssertDisconnected();
     }
     Console.WriteLine(myMaster.ToString());
     AssertDisconnected();
     Assert.IsFalse(myMachine.NeedsChannelAccess, "inconsistency of the myMachine.NeedsChannelAccess");
     System.Threading.ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads);
     Console.WriteLine("number of available threads worker= {0}; CompletionPort= {1}", workerThreads, completionPortThreads);
 }
Exemplo n.º 2
0
        public void GoTest()
        {
            FacadeApplicationLayerMaster m_Master = new FacadeApplicationLayerMaster();
            string m_MasterToString  = m_Master.ToString();
            GuardedDataProvider m_gp = new GuardedDataProvider("GoTest", m_Master);
            string m_gpToString      = m_gp.ToString();

            Assert.AreEqual(m_gpToString, m_MasterToString, "ToString error");
            StringAddress m_address = new StringAddress("DummyAddress");

            Assert.IsFalse(m_gp.Connected, "State error");
            m_gp.ConnectReq(m_address);
            Assert.IsTrue(m_gp.Connected, "State error");
            FacadeBlockDescription m_block = new FacadeBlockDescription(int.MaxValue, 100, short.MaxValue);
            IReadValue             m_readVal;

            switch (m_gp.ReadData(m_block, int.MaxValue, out m_readVal, byte.MaxValue))
            {
            case AL_ReadData_Result.ALRes_DatTransferErrr:
            case AL_ReadData_Result.ALRes_DisInd:
                Assert.Fail("incorrect return value from ReadData");
                break;

            case AL_ReadData_Result.ALRes_Success:
                Assert.IsNotNull(m_readVal, "ReadData returned null");
                m_readVal.ReturnEmptyEnvelope();
                break;
            }
            Assert.IsTrue(m_gp.Connected, "State error");
            IWriteValue m_writeVal = m_gp.GetEmptyWriteDataBuffor(m_block, int.MaxValue);

            m_writeVal.WriteValue(int.MaxValue, 0);
            switch (m_gp.WriteData(ref m_writeVal, byte.MaxValue))
            {
            case AL_ReadData_Result.ALRes_DatTransferErrr:
            case AL_ReadData_Result.ALRes_DisInd:
                Assert.Fail("incorrect return value from ReadData");
                break;

            case AL_ReadData_Result.ALRes_Success:
                Assert.IsNull(m_writeVal, "WriteData has not returned the envelope to a pool");
                break;
            }
            Assert.IsTrue(m_gp.Connected, "State error");
            m_gp.DisReq();
            Assert.IsFalse(m_gp.Connected, "State error");
            m_gp.Dispose();
        }