protected override void When()
        {
            _originalResponse = new SipRequestBuilder().Build().CreateResponse(SipResponseCodes.x200_Ok);
            var bytes = SipFormatter.FormatMessage(_originalResponse);

            _sipResponse = _parser.Parse(new DatagramPacketBuilder().WithDataBytes(bytes).Build()) as SipResponse;
        }
        protected override void Given()
        {
            base.Given();
            SipRequest sipMessage = new SipRequestBuilder().Build();

            _bytes = SipFormatter.FormatMessage(sipMessage);
        }
        protected override void When()
        {
            var ok = _receivedBye.CreateResponse(SipResponseCodes.x200_Ok);

            _network.SendTo(SipFormatter.FormatMessage(ok), _testClientUaEndPoint, _phoneUaEndPoint);
            _waitForOkByeProcessed.WaitOne(TimeSpan.FromSeconds(3));
        }
        protected override void When()
        {
            var response = _receivedInvite.CreateResponse(SipResponseCodes.x487_Request_Terminated);

            _network.SendTo(SipFormatter.FormatMessage(response), _testClientUaEndPoint, _phoneUaEndPoint);
            _waitforProcessed.WaitOne();
        }
        protected override void When()
        {
            var ack = CreateAckRequest(_invite, _okResponse);

            _network.SendTo(SipFormatter.FormatMessage(ack), _testClientUaEndPoint, _phoneUaEndPoint);
            _waitForAckProcessed.WaitOne();
        }
        protected override void When()
        {
            var cancelRequest = CreateCancelRequest(_invite);

            _network.SendTo(SipFormatter.FormatMessage(cancelRequest), _testClientUaEndPoint, _phoneUaEndPoint);
            WaitHandle.WaitAll(waitHandles, 2000 * 100);
        }
        private static void OnSendRequest(object state)
        {
            var id     = (int)state;
            var client = new UdpClient();

            Interlocked.Increment(ref _currentThreadCount);
            //if (_currentThreadCount == ThreadCount)
            //    _threadsGoEvent.Set();

            //// thread should wait until all threads are ready, to try the server.
            //if (!_threadsGoEvent.WaitOne(60000, true))
            //    Assert.False(true, "Start event was not triggered.");

            var request = new SipRequestBuilder().WithCSeq(new SipCSeqHeaderBuilder().WithSequence(id).Build()).Build();

            try
            {
                var bytes = SipFormatter.FormatMessage(request);
                client.Send(bytes, bytes.Length, _listenerEndPoint);
            }
            catch (Exception e)
            {
                Console.WriteLine("failed to send: " + id);
                lock (_failedThreads) _failedThreads.Add(id);
            }
        }
Exemple #8
0
        protected override void When()
        {
            _originalRequest = new SipRequestBuilder().Build();
            var bytes = SipFormatter.FormatMessage(_originalRequest);

            _sipMessage = _parser.Parse(new DatagramPacketBuilder().WithDataBytes(bytes).Build()) as SipRequest;
        }
        protected override void When()
        {
            var ok = _receivedCancel.CreateResponse(SipResponseCodes.x481_Call_Transaction_Does_Not_Exist);

            _network.SendTo(SipFormatter.FormatMessage(ok), _testClientUaEndPoint, _phoneUaEndPoint);
            _waitforProcessed.WaitOne();
        }
        protected override void When()
        {
            var bye = CreateByeRequest(_invite, _receivedRingingResponse);

            _network.SendTo(SipFormatter.FormatMessage(bye), TestConstants.IpEndPoint1, TestConstants.IpEndPoint2);

            _waitForByeReceived.WaitOne();
        }
        protected override void GivenOverride()
        {
            _network.SendTo(SipFormatter.FormatMessage(_invite), TestConstants.IpEndPoint1, TestConstants.IpEndPoint2);
            _wait.WaitOne(TimeSpan.FromMilliseconds(_longtimeSpan + 500));
            //_wait.WaitOne();

            _phone.InternalState.Should().Be(_stateProvider.GetRinging()); /*required assertion*/
        }
        protected override void When()
        {
            _toTag = SipUtil.CreateTag();
            var provResponse = CreateResponse(_receivedInvite, _toTag, SipResponseCodes.x486_Busy_Here);

            _network.SendTo(SipFormatter.FormatMessage(provResponse), _testClientUaEndPoint, _phoneUaEndPoint);
            _waitingforResponseProcessed.WaitOne();
        }
Exemple #13
0
        protected override void When()
        {
            _toTag = SipUtil.CreateTag();
            var provResponse = CreateRingingResponse(_receivedInvite, _toTag);

            _network.SendTo(SipFormatter.FormatMessage(provResponse), _testClientUaEndPoint, _phoneUaEndPoint);
            _ringingProcessed.WaitOne();
        }
Exemple #14
0
        protected override void When()
        {
            /*send ok to cancel*/
            var ok = _receivedCancel.CreateResponse(SipResponseCodes.x200_Ok);

            _network.SendTo(SipFormatter.FormatMessage(ok), _testClientUaEndPoint, _phoneUaEndPoint);
            _waitforOkProcessed.WaitOne();
        }
        protected override void When()
        {
            _call.Stop();
            var ringing = CreateRingingResponse(_receivedInvite, SipUtil.CreateTag());

            _network.SendTo(SipFormatter.FormatMessage(ringing), _testClientUaEndPoint, _phoneUaEndPoint);
            _waitingforRingingProcessed.WaitOne();
        }
