コード例 #1
0
        public void CheckCallInStatus_AnyCallIds_IsCallerTrue()
        {
            // 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 id = Guid.NewGuid();
            bool expectedResult = true;
            string status = "Pending";
            bool isCaller = true;
            Call call = new Call
            {
                Id = id,
                CallerStatus = status
            };
            repositoryMock.Setup(r => r.FindById<Call>(id)).Returns(call);

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            bool currentResult = callService.CheckCallInStatus(id, status, isCaller);

            // Assert
            repositoryMock.Verify(r => r.FindById<Call>(id));
            Assert.AreEqual(expectedResult, currentResult);
        }
コード例 #2
0
        public void UpdateCallFails_AnyBookingIds()
        {
            // 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 id = Guid.NewGuid();
            Booking booking = new Booking { Id = id };
            repositoryMock.Setup(r => r.FindById<Booking>(id)).Returns(booking);

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            callService.UpdateCallFails(id);

            // Assert
            repositoryMock.Verify(r => r.FindById<Booking>(id));
            repositoryMock.Verify(r => r.Update<Booking>(
                It.Is<Booking>(b => b.Id == id)));
            uowMock.Verify(u => u.Save());
        }
コード例 #3
0
        public void ReceiverReady_AnyCallIds_True()
        {
            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
            Guid id = Guid.NewGuid();
            Call call = new Call
            {
                Id = id,
                ReceiverReady = true
            };
            repositoryMock.Setup(r => r.FindById<Call>(id)).Returns(call);
            bool expectedResult = true;

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object,
                settingMock.Object, componentMock.Object);
            bool currentResult = callService.ReceiverReady(id);

            // Assert
            repositoryMock.Verify(r => r.FindById<Call>(id));
            Assert.AreEqual(expectedResult, currentResult);
        }
コード例 #4
0
        public void ReceiverReady_AnyCallIds_Null()
        {
            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>();

            ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object);

            // Arrange
            Guid id = Guid.NewGuid();
            Call call = new Call
            {
                Id = id,
                ReceiverReady = true
            };

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object,
                settingMock.Object, componentMock.Object);
            bool currentResult = callService.ReceiverReady(id);
        }
コード例 #5
0
        public void CreateFeedbackAndRating_AnyCallId_AnyCustomerId_AnySpecialistId_True()
        {
            // Setup dependence
            var settingMock = new Mock<ISettings>();
            var componentMock = new Mock<IComponents>();
            var repositoryMock = new Mock<IRepository>();
            var serviceLocatorMock = new Mock<IServiceLocator>();
            var uowMock = new Mock<IUnitOfWork>();

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

            // Arrange data
            Guid id = Guid.NewGuid();
            bool expectedResult = true;

            string feedBack = "feedback";
            int? start = 4;
            Call call = new Call
            {
                Id = id
            };
            repositoryMock.Setup(r => r.FindById<Call>(id)).Returns(call);
            repositoryMock.Setup(r => r.CreateUnitOfWork()).Returns(uowMock.Object);

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            bool currentResult = callService.CreateFeedbackAndRating(id, id, id, feedBack, start);

            // Assert
            repositoryMock.Verify(r => r.FindById<Call>(id));
            repositoryMock.Verify(r => r.Update<Call>(It.Is<Call>(c=>c.Rating == start
                && c.Feedback.Equals(feedBack))));
            uowMock.Verify(u=>u.Save());
            Assert.AreEqual(expectedResult, currentResult);
        }
コード例 #6
0
        public void UpdateCallStatus_CallNull_ReceiverSid()
        {
            // 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
            string receiverSid = "12345";
            string status = "queued";
            Call call = new Call
            {
                Id = Guid.NewGuid(),
                ReceiverSid = string.Empty
            };
            Call[] calls = new Call[] { call };
            repositoryMock.Setup(r => r.Query<Call>()).Returns(calls.AsQueryable());

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            CallDto currentCall = callService.UpdateCallStatus(receiverSid, status);

            // Assert
            Assert.AreEqual(currentCall, null);
        }
