Exemplo n.º 1
0
        public async void IsInCall_ShouldBeFalse_AfterCallIsClosed()
        {
            var callerId = Guid.NewGuid();

            Mock <IServiceFactory> serviceFactoryMock = new Mock <IServiceFactory>();

            serviceFactoryMock.Setup(s =>
                                     s.CreateClient <ITelephonyService>()
                                     .CloseCall(callerId))
            .Returns(true);
            var eventMock = new Mock <IEventAggregator>();

            PhoneViewModel phoneViewModel = new PhoneViewModel(serviceFactoryMock.Object);

            phoneViewModel._eventAggregator = eventMock.Object;
            var callerInfo = new CallerInfo
            {
                CallerId     = callerId,
                CallerName   = "Jon Doe",
                CallerNumber = 98608900
            };

            phoneViewModel.LoadCaller(callerInfo);

            await phoneViewModel.CloseCallCommand.Execute(callerInfo);

            Assert.False(phoneViewModel.IsInCall);
        }
Exemplo n.º 2
0
        public void CloseCall_ShouldSendHangupToserver_WhenCalledInCall()
        {
            var callerId = Guid.NewGuid();
            var didRunCallClosecommand = false;

            Mock <IServiceFactory> serviceFactoryMock = new Mock <IServiceFactory>();

            serviceFactoryMock.Setup(d =>
                                     d.CreateClient <ITelephonyService>()
                                     .CloseCall(callerId))
            .Callback(() => didRunCallClosecommand = true);

            var eventMock = new Mock <IEventAggregator>();

            PhoneViewModel phoneViewModel = new PhoneViewModel(serviceFactoryMock.Object);

            phoneViewModel._eventAggregator = eventMock.Object;

            var callerInfo = new CallerInfo
            {
                CallerId     = callerId,
                CallerName   = "Jon Doe",
                CallerNumber = 98608900
            };

            phoneViewModel.LoadCaller(callerInfo);

            phoneViewModel.CloseCallCommand.Execute(callerInfo);

            Assert.True(didRunCallClosecommand);
        }
Exemplo n.º 3
0
        public void LoadCaller_ShouldloadCaller_AndPopulateFields()
        {
            Mock <IServiceFactory> serviceFactoryMock = new Mock <IServiceFactory>();
            var eventMock = new Mock <IEventAggregator>();

            PhoneViewModel phoneViewModel = new PhoneViewModel(serviceFactoryMock.Object);

            phoneViewModel._eventAggregator = eventMock.Object;

            var callerInfo = new CallerInfo
            {
                CallerId     = Guid.NewGuid(),
                CallerName   = "Jon Doe",
                CallerNumber = 98608900
            };

            phoneViewModel.LoadCaller(callerInfo);

            Assert.True(phoneViewModel.Caller == callerInfo, "Caller was not loaded into Caller field");
        }
Exemplo n.º 4
0
        public void IsInCall_ShouldBeTrue_WhenCallerInfoIsPressent()
        {
            Mock <IServiceFactory> serviceFactoryMock = new Mock <IServiceFactory>();
            var eventMock = new Mock <IEventAggregator>();

            PhoneViewModel phoneViewModel = new PhoneViewModel(serviceFactoryMock.Object);

            phoneViewModel._eventAggregator = eventMock.Object;

            var callerInfo = new CallerInfo
            {
                CallerId     = Guid.NewGuid(),
                CallerName   = "Jon Doe",
                CallerNumber = 98608900
            };

            Assert.False(phoneViewModel.IsInCall, "phoneViewModel.IsInCall is true, when Caller is not present");

            phoneViewModel.LoadCaller(callerInfo);

            Assert.True(phoneViewModel.IsInCall, "phoneViewModel.IsInCall is false, when Caller is present");
        }
Exemplo n.º 5
0
        public void CallerLoaded_ShouldPublish_OpenCallerEvent()
        {
            var callerInfo = new CallerInfo
            {
                CallerId     = Guid.NewGuid(),
                CallerName   = "Jon Doe",
                CallerNumber = 98608900
            };

            var serviceFactoryMock  = new Mock <IServiceFactory>();
            var eventMock           = new Mock <OpenCallerViewEvent>();
            var eventAggregatorMock = new Mock <IEventAggregator>();

            eventAggregatorMock.Setup(aggregator => aggregator.GetEvent <OpenCallerViewEvent>())
            .Returns(eventMock.Object);


            var phoneViewModel = new PhoneViewModel(serviceFactoryMock.Object);

            phoneViewModel._eventAggregator = eventAggregatorMock.Object;
            phoneViewModel.LoadCaller(callerInfo);

            eventMock.Verify(e => e.Publish(callerInfo.CallerId), Times.Once);
        }