Exemple #16
0
        protected override void When()
        {
            var provResponse = CreateOkResponse(_receivedInvite, _toTag);

            _network.SendTo(SipFormatter.FormatMessage(provResponse), _testClientUaEndPoint, _phoneUaEndPoint);
            _waitingforOkProcessed.WaitOne();
            _waitingForAckReceived.WaitOne(3000); /*test also if ack is received by testclient.*/
        }
Exemple #17
0
        protected override void When()
        {
            _network.SendTo(SipFormatter.FormatMessage(_invite), TestConstants.IpEndPoint1, TestConstants.IpEndPoint2);
            Thread.Sleep(TimeSpan.FromSeconds(1));
            _network.SendTo(SipFormatter.FormatMessage(_invite), TestConstants.IpEndPoint1, TestConstants.IpEndPoint2);

            _wait.WaitOne(TimeSpan.FromSeconds(1));
            // _wait.WaitOne(); /*debug*/
        }
 protected override void GivenOverride()
 {
     _network.SendTo(SipFormatter.FormatMessage(_invite), _testClientUaEndPoint, _phoneUaEndPoint);
     _waitingforInviteProcessed.WaitOne();
     _phone.InternalState.Should().Be(_stateProvider.GetRinging()); /*required assertion*/
     _incomingCall.Accept();
     _waitingforOkReceived.WaitOne();
     _phone.InternalState.Should().Be(_stateProvider.GetWaitForAck()); /*required assertion*/
 }
Exemple #19
0
        protected override void Given()
        {
            base.Given();

            _originalBody = new DataBytesBuilder().WithText("body").Build();
            var sipMessage = new SipRequestBuilder()
                             .WithBody(_originalBody)
                             .WithContentLength(4).Build();

            _bytes = SipFormatter.FormatMessage(sipMessage);
        }
Exemple #20
0
        protected override void Given()
        {
            base.Given();

            _vias = new SipViaHeaderListBuilder()
                    .Add(new SipViaHeaderBuilder().WithSentBy(TestConstants.IpEndPoint1).Build())
                    .Add(new SipViaHeaderBuilder().WithSentBy(TestConstants.IpEndPoint2).Build()).Build();
            var sipMessage = new SipRequestBuilder()
                             .WithNoHeaders()
                             .WithVias(_vias).Build();

            _bytes = SipFormatter.FormatMessage(sipMessage);
        }
Exemple #21
0
        protected override void GivenOverride()
        {
            _network.SendTo(SipFormatter.FormatMessage(_invite), _testClientUaEndPoint, _phoneUaEndPoint);
            _waitingforInviteProcessed.WaitOne();
            _phone.InternalState.Should().Be(_stateProvider.GetRinging());    /*required assertion*/
            _incomingCall.Accept();
            _phone.InternalState.Should().Be(_stateProvider.GetWaitForAck()); /*required assertion*/
            _waitingforOkReceived.WaitOne();
            var ack = CreateAckRequest(_invite, _receivedRingingResponse);

            _network.SendTo(SipFormatter.FormatMessage(ack), _testClientUaEndPoint, _phoneUaEndPoint);
            _waitForAckProcessed.WaitOne();
            _phone.InternalState.Should().Be(_stateProvider.GetEstablished()); /*required assertion*/
            _incomingCall.Stop();
            _phone.InternalState.Should().Be(_stateProvider.GetWaitByeOk());   /*required assertion*/
            _waitForByeReceived.WaitOne();
        }
Exemple #22
0
        protected override void GivenOverride()
        {
            _call = _phone.CreateCall();
            _call.CallStateChanged += call_CallStateChanged;
            _call.Start(_testClientUaUri.FormatToString());

            _waitingforInviteReceived.WaitOne();
            _phone.InternalState.Should().Be(_stateProvider.GetWaitProvisional()); /*required assertion*/

            _toTag = SipUtil.CreateTag();
            var provResponse = CreateRingingResponse(_receivedInvite, _toTag);

            _network.SendTo(SipFormatter.FormatMessage(provResponse), _testClientUaEndPoint, _phoneUaEndPoint);
            _ringingProcessed.WaitOne();

            _phone.InternalState.Should().Be(_stateProvider.GetWaitFinal()); /*required assertion*/
        }
Exemple #23
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);
        }
Exemple #24
0
 protected override void GivenOverride()
 {
     _network.SendTo(SipFormatter.FormatMessage(_invite), _testClientUaEndPoint, _phoneUaEndPoint);
     _waitingforInviteReceived.WaitOne(TimeSpan.FromSeconds(3));
     _phone.InternalState.Should().Be(_stateProvider.GetRinging()); /*required assertion*/
 }
Exemple #25
0
        private void SendRingingToPhone()
        {
            var provResponse = CreateResponse(_receivedInvite, _toTag, SipResponseCodes.x181_Call_Forwarded);

            _network.SendTo(SipFormatter.FormatMessage(provResponse), _testClientUaEndPoint, _phoneUaEndPoint);
        }