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); }
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); }
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); }
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); }