当前位置: 首页>>代码示例>>C#>>正文


C# IHttpClient.Stub方法代码示例

本文整理汇总了C#中IHttpClient.Stub方法的典型用法代码示例。如果您正苦于以下问题:C# IHttpClient.Stub方法的具体用法?C# IHttpClient.Stub怎么用?C# IHttpClient.Stub使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IHttpClient的用法示例。


在下文中一共展示了IHttpClient.Stub方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FixtureSetup

        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock<IHttpClient>();
            Client = new RestSubscriptionClient(HttpClientMock);

            SubscriptionId = 14561;
            SubscriptionFilter = new CfSubscriptionSubscriptionFilter(1, 5, "fromNumber", "toNumber", true);
            Subscription = new CfSubscription(SubscriptionId, true, "endPoint", CfNotificationFormat.Soap,
                CfSubscriptionTriggerEvent.CampaignStarted, SubscriptionFilter);
            SubscriptionRequest = new CfSubscriptionRequest("requestId", Subscription);

            var notificationFormat = EnumeratedMapper.ToSoapEnumerated<NotificationFormat>(Subscription.NotificationFormat.ToString());
            var triggerEvent = EnumeratedMapper.ToSoapEnumerated<SubscriptionTriggerEvent>(Subscription.TriggerEvent.ToString());

            var response = string.Format("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
                        "<r:ResourceReference xmlns=\"http://api.callfire.com/data\" xmlns:r=\"http://api.callfire.com/resource\">" +
                              "<r:Id>{0}</r:Id>" +
                              "<r:Location>https://www.callfire.com/api/1.1/rest/subscription/{0}</r:Location>" +
                        "</r:ResourceReference>", SubscriptionId);

            HttpClientMock
                .Stub(j => j.Send(Arg<string>.Is.Equal("/subscription"), Arg<HttpMethod>.Is.Equal(HttpMethod.Post),
                    Arg<SubscriptionRequest>.Matches(x => x.RequestId == SubscriptionRequest.RequestId &&
                                                          x.Subscription.id == Subscription.Id &&
                                                          x.Subscription.Enabled == Subscription.Enabled &&
                                                          x.Subscription.Endpoint == Subscription.Endpoint &&
                                                          x.Subscription.NotificationFormat == notificationFormat &&
                                                          x.Subscription.TriggerEvent == triggerEvent &&
                                                          x.Subscription.SubscriptionFilter.BroadcastId == SubscriptionFilter.BroadcastId &&
                                                          x.Subscription.SubscriptionFilter.BatchId == SubscriptionFilter.BatchId &&
                                                          x.Subscription.SubscriptionFilter.FromNumber == SubscriptionFilter.FromNumber &&
                                                          x.Subscription.SubscriptionFilter.ToNumber == SubscriptionFilter.ToNumber &&
                                                          x.Subscription.SubscriptionFilter.Inbound == SubscriptionFilter.Inbound)))
                            .Return(response);
        }
开发者ID:vladimir-mhl,项目名称:CallFire-CSharp-SDK,代码行数:35,代码来源:CreateSubscriptionRestClientTest.cs

示例2: FixtureSetup

        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock<IHttpClient>();
            Client = new RestBroadcastClient(HttpClientMock);

            var localTimeZoneRestriction = new CfLocalTimeZoneRestriction(DateTime.Now, DateTime.Now);
            CfResult[] result = { CfResult.Received };
            CfRetryPhoneType[] phoneTypes = { CfRetryPhoneType.FirstNumber };
            var broadcastConfigRestryConfig = new CfBroadcastConfigRetryConfig(1000, 2, result, phoneTypes);
            var expectedTextBroadcastConfig = new CfTextBroadcastConfig(1, DateTime.Now, "fromNumber", localTimeZoneRestriction, broadcastConfigRestryConfig, "Test", CfBigMessageStrategy.DoNotSend);

            ExpectedBroadcast = new CfBroadcast(1894, "broadcast", CfBroadcastStatus.Running, DateTime.Now, CfBroadcastType.Text, expectedTextBroadcastConfig);

            var response = string.Format(
                "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
                "<r:ResourceReference xmlns=\"http://api.callfire.com/data\" xmlns:r=\"http://api.callfire.com/resource\">" +
                "<r:Id>{0}</r:Id>" +
                "<r:Location>https://www.callfire.com/api/1.1/rest/broadcast/{0}</r:Location>" +
                "</r:ResourceReference>", ExpectedBroadcast.Id);

            HttpClientMock
                .Stub(j => j.Send(Arg<string>.Is.Equal("/broadcast"),
                    Arg<HttpMethod>.Is.Equal(HttpMethod.Post),
                    Arg<BroadcastRequest>.Matches(x => x.Broadcast.id == ExpectedBroadcast.Id &&
                                                x.Broadcast.Name == ExpectedBroadcast.Name &&
                                                x.Broadcast.LastModified == ExpectedBroadcast.LastModified &&
                                                x.Broadcast.Status == BroadcastStatus.RUNNING &&
                                                x.Broadcast.Type == BroadcastType.TEXT)))
                .Return(response);
        }
