public async System.Threading.Tasks.Task ShouldListWorkersStatisticsUsingFilters()
        {
            RestRequest savedRequest = null;

            var tcs = new TaskCompletionSource <WorkersStatistics>();

            tcs.SetResult(new WorkersStatistics());

            mockClient.Setup(trc => trc.Execute <WorkersStatistics>(It.IsAny <RestRequest>()))
            .Callback <RestRequest>((request) => savedRequest = request)
            .Returns(tcs.Task);
            var client        = mockClient.Object;
            var friendlyName  = Twilio.Api.Tests.Utilities.MakeRandomFriendlyName();
            var minutes       = 10;
            var taskQueueSid  = "WQ123";
            var taskQueueName = Twilio.Api.Tests.Utilities.MakeRandomFriendlyName();
            var options       = new WorkersStatisticsRequest();

            options.Minutes       = minutes;
            options.FriendlyName  = friendlyName;
            options.TaskQueueSid  = taskQueueSid;
            options.TaskQueueName = taskQueueName;

            await client.ListWorkersStatisticsAsync(WORKSPACE_SID, options);

            mockClient.Verify(trc => trc.Execute <WorkersStatistics>(It.IsAny <RestRequest>()), Times.Once);
            Assert.IsNotNull(savedRequest);
            Assert.AreEqual("Workspaces/{WorkspaceSid}/Workers/Statistics", savedRequest.Resource);
            Assert.AreEqual("GET", savedRequest.Method);
            Assert.AreEqual(5, savedRequest.Parameters.Count);
            var workspaceSidParam = savedRequest.Parameters.Find(x => x.Name == "WorkspaceSid");

            Assert.IsNotNull(workspaceSidParam);
            Assert.AreEqual(WORKSPACE_SID, workspaceSidParam.Value);
            var friendlyNameParam = savedRequest.Parameters.Find(x => x.Name == "FriendlyName");

            Assert.IsNotNull(friendlyNameParam);
            Assert.AreEqual(friendlyName, friendlyNameParam.Value);
            var taskQueueSidParam = savedRequest.Parameters.Find(x => x.Name == "TaskQueueSid");

            Assert.IsNotNull(taskQueueSidParam);
            Assert.AreEqual(taskQueueSid, taskQueueSidParam.Value);
            var taskQueueNameParam = savedRequest.Parameters.Find(x => x.Name == "TaskQueueName");

            Assert.IsNotNull(taskQueueNameParam);
            Assert.AreEqual(taskQueueName, taskQueueNameParam.Value);
            var minutesParam = savedRequest.Parameters.Find(x => x.Name == "Minutes");

            Assert.IsNotNull(minutesParam);
            Assert.AreEqual(minutes, minutesParam.Value);
        }
        public void ShouldListWorkersStatisticsUsingFiltersAsynchronously()
        {
            RestRequest savedRequest = null;

            mockClient.Setup(trc => trc.ExecuteAsync <WorkersStatistics>(It.IsAny <RestRequest>(), It.IsAny <Action <WorkersStatistics> >()))
            .Callback <RestRequest, Action <WorkersStatistics> >((request, action) => savedRequest = request);
            var client = mockClient.Object;

            manualResetEvent = new ManualResetEvent(false);
            var options = new WorkersStatisticsRequest();

            options.FriendlyName  = Twilio.Api.Tests.Utilities.MakeRandomFriendlyName();
            options.Minutes       = 10;
            options.TaskQueueSid  = "WQ123";
            options.TaskQueueName = Twilio.Api.Tests.Utilities.MakeRandomFriendlyName();;

            client.ListWorkersStatistics(WORKSPACE_SID, options, stats => {
                manualResetEvent.Set();
            });

            mockClient.Verify(trc => trc.ExecuteAsync <WorkersStatistics>(It.IsAny <RestRequest>(), It.IsAny <Action <WorkersStatistics> >()), Times.Once);
            Assert.IsNotNull(savedRequest);
            Assert.AreEqual("Workspaces/{WorkspaceSid}/Workers/Statistics", savedRequest.Resource);
            Assert.AreEqual("GET", savedRequest.Method);
            Assert.AreEqual(5, savedRequest.Parameters.Count);
            var workspaceSidParam = savedRequest.Parameters.Find(x => x.Name == "WorkspaceSid");

            Assert.IsNotNull(workspaceSidParam);
            Assert.AreEqual(WORKSPACE_SID, workspaceSidParam.Value);
            var friendlyNameParam = savedRequest.Parameters.Find(x => x.Name == "FriendlyName");

            Assert.IsNotNull(friendlyNameParam);
            Assert.AreEqual(options.FriendlyName, friendlyNameParam.Value);
            var taskQueueSidParam = savedRequest.Parameters.Find(x => x.Name == "TaskQueueSid");

            Assert.IsNotNull(taskQueueSidParam);
            Assert.AreEqual(options.TaskQueueSid, taskQueueSidParam.Value);
            var taskQueueNameParam = savedRequest.Parameters.Find(x => x.Name == "TaskQueueName");

            Assert.IsNotNull(taskQueueNameParam);
            Assert.AreEqual(options.TaskQueueName, taskQueueNameParam.Value);
            var minutesParam = savedRequest.Parameters.Find(x => x.Name == "Minutes");

            Assert.IsNotNull(minutesParam);
            Assert.AreEqual(options.Minutes, minutesParam.Value);
        }
        public void ShouldListWorkersStatisticsUsingFilters()
        {
            IRestRequest savedRequest = null;
            mockClient.Setup(trc => trc.Execute<WorkersStatistics>(It.IsAny<IRestRequest>()))
                .Callback<IRestRequest>((request) => savedRequest = request)
                .Returns(new WorkersStatistics());
            var client = mockClient.Object;
            var friendlyName = Utilities.MakeRandomFriendlyName();
            var minutes = 10;
            var taskQueueSid = "WQ123";
            var taskQueueName = Utilities.MakeRandomFriendlyName ();
            var options = new WorkersStatisticsRequest();
            options.Minutes = minutes;
            options.FriendlyName = friendlyName;
            options.TaskQueueSid = taskQueueSid;
            options.TaskQueueName = taskQueueName;

            client.ListWorkersStatistics(WORKSPACE_SID, options);

            mockClient.Verify(trc => trc.Execute<WorkersStatistics>(It.IsAny<IRestRequest>()), Times.Once);
            Assert.IsNotNull(savedRequest);
            Assert.AreEqual("Workspaces/{WorkspaceSid}/Workers/Statistics", savedRequest.Resource);
            Assert.AreEqual(Method.GET, savedRequest.Method);
            Assert.AreEqual(5, savedRequest.Parameters.Count);
            var workspaceSidParam = savedRequest.Parameters.Find(x => x.Name == "WorkspaceSid");
            Assert.IsNotNull (workspaceSidParam);
            Assert.AreEqual (WORKSPACE_SID, workspaceSidParam.Value);
            var friendlyNameParam = savedRequest.Parameters.Find(x => x.Name == "FriendlyName");
            Assert.IsNotNull (friendlyNameParam);
            Assert.AreEqual (friendlyName, friendlyNameParam.Value);
            var taskQueueSidParam = savedRequest.Parameters.Find(x => x.Name == "TaskQueueSid");
            Assert.IsNotNull (taskQueueSidParam);
            Assert.AreEqual (taskQueueSid, taskQueueSidParam.Value);
            var taskQueueNameParam = savedRequest.Parameters.Find(x => x.Name == "TaskQueueName");
            Assert.IsNotNull (taskQueueNameParam);
            Assert.AreEqual (taskQueueName, taskQueueNameParam.Value);
            var minutesParam = savedRequest.Parameters.Find(x => x.Name == "Minutes");
            Assert.IsNotNull(minutesParam);
            Assert.AreEqual(minutes, minutesParam.Value);
        }
