Ejemplo n.º 1
0
        public void Test()
        {
            _requestReceived = new ManualResetEvent(false);

            /*setup + start listening*/
            var stub = new SipReceivedMessageProcessorStub(OnRequestReceived, (s,e) => { });

            var listeningPoint = new IPEndPoint(TestConstants.MyIpAddress, 33333);

            var f = new SipFactory();

            var stp = new SmartThreadPool();
            stp.Start();
            var provider = new SipContextSource(listeningPoint, stp);
            provider.AddListener(null);
            provider.Start();

            /*send a message to the listener*/
            var send = new SipRequestBuilder().Build();
            var requestBytes = SipFormatter.FormatMessage(send);

            var udpClient = new UdpClient();
            udpClient.Send(requestBytes, requestBytes.Length, listeningPoint);

            _requestReceived.WaitOne();

            var oc = ObjectComparer.Create();

            var received = stub.Requests.First();
            oc.Compare(received, send);
            Assert.True(oc.Differences.Count == 0, oc.DifferencesString);
        }
Ejemplo n.º 2
0
        public void Test()
        {
            var stub = new SipReceivedMessageProcessorStub(OnRequestReceived, (s,e) => { });

            //var provider = new SipContextSource(_listenerEndPoint);
            provider.AddListener(null);
            provider.Start();

            Thread[] threads = new Thread[ThreadCount];
            for (int i = 0; i < ThreadCount; ++i)
            {
                threads[i] = new Thread(OnSendRequest);
                threads[i].Start(i + 1);
                Thread.Sleep(5);
            }

            if (!_threadsDoneEvent.WaitOne(60000, true))
                Console.WriteLine("Failed to get all responses.");

            foreach (int id in _failedThreads)
                Console.WriteLine("* Failed thread: " + id);
            if (_failedThreads.Count > 0)
                Console.WriteLine("* Total: " + _failedThreads.Count);

            Assert.IsTrue(true);
        }