开发者ID:vladimir-mhl,项目名称:CallFire-CSharp-SDK,代码行数:30,代码来源:CreateBroadcastRestClientTests.cs

示例3: FixtureSetup

        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock<IHttpClient>();
            Client = new RestBroadcastClient(HttpClientMock);

            BroadcastScheduleId = 4889;
            CfDaysOfWeek[] daysOfWeek = {CfDaysOfWeek.Monday};
            BroadcastSchedule = new CfBroadcastSchedule(BroadcastScheduleId, DateTime.Now, DateTime.Now, "timeZone", DateTime.Now, DateTime.Now, daysOfWeek);
            CreateBroadcastSchedule = new CfCreateBroadcastSchedule("requestId", BroadcastScheduleId, BroadcastSchedule);

            var response = string.Format(
                "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
                "<r:ResourceReference xmlns=\"http://api.callfire.com/data\" xmlns:r=\"http://api.callfire.com/resource\">" +
                "<r:Id>{0}</r:Id>" +
                "<r:Location>https://www.callfire.com/api/1.1/rest//broadcast/{0}/schedule</r:Location>" +
                "</r:ResourceReference>", BroadcastScheduleId);

            HttpClientMock.Stub(
                j =>
                    j.Send(Arg<string>.Is.Equal(string.Format("/broadcast/{0}/schedule", BroadcastScheduleId)),
                        Arg<HttpMethod>.Is.Equal(HttpMethod.Post),
                        Arg<CreateBroadcastSchedule>.Matches(x => x.RequestId == CreateBroadcastSchedule.RequestId &&
                                                                  x.BroadcastId == CreateBroadcastSchedule.BroadcastId &&
                                                                  x.BroadcastSchedule.id == BroadcastSchedule.Id &&
                                                                  x.BroadcastSchedule.BeginDate == BroadcastSchedule.BeginDate &&
                                                                  x.BroadcastSchedule.EndDate == BroadcastSchedule.EndDate &&
                                                                  x.BroadcastSchedule.TimeZone == BroadcastSchedule.TimeZone &&
                                                                  x.BroadcastSchedule.StartTimeOfDay == BroadcastSchedule.StartTimeOfDay &&
                                                                  x.BroadcastSchedule.StopTimeOfDay == BroadcastSchedule.StopTimeOfDay)))
                .Return(response);
        }
开发者ID:vladimir-mhl,项目名称:CallFire-CSharp-SDK,代码行数:31,代码来源:CreateBroadcastScheduleRestClientTest.cs

示例4: FixtureSetup

        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock<IHttpClient>();
            Client = new RestSubscriptionClient(HttpClientMock);

            SubscriptionId = 1;
            SubscriptionFilter = new CfSubscriptionSubscriptionFilter(1, 5, "fromNumber", "toNumber", true);
            Subscription = new CfSubscription(SubscriptionId, true, "endPoint", CfNotificationFormat.Soap,
                CfSubscriptionTriggerEvent.CampaignStarted, SubscriptionFilter);
            SubscriptionRequest = new CfSubscriptionRequest("requestId", Subscription);

            var notificationFormat = EnumeratedMapper.ToSoapEnumerated<NotificationFormat>(Subscription.NotificationFormat.ToString());
            var triggerEvent = EnumeratedMapper.ToSoapEnumerated<SubscriptionTriggerEvent>(Subscription.TriggerEvent.ToString());

            HttpClientMock
                .Stub(j => j.Send(Arg<string>.Is.Equal(String.Format("/subscription/{0}", SubscriptionId)),
                    Arg<HttpMethod>.Is.Equal(HttpMethod.Put),
                    Arg<SubscriptionRequest>.Matches(x => x.RequestId == SubscriptionRequest.RequestId &&
                                                          x.Subscription.id == Subscription.Id &&
                                                          x.Subscription.Enabled == Subscription.Enabled &&
                                                          x.Subscription.Endpoint == Subscription.Endpoint &&
                                                          x.Subscription.NotificationFormat == notificationFormat &&
                                                          x.Subscription.TriggerEvent == triggerEvent &&
                                                          x.Subscription.SubscriptionFilter.BroadcastId == SubscriptionFilter.BroadcastId &&
                                                          x.Subscription.SubscriptionFilter.BatchId == SubscriptionFilter.BatchId &&
                                                          x.Subscription.SubscriptionFilter.FromNumber == SubscriptionFilter.FromNumber &&
                                                          x.Subscription.SubscriptionFilter.ToNumber == SubscriptionFilter.ToNumber &&
                                                          x.Subscription.SubscriptionFilter.Inbound == SubscriptionFilter.Inbound)))
                .Return(string.Empty);
        }