Пример #4
0
        public void ShouldListWorkersStatisticsUsingFiltersAsynchronously()
        {
            IRestRequest savedRequest = null;
            mockClient.Setup(trc => trc.ExecuteAsync<WorkersStatistics>(It.IsAny<IRestRequest>(), It.IsAny<Action<WorkersStatistics>>()))
                .Callback<IRestRequest, Action<WorkersStatistics>>((request, action) => savedRequest = request);
            var client = mockClient.Object;
            manualResetEvent = new ManualResetEvent(false);
            var options = new WorkersStatisticsRequest();
            options.FriendlyName = Utilities.MakeRandomFriendlyName();
            options.Minutes = 10;
            options.TaskQueueSid = "WQ123";
            options.TaskQueueName = Utilities.MakeRandomFriendlyName();;

            client.ListWorkersStatistics(WORKSPACE_SID, options, stats => {
                manualResetEvent.Set();
            });

            mockClient.Verify(trc => trc.ExecuteAsync<WorkersStatistics>(It.IsAny<IRestRequest>(), It.IsAny<Action<WorkersStatistics>>()), Times.Once);
            Assert.IsNotNull(savedRequest);
            Assert.AreEqual("Workspaces/{WorkspaceSid}/Workers/Statistics", savedRequest.Resource);
            Assert.AreEqual(Method.GET, savedRequest.Method);
            Assert.AreEqual(5, savedRequest.Parameters.Count);
            var workspaceSidParam = savedRequest.Parameters.Find(x => x.Name == "WorkspaceSid");
            Assert.IsNotNull (workspaceSidParam);
            Assert.AreEqual (WORKSPACE_SID, workspaceSidParam.Value);
            var friendlyNameParam = savedRequest.Parameters.Find(x => x.Name == "FriendlyName");
            Assert.IsNotNull (friendlyNameParam);
            Assert.AreEqual (options.FriendlyName, friendlyNameParam.Value);
            var taskQueueSidParam = savedRequest.Parameters.Find(x => x.Name == "TaskQueueSid");
            Assert.IsNotNull (taskQueueSidParam);
            Assert.AreEqual (options.TaskQueueSid, taskQueueSidParam.Value);
            var taskQueueNameParam = savedRequest.Parameters.Find(x => x.Name == "TaskQueueName");
            Assert.IsNotNull (taskQueueNameParam);
            Assert.AreEqual (options.TaskQueueName, taskQueueNameParam.Value);
            var minutesParam = savedRequest.Parameters.Find(x => x.Name == "Minutes");
            Assert.IsNotNull(minutesParam);
            Assert.AreEqual(options.Minutes, minutesParam.Value);
        }