コード例 #7
0
        public void UpdateCallStatus_CallNotNull_CallSid()
        {
            // 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
            string callSid = "12345";
            string callerStatus = "queued";
            Call call = new Call
            {
                Id = Guid.NewGuid(),
                CallerSid = callSid
            };
            Call[] calls = new Call[] { call };
            repositoryMock.Setup(r => r.Query<Call>()).Returns(calls.AsQueryable());

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            CallDto currentCall = callService.UpdateCallStatus(callSid, callerStatus);

            // Assert
            repositoryMock.Verify(r => r.Query<Call>());
            uowMock.Verify(u => u.Save());
            Assert.AreEqual(currentCall.CallerStatus, callerStatus);
        }
コード例 #8
0
        public void UpdateCallStatus_AnyCallIds_CallNotNull_IsCallerTrue()
        {
            // 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();
            string callerStatus = "queued";
            bool isCaller = true;

            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.UpdateCallStatus(callId, callerStatus, isCaller);

            // Assert
            repositoryMock.Verify(r => r.FindById<Call>(callId));
            uowMock.Verify(u => u.Save());
            Assert.AreEqual(currentCall.CallerStatus, callerStatus);
        }
コード例 #9
0
        public void GetCallInProgressByCallerId_AnyIds_CallerStatusQueued()
        {
            // 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 id = Guid.NewGuid();
            string callerStatus = "queued";
            Call call = new Call
            {
                Id = Guid.NewGuid(),
                CallerStatus = callerStatus,
                Caller = new User { Id = id }
            };
            Call[] calls = new Call[] { call };
            repositoryMock.Setup(r => r.Query<Call>()).Returns(calls.AsQueryable());

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            var currentCall = callService.GetCallByCallerIdAndStatus(id, callerStatus);

            // Assert
            Assert.AreEqual(call.Caller.Id, currentCall.Caller.Id);
        }
コード例 #10
0
        public void GetCallFails_AnyBookIds()
        {
            // 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 id = Guid.NewGuid();
            Booking book = new Booking
            {
                Id = id
            };
            Booking[] books = new Booking[] { book };
            repositoryMock.Setup(r => r.FindById<Booking>(id)).Returns(book);

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            var currentCall = callService.GetCallFails(id);

            // Assert
            repositoryMock.Verify(r => r.FindById<Booking>(id));
        }
コード例 #11
0
        public void GetByCallSid_CallId()
        {
            // 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
            string receiverSid = string.Empty;
            repositoryMock.Setup(r => r.Query<Call>())
                .Returns(new List<Call>().AsQueryable());

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object,
                settingMock.Object, componentMock.Object);
            callService.GetByCallSid(string.Empty);

            // Assert
            repositoryMock.Verify(r => r.Query<Call>());
        }
コード例 #12
0
        public void GetByBookingId_AnyIds()
        {
            // 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 id = Guid.NewGuid();
            Call call = new Call
            {
                Id = Guid.NewGuid(),
                Booking = new Booking
                {
                    Id = id
                }
            };
            Call[] calls = new Call[] { call };
            repositoryMock.Setup(r => r.Query<Call>()).Returns(calls.AsQueryable());

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            callService.GetByBookingId(id);

            // Assert
            repositoryMock.Verify(r => r.Query<Call>());
        }
コード例 #13
0
        public void Create_CallDto()
        {
            // 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

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            var currentCall = callService.Create(new CallDto());

            // Assert
            repositoryMock.Verify(r => r.Insert<Call>(It.IsAny<Call>()));
            uowMock.Verify(u => u.Save());
        }
コード例 #14
0
        public void Update_CallDto()
        {
            // 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 id = Guid.NewGuid();
            CallDto callDto = new CallDto { Id = id };
            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            var currentCall = callService.Update(callDto);

            // Assert
            repositoryMock.Verify(r => r.Update<Call>(
                It.Is<Call>(b => b.Id == id)));
            uowMock.Verify(u => u.Save());
        }
