public void GivenASendAction_When2PhoneNumbersAreProvided_ThenCallIsCalledTwice() { const string baseUrl = "http://example.com"; string broadcastPlayUrl = $"{baseUrl}/Broadcast/Play?recordingUrl=recording-url"; const string twilioNumber = "twilio-number"; var clientMock = new Mock <IClient>(); var mockPhoneNumbers = new Mock <IPhoneNumbers>(); mockPhoneNumbers.Setup(p => p.Twilio).Returns("twilio-number"); var mockCustomRequest = new Mock <ICustomRequest>(); mockCustomRequest.Setup(r => r.Url).Returns(baseUrl); var controller = new BroadcastController( clientMock.Object, mockPhoneNumbers.Object, mockCustomRequest.Object ) { Url = Url }; controller.WithCallTo(c => c.Send("phone-one, phone-two", "recording-url")) .ShouldRenderView("Send"); clientMock.Verify(c => c.Call("phone-one", twilioNumber, broadcastPlayUrl)); clientMock.Verify(c => c.Call("phone-two", twilioNumber, broadcastPlayUrl)); }
public void GivenAnIndexAction_ThenRenderTheDefaultView() { var controller = new BroadcastController(); controller.WithCallTo(c => c.Index()) .ShouldRenderDefaultView(); }
public void GivenAPlayAction_ThenTheResponseContainsPlay() { var controller = new BroadcastController(); const string recordUrl = "record-url"; var result = controller.Play(recordUrl); result.ExecuteResult(MockControllerContext.Object); var document = BuildDocument(); Assert.That(document.SelectSingleNode("Response/Play").InnerText, Is.EqualTo(recordUrl)); }
public void GivenASendAction_When2PhoneNumbersAreProvided_ThenCallIsCalledTwice() { var mockClient = new Mock <IClient>(); mockClient.Setup(c => c.Call(It.IsAny <CallOptions>())); var mockPhoneNumbers = new Mock <IPhoneNumbers>(); mockPhoneNumbers.Setup(p => p.Twilio).Returns("twilio-number"); var mockCustomRequest = new Mock <ICustomRequest>(); mockCustomRequest.Setup(r => r.Url).Returns("http://example.com"); var controller = new BroadcastController( mockClient.Object, mockPhoneNumbers.Object, mockCustomRequest.Object) { Url = Url }; controller.Send("phone-one, phone-two", "recording-url"); mockClient.Verify(c => c.Call(It.IsAny <CallOptions>()), Times.Exactly(2)); }
public ActionResult Approve(int ID) { var actionCodes = RoleModuleMappingService.Instance.GetActionCodesOfModule(User.Identity.Name, ModuleRoleConstants.Module_LeaveRequest); var hasViewAccess = actionCodes.Data.Contains(ModuleRoleConstants.ActionView); var hasUpdateAccess = actionCodes.Data.Contains(ModuleRoleConstants.ActionUpdate); if (!hasViewAccess || !hasUpdateAccess) { this.ShowMessage(false, "", ModuleRoleConstants.NoAccessErrorMsg); return(View("Index")); } ViewBag.Title = "Leave Approval"; var model = new List <LeaveApplicationObj>(); bool isSuccess = false; try { var result = LeaveService.Instance.ApproveLeaveApplication(ID); if (result.IsSuccess) { isSuccess = true; ViewBag.IsShowSuccessfullMessage = true; ViewBag.Message = string.Format("Leave application {0} to {1} has been approved.", result.Data.StartDate.ToString("yyyy-MM-dd"), result.Data.EndDate.ToString("yyyy-MM-dd")); var leaveRecord = LeaveService.Instance.GetLeaveApplication(ID); if (leaveRecord.IsSuccess) { var broadCastRecord = BroadcastService.Instance.GetBusCaptainGCMID(leaveRecord.Data.PersonnelNumber); var err = GoogleNotification.CallGoogleAPI(broadCastRecord.Data.GcmID, "Leave Approval", ViewBag.Message); var broadcast = new BroadcastController(); bool apnsErr = AppleNotification.Push(broadCastRecord.Data.GcmID, ViewBag.Message); if (err != "") { _log.ErrorFormat("error while doing google notification on leave approval"); } } else { ViewBag.IsShowErrorMessage = true; ViewBag.Message = leaveRecord.ErrorInfo; } } else { ViewBag.IsShowErrorMessage = true; ViewBag.Message = result.ErrorInfo; } } catch (Exception ex) { ViewBag.IsShowErrorMessage = true; ViewBag.Message = this.CleanJavaScriptString(ex.ToString()); _log.Error(ex); } BusCaptainService.Instance.saveActivity(Activities.LeaveApprove.ToString(), User.Identity.Name, "", "", isSuccess, ID); return(View("Index", model)); }
protected void HandleBroadcastStateChanged(BroadcastController.BroadcastState state) { }
public StreamCallbackListener(BroadcastController controller) : base(controller) { }
protected ControllerAccess(BroadcastController controller) { m_BroadcastController = controller; }