예제 #1
0
        public void UpdateConferenceTime_AnyCallId_CallNotNull_EndTime()
        {
            // Setup dependence
            var settingMock = new Mock<ISettings>();
            var componentMock = new Mock<IComponents>();
            var repositoryMock = new Mock<IRepository>();
            var uowMock = new Mock<IUnitOfWork>();
            var serviceLocatorMock = new Mock<IServiceLocator>();

            serviceLocatorMock.Setup(r => r.GetInstance<IRepository>())
                .Returns(repositoryMock.Object);
            serviceLocatorMock.Setup(r => r.GetInstance<IUnitOfWork>())
                .Returns(uowMock.Object);
            ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object);
            repositoryMock.Setup(r => r.CreateUnitOfWork()).Returns(uowMock.Object);

            // Arrange data
            Guid callId = Guid.NewGuid();
            bool isCaller = false;
            DateTime now = DateTime.Now;

            Call call = new Call
            {
                Id = callId
            };
            repositoryMock.Setup(r => r.FindById<Call>(callId))
                .Returns(call);

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            CallDto currentCall = callService
                .UpdateConferenceTime(callId, isCaller);

            // Assert
            repositoryMock.Verify(r => r.FindById<Call>(callId));
            uowMock.Verify(u => u.Save());
            Assert.AreEqual(currentCall.EndTime.Value.ToShortDateString(), now.ToShortDateString());
        }
예제 #2
0
        public void UpdateConferenceTime_AnyCallId_CallNull_isCallerFalse()
        {
            // Setup dependence
            var settingMock = new Mock<ISettings>();
            var componentMock = new Mock<IComponents>();
            var uowMock = new Mock<IUnitOfWork>();
            var repositoryMock = new Mock<IRepository>();
            var serviceLocatorMock = new Mock<IServiceLocator>();

            serviceLocatorMock.Setup(r => r.GetInstance<IRepository>())
                .Returns(repositoryMock.Object);
            ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object);

            // Arrange data
            Guid callId = Guid.NewGuid();
            //string receiverSid = "12345";
            bool isCaller = false;

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            CallDto currentCall = callService
                .UpdateConferenceTime(callId, isCaller);

            // Assert
            repositoryMock.Verify(r => r.FindById<Call>(callId));
            Assert.AreEqual(currentCall, null);
        }