开发者ID:vladimir-mhl,项目名称:CallFire-CSharp-SDK,代码行数:30,代码来源:UpdateSubscriptionRestClientTest.cs

示例5: FixtureSetup

        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock<IHttpClient>();
            Client = new RestBroadcastClient(HttpClientMock);

            ExpectedQueryBroadcastData = new CfQueryBroadcastData(500, 0, 1);

            ExpectedContactBatch = new CfContactBatch(1, "contactBatch", CfBatchStatus.Active, 2, DateTime.Now, 10, 15);

            var contactBatchArray = new CfContactBatch[1];
            contactBatchArray[0] = ExpectedContactBatch;

            ExpectedContactBatchQueryResult = new CfContactBatchQueryResult(10, contactBatchArray);

            var resource = new ResourceList();
            var array = new ContactBatch[1];
            array[0] = ContactBatchMapper.ToSoapContactBatch(ExpectedContactBatchQueryResult.ContactBatch[0]);
            resource.Resource = array;
            resource.TotalResults = 1;

            var serializer = new XmlSerializer(typeof(ResourceList));
            TextWriter writer = new StringWriter();
            serializer.Serialize(writer, resource);

            HttpClientMock
                .Stub(j => j.Send(Arg<string>.Is.Equal(String.Format("/broadcast/{0}/batch",
                            ExpectedQueryBroadcastData.BroadcastId)),
                            Arg<HttpMethod>.Is.Equal(HttpMethod.Get),
                            Arg<object>.Is.Anything))
                .Return(writer.ToString());
        }
开发者ID:vladimir-mhl,项目名称:CallFire-CSharp-SDK,代码行数:31,代码来源:QueryContactBatchRestClientTest.cs

示例6: FixtureSetup

        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock<IHttpClient>();
            Client = new RestBroadcastClient(HttpClientMock);

            BroadcastId = 1;
            GetBroadcastStats = new CfGetBroadcastStats(BroadcastId, DateTime.Now, DateTime.Now);
            ExpectedUsageStats = new BroadcastStatsUsageStats(5, 5, 2, 10, 2);

            var resultStat = new BroadcastStatsResultStat[1];
            ExpectedResultStat = new BroadcastStatsResultStat("result", 2, 3);
            resultStat[0] = ExpectedResultStat;

            ExpectedActionsStatistics = new BroadcastStatsActionStatistics(2, 0, 10);

            var expectedBroadcastStats = new BroadcastStats(ExpectedUsageStats, resultStat, ExpectedActionsStatistics);

            var resource = new Resource { Resources = expectedBroadcastStats };
            var serializer = new XmlSerializer(typeof(Resource));
            TextWriter writer = new StringWriter();
            serializer.Serialize(writer, resource);

            HttpClientMock
                .Stub(j => j.Send(Arg<string>.Is.Equal(String.Format("/broadcast/{0}/stats", BroadcastId)),
                    Arg<HttpMethod>.Is.Equal(HttpMethod.Get),
                    Arg<object>.Is.Anything))
                .Return(writer.ToString());
        }
开发者ID:vladimir-mhl,项目名称:CallFire-CSharp-SDK,代码行数:28,代码来源:GetBroadcastStatsRestClientTest.cs