コード例 #15
0
        public void UpdateImageUrlById_AnyCallIds_AnyUrl_True()
        {
            // Setup dependence
            var settingMock = new Mock<ISettings>();
            var componentMock = new Mock<IComponents>();
            var repositoryMock = new Mock<IRepository>();
            var serviceLocatorMock = new Mock<IServiceLocator>();
            var uowMock = new Mock<IUnitOfWork>();

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

            // Arrange data
            Guid id = Guid.NewGuid();
            string imageUrl = "feedback";
            bool expectedResult = true;

            Call call = new Call
            {
                Id = id
            };
            repositoryMock.Setup(r => r.FindById<Call>(id)).Returns(call);
            repositoryMock.Setup(r => r.CreateUnitOfWork()).Returns(uowMock.Object);

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            bool currentResult = callService.UpdateImageUrlById(id, imageUrl);

            // Assert
            repositoryMock.Verify(r => r.FindById<Call>(id));
            repositoryMock.Verify(r => r.Update<Call>(It.Is<Call>(
                c => c.ImageUrl.Equals(imageUrl))));
            uowMock.Verify(u => u.Save());
            Assert.AreEqual(expectedResult, currentResult);
        }
コード例 #16
0
        public void UpdateCallFails_NotFoundBookingIds()
        {
            // 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 id = Guid.NewGuid();

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            callService.UpdateCallFails(id);
        }
コード例 #17
0
        public void UpdateCallSid_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
                .UpdateCallSid(callId, receiverSid, isCaller);

            // Assert
            repositoryMock.Verify(r => r.FindById<Call>(callId));
            Assert.AreEqual(currentCall, null);
        }
コード例 #18
0
        public void Get_GuidId()
        {
            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);

            Guid id = Guid.NewGuid();

            repositoryMock.Setup(r => r.FindById<Call>(id)).Returns(new Call());

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object,
                settingMock.Object, componentMock.Object);
            callService.Get(id);

            // Assert
            repositoryMock.Verify(r => r.FindById<Call>(id));
        }
コード例 #19
0
        public void UpdateCallStatus_AnyCallIds_CallNull()
        {
            // 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 callerStatus = "queued";
            bool isCaller = false;

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

            // Assert
            Assert.AreEqual(currentCall, null);
        }
コード例 #20
0
        public void ReceiverReadyNow_AnyCallIds()
        {
            // 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 id = Guid.NewGuid();
            bool expectedResult = true;
            Call call = new Call
            {
                Id = id
            };
            repositoryMock.Setup(r => r.FindById<Call>(id)).Returns(call);

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            CallDto currentCall = callService.ReceiverReadyNow(id);

            // Assert
            repositoryMock.Verify(r => r.FindById<Call>(id));
            repositoryMock.Verify(r => r.Update<Call>(It.IsAny<Call>()));
            uowMock.Verify(u => u.Save());
            Assert.AreEqual(expectedResult, currentCall.ReceiverReady);
        }
コード例 #21
0
        public void CreateFeedbackAndRating_AnyCallId_AnyCustomerId_AnySpecialistId_False()
        {
            // 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 id = Guid.NewGuid();
            string feedBack = "feedback";
            int? start = 4;
            bool expectedResult = false;

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            bool currentResult = callService.CreateFeedbackAndRating(id, id, id, feedBack, start);

            // Assert
            Assert.AreEqual(expectedResult, currentResult);
        }
コード例 #22
0
        public void ReceiverReadyNow_AnyCallIds_CallNull()
        {
            // 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);
            ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object);

            // Arrange data
            Guid id = Guid.NewGuid();

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            CallDto currentCall = callService.ReceiverReadyNow(id);

            // Assert
            repositoryMock.Verify(r => r.FindById<Call>(id));
            Assert.AreEqual(null, currentCall);
        }
コード例 #23
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());
        }
コード例 #24
0
        public void UpdateImageUrlById_AnyCallIds_AnyUrl_False()
        {
            // 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);
            ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object);

            // Arrange data
            Guid id = Guid.NewGuid();
            string imageUrl = "feedback";
            bool expectedResult = false;

            // Act
            CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object);
            bool currentResult = callService.UpdateImageUrlById(id, imageUrl);

            // Assert
            Assert.AreEqual(expectedResult, currentResult);
        }