Пример #1
0
        public void Test()
        {
            //send invite

            var network = new FakeNetwork();
            var cs1 = new FakeSipContextSource(TestConstants.IpEndPoint1);
            var cs2 = new FakeSipContextSource(TestConstants.IpEndPoint2);

            //var idleState = new IdleState(null);
            //var sendCommand = (IdleSendCommand) idleState.ProcessRequest();

            //var contextSourceMock = new Mock<ISipContextSource>();
            //contextSourceMock.Setup((cs)=> cs.SendTo(It.IsAny<byte[]>(), It.IsAny<IPEndPoint>())).Callback((byte[] bytes, IPEndPoint endPoint) =>
            //                                                                                                   {
            //                                                                                                       var sipContext = ConvertToSipContext(bytes);
            //                                                                                                       idleState.ProcessRequest(sipContext);
            //                                                                                                       network.SendTo();
            //                                                                                                   })
            //cs1.AddToNetwork(network);
            //cs2.AddToNetwork(network);

            //var sipProvider1 = new SipProvider(new SipStack(), cs1);
            ////var sipProvider2 = new SipProvider(new SipStack(), cs2);

            ////sendCommand.Response;
            //var sipProviderMock = new Mock<ISipProvider>();
            //sipProviderMock.Setup((p) => p.ListeningPoint).Returns(new SipListeningPoint(TestConstants.IpEndPoint2));
            ////sipProviderMock.Setup((p) => p.CreateServerDialog(It.IsAny<ISipServerTransaction>())).Returns();
            //var commandFactoryMock = new Mock<ICommandFactory>();
            //bool fired1,fired2,fired3;
            //SoftPhone calleePhone = new SoftPhone(sipProvider1, new SipMessageFactory(), new SipHeaderFactory(), new SipAddressFactory(), new CommandFactory());
            //calleePhone.IncomingCall += CalleePhoneOnIncomingCall;
            //calleePhone.StateChanged += CalleePhoneOnStateChanged;
            //calleePhone.Start();
            //IPhoneLine calleePhoneLine = calleePhone.CreatePhoneLine(new SipAccount());
            //calleePhoneLine.Register();

            //SoftPhone callerPhone = new SoftPhone(sipProvider2, new SipMessageFactory(), new SipHeaderFactory(), new SipAddressFactory(), new CommandFactory());
            //callerPhone.StateChanged += CallerPhoneOnStateChanged;
            //callerPhone.Start();
            //IPhoneCall phoneCall = callerPhone.CreateCall();
            //phoneCall.Invite(TestConstants.IpEndPoint1.ToString());

            //callerPhone.State.Should().BeOfType<RingingState>();
            //calleePhone.State.Should().BeOfType<RingingState>();
            //var softPhone =

            /*simulate receive invite.*/

            /*verify ringingresponse sent*/
            /*verify both caller + callee to ringingstate*/
        }
Пример #2
0
 /// <summary>
 /// Registers itself as a receiver to the network
 /// </summary>
 /// <param name="network"></param>
 public void AddToNetwork(FakeNetwork network)
 {
     _network = network;
     _network.AddReceiver(this.ListeningPoint, FireNewContextReceivedEvent);
 }
Пример #3
0
 /// <summary>
 /// Registers itself as a receiver to the network
 /// </summary>
 /// <param name="network"></param>
 public void AddToNetwork(FakeNetwork network)
 {
     _network = network;
     _network.AddReceiver(this.ListeningPoint, FireNewContextReceivedEvent);
 }
        protected override void Given()
        {
            //create invite that is addresses to the phone's sipuri
            _invite = CreateInviteRequest(_testClientUaUri, _phoneUaUri);
            //create phone that is located at IpEndPoint2
            var phoneCs = new FakeSipContextSource(_phoneUaEndPoint);

            _network = new FakeNetwork();
            _sipProvider1 = new SipProvider(new SipStack(), phoneCs);

            _phone = new SoftPhone(_sipProvider1, new SipMessageFactory(), new SipHeaderFactory(), new SipAddressFactory(), _stateProvider, _timerFactory, new SipListeningPoint(_phoneUaEndPoint));
            phoneCs.AddToNetwork(_network);
            _network.AddReceiver(_testClientUaEndPoint, OnTestClientUaReceive);
            _phone.InternalStateChanged += new EventHandler<EventArgs>(_calleePhone_InternalStateChanged);
            _phone.IncomingCall += new EventHandler<VoipEventArgs<IPhoneCall>>(_calleePhone_IncomingCall);
            _phone.Start();

            GivenOverride();
        }