示例7: FixtureSetup

        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock<IHttpClient>();
            Client = new RestBroadcastClient(HttpClientMock);

            BroadcastId = 28936;
            const long id = 188717001;
            object[] contactList = { id };
            ExpectedCreateContactBatch = new CfCreateContactBatch("1", BroadcastId, "name", contactList, false);

            var response = string.Format(
               "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
               "<r:ResourceReference xmlns=\"http://api.callfire.com/data\" xmlns:r=\"http://api.callfire.com/resource\">" +
               "<r:Id>{0}</r:Id>" +
               "<r:Location>https://www.callfire.com/api/1.1/rest//broadcast/{0}/batch</r:Location>" +
               "</r:ResourceReference>", BroadcastId);

            HttpClientMock
                .Stub(j => j.Send(Arg<string>.Is.Equal(String.Format("/broadcast/{0}/batch", BroadcastId)),
                    Arg<HttpMethod>.Is.Equal(HttpMethod.Post),
                    Arg<CreateContactBatch>.Matches(x => x.RequestId == ExpectedCreateContactBatch.RequestId &&
                                                         x.BroadcastId == ExpectedCreateContactBatch.BroadcastId &&
                                                         x.Name == ExpectedCreateContactBatch.Name &&
                                                         x.ScrubBroadcastDuplicates == ExpectedCreateContactBatch.ScrubBroadcastDuplicates)))
                .Return(response);
        }
开发者ID:vladimir-mhl,项目名称:CallFire-CSharp-SDK,代码行数:26,代码来源:CreateContactBatchRestClientTest.cs

示例8: FixtureSetup

        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock<IHttpClient>();
            Client = new RestBroadcastClient(HttpClientMock);

            var queryBroadcast = new Broadcast[1];
            BroadcastId = 1;
            BroadcastName = "broadcast";
            BroadcastLastModified = DateTime.Now;
            queryBroadcast[0] = new Broadcast(BroadcastId, BroadcastName, BroadcastStatus.RUNNING, BroadcastLastModified, BroadcastType.IVR, null);

            CfBroadcastType[] broadcastType = { CfBroadcastType.Ivr};
            ExpectedQueryBroadcast = new CfQueryBroadcasts(5, 0, broadcastType, true, "labelName");

            var cfBroadcastQueryResult = new BroadcastQueryResult(1, queryBroadcast);

            var resource = new ResourceList();
            var array = new Broadcast[1];
            array[0] = cfBroadcastQueryResult.Broadcast[0];
            resource.Resource = array;
            resource.TotalResults = 1;

            var serializer = new XmlSerializer(typeof(ResourceList));
            TextWriter writer = new StringWriter();
            serializer.Serialize(writer, resource);

            HttpClientMock
                .Stub(j => j.Send(Arg<string>.Is.Equal(String.Format("/broadcast")),
                    Arg<HttpMethod>.Is.Equal(HttpMethod.Get),
                    Arg<object>.Is.Anything))
                .Return(writer.ToString());
        }
开发者ID:vladimir-mhl,项目名称:CallFire-CSharp-SDK,代码行数:32,代码来源:QueryBroadcastRestClientTest.cs

示例9: FixtureSetup

        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock<IHttpClient>();
            Client = new RestSubscriptionClient(HttpClientMock);

            SubscriptionId = 1;
            
            HttpClientMock
                .Stub(j => j.Send(Arg<string>.Is.Equal(String.Format("/subscription/{0}", SubscriptionId)), Arg<HttpMethod>.Is.Equal(HttpMethod.Delete),
                    Arg<string>.Is.Anything))
                .Return(string.Empty);
        }
开发者ID:okolomiiets,项目名称:CallFire-CSharp-SDK,代码行数:12,代码来源:DeleteSubscriptionRestClientTest.cs

示例10: FixtureSetup

        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock<IHttpClient>();
            Client = new RestBroadcastClient(HttpClientMock);

            BroadcastScheduleId = 1;

            HttpClientMock
                .Stub(j => j.Send(Arg<string>.Is.Equal(String.Format("/broadcast/schedule/{0}", BroadcastScheduleId)),
                    Arg<HttpMethod>.Is.Equal(HttpMethod.Delete),
                    Arg<string>.Is.Anything))
                .Return(string.Empty);
        }
开发者ID:vladimir-mhl,项目名称:CallFire-CSharp-SDK,代码行数:13,代码来源:DeleteBroadcastScheduleRestClientTest.cs

示例11: FixtureSetup

        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock<IHttpClient>();
            Client = new RestBroadcastClient(HttpClientMock);

            ExpectedControlBroadcast = new CfControlBroadcast(1, "123", CfBroadcastCommand.Start, 5);
            
            HttpClientMock
                .Stub(j => j.Send(Arg<string>.Is.Equal("/broadcast"),
                    Arg<HttpMethod>.Is.Equal(HttpMethod.Put),
                    Arg<ControlBroadcast>.Matches(x => x.Id == ExpectedControlBroadcast.Id &&
                                                       x.RequestId == ExpectedControlBroadcast.RequestId &&
                                                       x.Command == BroadcastCommand.START &&
                                                       x.MaxActive == ExpectedControlBroadcast.MaxActive)));
        }
开发者ID:vladimir-mhl,项目名称:CallFire-CSharp-SDK,代码行数:15,代码来源:ControlBroadcastRestClientTests.cs

示例12: FixtureSetup

        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock<IHttpClient>();
            Client = new RestBroadcastClient(HttpClientMock);

            ControlContactBatchId = 1;
            ExpectedControlContactBatch = new CfControlContactBatch(ControlContactBatchId, "controlContactBatch", true);

            HttpClientMock
                .Stub(j => j.Send(Arg<string>.Is.Equal(String.Format("/broadcast/batch/{0}/control", ControlContactBatchId)),
                    Arg<HttpMethod>.Is.Equal(HttpMethod.Put),
                    Arg<ControlContactBatch>.Matches(x => x.Id == ExpectedControlContactBatch.Id &&
                                                          x.Name == ExpectedControlContactBatch.Name &&
                                                          x.Enabled == ExpectedControlContactBatch.Enabled)))
                .Return(string.Empty);
        }
开发者ID:vladimir-mhl,项目名称:CallFire-CSharp-SDK,代码行数:16,代码来源:ControlContactBatchRestClientTest.cs

示例13: FixtureSetup

        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock<IHttpClient>();
            Client = new RestBroadcastClient(HttpClientMock);

            ContactBatchId = 1;
            ExpectedContactBatch = new CfContactBatch(ContactBatchId, "contactBatch", CfBatchStatus.Active, 5, DateTime.Now, 200, 10);

            var contactBatch = ContactBatchMapper.ToSoapContactBatch(ExpectedContactBatch);

            var resource = new Resource { Resources = contactBatch };
            var serializer = new XmlSerializer(typeof(Resource));
            TextWriter writer = new StringWriter();
            serializer.Serialize(writer, resource);

            HttpClientMock
                .Stub(j => j.Send(Arg<string>.Is.Equal(String.Format("/broadcast/batch/{0}", ContactBatchId)),
                    Arg<HttpMethod>.Is.Equal(HttpMethod.Get),
                    Arg<object>.Is.Null))
                .Return(writer.ToString());
        }
开发者ID:vladimir-mhl,项目名称:CallFire-CSharp-SDK,代码行数:21,代码来源:GetContactBatchRestClientTest.cs

示例14: FixtureSetup

        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock<IHttpClient>();
            Client = new RestBroadcastClient(HttpClientMock);

            BroadcastScheduleId = 1;
            CfDaysOfWeek[] daysOfWeek = { CfDaysOfWeek.Monday };
            BroadcastSchedule = new CfBroadcastSchedule(BroadcastScheduleId, DateTime.Now, DateTime.Now, "timeZone", DateTime.Now, DateTime.Now, daysOfWeek);

            var broadcastSchedule = BroadcastScheduleMapper.ToSoapBroadcastSchedule(BroadcastSchedule);

            var resource = new Resource { Resources = broadcastSchedule };
            var serializer = new XmlSerializer(typeof(Resource));
            TextWriter writer = new StringWriter();
            serializer.Serialize(writer, resource);

            HttpClientMock
                .Stub(j => j.Send(Arg<string>.Is.Equal(String.Format("/broadcast/schedule/{0}", BroadcastScheduleId)),
                    Arg<HttpMethod>.Is.Equal(HttpMethod.Get),
                    Arg<object>.Is.Null))
                .Return(writer.ToString());
        }
开发者ID:vladimir-mhl,项目名称:CallFire-CSharp-SDK,代码行数:22,代码来源:GetBroadcastScheduleRestClientTest.cs


注:本文中的IHttpClient.Stub方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。