Ejemplo n.º 1
0
        public void can_FakeResponse_with_an_IResponse_globally()
        {
            var requestor = new Requestor(RootUrl);
            requestor.DisableRealRequests();
            Should.Throw<RealRequestsDisabledException>(() => requestor.Get("/"));

            Requestor.Global.FakeResponse("GET", "http://localhost:3000/", new Response {
                Status  = 400,
                Body    = "Something Global Blew Up",
                Headers = new Vars {{"Foo","Bar"}}
            });

            requestor.Get("/");
            requestor.LastResponse.Status.ShouldEqual(400);
            requestor.LastResponse.Body.ShouldEqual("Something Global Blew Up");
            requestor.LastResponse.Headers["Foo"].ShouldEqual("Bar");

            // works again, because no maximum number of requests was set ...
            requestor.Get("/");

            // blows up for any different url/path
            Should.Throw<RealRequestsDisabledException>("Real requests are disabled. GET http://localhost:3000/different", () => {
                requestor.Get("/different");
            });
        }
Ejemplo n.º 2
0
 public StripeService(string apiKey = null)
 {
     ApiKey = apiKey;
     Mapper = new Mapper();
     Requestor = new Requestor(Mapper);
     ParameterBuilder = new ParameterBuilder();
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            try
            {
                PerfArguments perfArgs = new PerfArguments(args);
                if (args.Length == 0 || Arguments.IsHelp(perfArgs.Operation))
                {
                    Usage();
                    return;
                }

                if (perfArgs.TraceLevel != 0)
                {
                    Trace.TraceLevel = perfArgs.TraceLevel;
                    Trace.TraceListener = (f, o) => Console.WriteLine(DateTime.Now.ToString("[hh:mm:ss.fff]") + " " + string.Format(f, o));
                }

                Role role;
                if (string.Equals("send", perfArgs.Operation, StringComparison.OrdinalIgnoreCase))
                {
                    role = new Sender(perfArgs);
                }
                else if (string.Equals("receive", perfArgs.Operation, StringComparison.OrdinalIgnoreCase))
                {
                    role = new Receiver(perfArgs);
                }
                else if (string.Equals("request", perfArgs.Operation, StringComparison.OrdinalIgnoreCase))
                {
                    role = new Requestor(perfArgs);
                }
                else if (string.Equals("reply", perfArgs.Operation, StringComparison.OrdinalIgnoreCase))
                {
                    role = new ReplyListener(perfArgs);
                }
                else if (string.Equals("listen", perfArgs.Operation, StringComparison.OrdinalIgnoreCase))
                {
                    role = new Listener(perfArgs);
                }
                else
                {
                    throw new ArgumentException(perfArgs.Operation);
                }

                Console.WriteLine("Running perf test...");
                role.Run();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Ejemplo n.º 4
0
        public void can_get_last_response()
        {
            var requestor = new Requestor(RootUrl);
            requestor.LastResponse.Should(Be.Null);

            requestor.Get("/");
            requestor.LastResponse.ShouldNot(Be.Null);
            requestor.LastResponse.Status.ShouldEqual(200);
            requestor.LastResponse.Body.ShouldEqual("Hello World");

            requestor.Get("/info");
            requestor.LastResponse.ShouldNot(Be.Null);
            requestor.LastResponse.Status.ShouldEqual(200);
            requestor.LastResponse.Body.ShouldContain("GET /info");
        }
Ejemplo n.º 5
0
        public void can_specify_a_number_of_times_that_the_fake_response_should_be_returned()
        {
            var requestor = new Requestor(RootUrl);

            // once globally
            requestor.Get("/foo").Body.ShouldEqual("Not Found: GET /foo");
            Requestor.Global.FakeResponseOnce("GET", "http://localhost:3000/foo", new Response { Body = "Foo!" });
            requestor.Get("/foo").Body.ShouldEqual("Foo!");
            requestor.Get("/foo").Body.ShouldEqual("Not Found: GET /foo");

            // twice globally
            requestor.Get("/foo").Body.ShouldEqual("Not Found: GET /foo");
            Requestor.Global.FakeResponse(2, "GET", "http://localhost:3000/foo", new Response { Body = "Foo!" });
            requestor.Get("/foo").Body.ShouldEqual("Foo!");
            requestor.Get("/foo").Body.ShouldEqual("Foo!");
            requestor.Get("/foo").Body.ShouldEqual("Not Found: GET /foo");

            // once on instance
            requestor.Get("/foo").Body.ShouldEqual("Not Found: GET /foo");
            requestor.FakeResponseOnce("GET", "http://localhost:3000/foo", new Response { Body = "Foo!" });
            requestor.Get("/foo").Body.ShouldEqual("Foo!");
            requestor.Get("/foo").Body.ShouldEqual("Not Found: GET /foo");

            // 3 times on instance
            requestor.Get("/foo").Body.ShouldEqual("Not Found: GET /foo");
            requestor.FakeResponse(3, "GET", "http://localhost:3000/foo", new Response { Body = "Foo!" });
            requestor.Get("/foo").Body.ShouldEqual("Foo!");
            requestor.Get("/foo").Body.ShouldEqual("Foo!");
            requestor.Get("/foo").Body.ShouldEqual("Foo!");
            requestor.Get("/foo").Body.ShouldEqual("Not Found: GET /foo");

            // once globally, once on instance (both will happen)
            requestor.Get("/foo").Body.ShouldEqual("Not Found: GET /foo");
            Requestor.Global.FakeResponseOnce("GET", "http://localhost:3000/foo", new Response { Body = "Foo!" });
            requestor.FakeResponseOnce("GET", "http://localhost:3000/foo", new Response { Body = "Foo!" });
            requestor.Get("/foo").Body.ShouldEqual("Foo!");
            requestor.Get("/foo").Body.ShouldEqual("Foo!");
            requestor.Get("/foo").Body.ShouldEqual("Not Found: GET /foo");
        }
Ejemplo n.º 6
0
        public IList<MemoryStream> GetBytes(Protocol local, Requestor requestor)
        {
            if (local == null) throw new ArgumentNullException("local");
            if (requestor == null) throw new ArgumentNullException("requestor");

            if (requestBytes == null)
            {
                using (var bbo = new ByteBufferOutputStream())
                {
                    var o = new BinaryEncoder(bbo);

                    // use local protocol to write request
                    Message m = GetMessage(local);
                    Context.Message = m;

                    requestor.WriteRequest(m.Request, request, o); // write request payload

                    o.Flush();
                    List<MemoryStream> payload = bbo.GetBufferList();

                    requestor.WriteHandshake(o); // prepend handshake if needed

                    Context.RequestPayload = payload;

                    IDictionary<string, object> responseCallMeta = Context.ResponseCallMeta;
                    Requestor.MetaWriter.Write(responseCallMeta, o);

                    o.WriteString(m.Name); // write message name
                    o.Flush();

                    bbo.Append(payload);

                    requestBytes = bbo.GetBufferList();
                }
            }

            return requestBytes;
        }
Ejemplo n.º 7
0
        public void can_set_Implementation_on_instance_or_globally()
        {
            // global default
            Requestor.Global.Implementation = null;
            Requestor.DefaultIRequestor = typeof(RequestorA); // TODO move this to Requestor.Global, cause that's where everything else is ...
            new Requestor().Get("/").Body.ShouldEqual("RequestorA.GetResponse(GET, /)");

            // instance implementation
            var requestor = new Requestor();
            requestor.Implementation = new RequestorB();
            requestor.Get("/").Body.ShouldEqual("RequestorB.GetResponse(GET, /)");
            new Requestor().Get("/").Body.ShouldEqual("RequestorA.GetResponse(GET, /)"); // other instances still use A [the global default]

            // global implementation
            Requestor.Global.Implementation = new RequestorC();
            new Requestor().Get("/").Body.ShouldEqual("RequestorC.GetResponse(GET, /)");
            requestor = new Requestor();
            requestor.Get("/").Body.ShouldEqual("RequestorC.GetResponse(GET, /)");

            // override with instance implementation
            requestor.Implementation = new RequestorB(); // override global and set it back to B
            requestor.Get("/").Body.ShouldEqual("RequestorB.GetResponse(GET, /)");
            new Requestor().Get("/").Body.ShouldEqual("RequestorC.GetResponse(GET, /)"); // other instances still use C [the global implementation]
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Begin a new asynchornous ListMessageSummaryRequest
        /// </summary>
        /// <param name="requestData"></param>
        /// <returns></returns>
        public async Task <ListMessageSummaryResponse> ListMessageSummaryRequestAsync(ListMessageSummaryRequest requestData)
        {
            var res = await Requestor.PostStringAsync(Urls.ListMessageSummaryRequest, JsonHelper.SerializeData(requestData));

            return(JsonConvert.DeserializeObject <ListMessageSummaryResponse>(res.ResponseJson));
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Begin a new AccountDetailsRequest
 /// </summary>
 /// <param name="requestData"></param>
 /// <returns></returns>
 public AccountDetailsResponse AccountDetailsRequest(AccountDetailsRequest requestData)
 {
     return(JsonConvert.DeserializeObject <AccountDetailsResponse>(Requestor.PostString(Urls.AccountDetailsRequest, JsonHelper.SerializeData(requestData)).ResponseJson));
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Begin a new asynchornous ChangeUserDetailsRequest
        /// </summary>
        /// <param name="requestData"></param>
        /// <returns></returns>
        public async Task <GameSparksBasePlayerResponse> ChangeUserDetailsRequestAsync(ChangeUserDetailsRequest requestData)
        {
            var res = await Requestor.PostStringAsync(Urls.ChangeUserDetailsRequest, JsonHelper.SerializeData(requestData));

            return(JsonConvert.DeserializeObject <GameSparksBasePlayerResponse>(res.ResponseJson));
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Begin a new UpdateMessageRequest
 /// </summary>
 /// <param name="requestData"></param>
 /// <returns></returns>
 public GameSparksBasePlayerResponse UpdateMessageRequest(UpdateMessageRequest requestData)
 {
     return(JsonConvert.DeserializeObject <GameSparksBasePlayerResponse>(Requestor.PostString(Urls.UpdateMessageRequest, JsonHelper.SerializeData(requestData)).ResponseJson));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Begin a new ListTransactionsRequest
 /// </summary>
 /// <param name="requestData"></param>
 /// <returns></returns>
 public ListTransactionsResponse ListTransactionsRequest(ListTransactionsRequest requestData)
 {
     return(JsonConvert.DeserializeObject <ListTransactionsResponse>(Requestor.PostString(Urls.ListTransactionsRequest, JsonHelper.SerializeData(requestData)).ResponseJson));
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 余额提现列表查询
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="listParams"></param>
        /// <returns></returns>
        public WithdrawalList List(string appId, Dictionary <string, object> listParams)
        {
            var url = Requestor.FormatUrl(string.Format("{0}/{1}/withdrawals", BaseUrl, appId), Requestor.CreateQuery(listParams));
            var wd  = base.DoRequest(url, "GET");

            return(Mapper <WithdrawalList> .MapFromJson(wd));
        }
Ejemplo n.º 14
0
 //Sync
 public virtual SpaceClient Create(string organizationId, SpaceClientCreateOptions client)
 {
     return(Mapper <SpaceClient> .MapFromJson(
                Requestor.Post(client, $"{Urls.Organizations}/{organizationId}/clients")
                ));
 }
Ejemplo n.º 15
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as PaymentReconciliation;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.FinancialResourceStatusCodes>)StatusElement.DeepCopy();
            }
            if (Period != null)
            {
                dest.Period = (Hl7.Fhir.Model.Period)Period.DeepCopy();
            }
            if (CreatedElement != null)
            {
                dest.CreatedElement = (Hl7.Fhir.Model.FhirDateTime)CreatedElement.DeepCopy();
            }
            if (PaymentIssuer != null)
            {
                dest.PaymentIssuer = (Hl7.Fhir.Model.ResourceReference)PaymentIssuer.DeepCopy();
            }
            if (Request != null)
            {
                dest.Request = (Hl7.Fhir.Model.ResourceReference)Request.DeepCopy();
            }
            if (Requestor != null)
            {
                dest.Requestor = (Hl7.Fhir.Model.ResourceReference)Requestor.DeepCopy();
            }
            if (OutcomeElement != null)
            {
                dest.OutcomeElement = (Code <Hl7.Fhir.Model.ClaimProcessingCodes>)OutcomeElement.DeepCopy();
            }
            if (DispositionElement != null)
            {
                dest.DispositionElement = (Hl7.Fhir.Model.FhirString)DispositionElement.DeepCopy();
            }
            if (PaymentDateElement != null)
            {
                dest.PaymentDateElement = (Hl7.Fhir.Model.Date)PaymentDateElement.DeepCopy();
            }
            if (PaymentAmount != null)
            {
                dest.PaymentAmount = (Hl7.Fhir.Model.Money)PaymentAmount.DeepCopy();
            }
            if (PaymentIdentifier != null)
            {
                dest.PaymentIdentifier = (Hl7.Fhir.Model.Identifier)PaymentIdentifier.DeepCopy();
            }
            if (Detail != null)
            {
                dest.Detail = new List <Hl7.Fhir.Model.PaymentReconciliation.DetailsComponent>(Detail.DeepCopy());
            }
            if (FormCode != null)
            {
                dest.FormCode = (Hl7.Fhir.Model.CodeableConcept)FormCode.DeepCopy();
            }
            if (ProcessNote != null)
            {
                dest.ProcessNote = new List <Hl7.Fhir.Model.PaymentReconciliation.NotesComponent>(ProcessNote.DeepCopy());
            }
            return(dest);
        }
Ejemplo n.º 16
0
        public static async Task <Customer> Create(Dictionary <string, object> cusParams)
        {
            var cus = await Requestor.DoRequest(BaseUrl, "POST", cusParams);

            return(Mapper <Customer> .MapFromJson(cus));
        }
Ejemplo n.º 17
0
        public static Transfer Create(Dictionary <string, object> trParams)
        {
            var transfer = Requestor.DoRequest(BaseUrl, "POST", trParams);

            return(Mapper <Transfer> .MapFromJson(transfer));
        }
Ejemplo n.º 18
0
        public static async Task <RefundList> List(string id, Dictionary <string, object> listParams = null)
        {
            var url        = Requestor.FormatUrl(string.Format("/v1/charges/{0}/refunds", id), Requestor.CreateQuery(listParams));
            var refundList = await Requestor.DoRequest(url, "Get");

            return(Mapper <RefundList> .MapFromJson(refundList));
        }
 public AccountOperations(Requestor requestor)
 {
     _requestor = requestor;
 }
Ejemplo n.º 20
0
        public virtual async void Delete(string planId)
        {
            var url = string.Format("{0}/{1}", Urls.Plans, planId);

            await Requestor.Delete(url);
        }
 public virtual async Task <SpaceAccount> DetailsAsync(string accountId, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(Mapper <SpaceAccount> .MapFromJson(
                await Requestor.GetAsync($"{Urls.Accounts}/{accountId}", cancellationToken)
                ));
 }
Ejemplo n.º 22
0
        public RechargeList List(string appId, Dictionary <string, object> listParams = null)
        {
            var rechargeList = base.DoRequest(Requestor.FormatUrl(string.Format(BaseUrl, appId), Requestor.CreateQuery(listParams)), "GET");

            return(Mapper <RechargeList> .MapFromJson(rechargeList));
        }
Ejemplo n.º 23
0
 public virtual SpaceClient Edit(string clientId, SpaceClientEditOptions client)
 {
     return(Mapper <SpaceClient> .MapFromJson(
                Requestor.Put(client, $"{Urls.Clients}/{clientId}")
                ));
 }
Ejemplo n.º 24
0
 public abstract void EditRequestor(Requestor requestor);
Ejemplo n.º 25
0
 public HomeController()
 {
     this.request = new Requestor(this);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Begin a new SocialDisconnectRequest
 /// </summary>
 /// <param name="requestData"></param>
 /// <returns></returns>
 public GameSparksBasePlayerResponse SocialDisconnectRequest(SocialDisconnectRequest requestData)
 {
     return(JsonConvert.DeserializeObject <GameSparksBasePlayerResponse>(Requestor.PostString(Urls.SocialDisconnectRequest, JsonHelper.SerializeData(requestData)).ResponseJson));
 }
Ejemplo n.º 27
0
 public LanguageAccess(Requestor requestor) : base(requestor, "T_REF_Languages")
 {
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Begin a new asynchornous AccountDetailsRequest
        /// </summary>
        /// <param name="requestData"></param>
        /// <returns></returns>
        public async Task <AccountDetailsResponse> AccountDetailsRequestAsync(AccountDetailsRequest requestData)
        {
            var res = await Requestor.PostStringAsync(Urls.AccountDetailsRequest, JsonHelper.SerializeData(requestData));

            return(JsonConvert.DeserializeObject <AccountDetailsResponse>(res.ResponseJson));
        }
Ejemplo n.º 29
0
 public async static Task UploadAsync(CancellationToken cancellationToken, int?customerId, int?externalAccountId, string documentType, string documentName, byte[] documentContent, string reasonType, Connection connection = null, object userDefinedObjectForLogging = null)
 {
     connection = connection ?? Connection.CreateFromConfig();
     var body = new { CustomerId = customerId, ExternalAccountId = externalAccountId, DocumentType = documentType, DocumentName = documentName, DocumentContent = Convert.ToBase64String(documentContent), ReasonType = reasonType };
     var rv   = await Requestor.PostAsync <CustomerIdOnly>(cancellationToken, "externalaccountdocument/upload", connection, body, userDefinedObjectForLogging);
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Begin a new asynchornous DismissMessageRequest
        /// </summary>
        /// <param name="requestData"></param>
        /// <returns></returns>
        public async Task <GameSparksBasePlayerResponse> DismissMessageRequestAsync(DismissMessageRequest requestData)
        {
            var res = await Requestor.PostStringAsync(Urls.DismissMessageRequest, JsonHelper.SerializeData(requestData));

            return(JsonConvert.DeserializeObject <GameSparksBasePlayerResponse>(res.ResponseJson));
        }
Ejemplo n.º 31
0
        /// <summary>
        /// 查询订单退款列表
        /// </summary>
        /// <param name="orId"></param>
        /// <param name="listParams"></param>
        /// <returns></returns>
        public RefundList List(string orId, Dictionary <string, object> listParams = null)
        {
            var refundList = base.DoRequest(Requestor.FormatUrl(string.Format("/v1/orders/{0}/order_refunds", orId), Requestor.CreateQuery(listParams)), "Get");

            return(Mapper <RefundList> .MapFromJson(refundList));
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Begin a new asynchornous DismissMultipleMessagesRequest
        /// </summary>
        /// <param name="requestData"></param>
        /// <returns></returns>
        public async Task <DismissMultipleMessagesResponse> DismissMultipleMessagesRequestAsync(DismissMultipleMessagesRequest requestData)
        {
            var res = await Requestor.PostStringAsync(Urls.DismissMultipleMessagesRequest, JsonHelper.SerializeData(requestData));

            return(JsonConvert.DeserializeObject <DismissMultipleMessagesResponse>(res.ResponseJson));
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Creates shiny new queues that are not referenced / altered by other methods.
        /// </summary>
        /// <returns></returns>
        private Company NewCompany()
        {
            Company expected = new Company();
            expected.Address1 = "addy1";
            expected.Address2 = "addy2";
            expected.City = "some city";
            expected.ContactNumber1 = "444-444-4444";
            expected.ContactNumber2 = "322-333-3333";
            expected.Name = "New Company";
            expected.ParentId = 0;
            expected.State = "TN";
            expected.Website = "www.sworps.com";
            expected.Zip_Code = "33333-3333";

            //Complex objects...

            Requestor MainReq = new Requestor();
            MainReq.ContactNumber = "555-555-5555";
            MainReq.Email = "*****@*****.**";
            MainReq.FirstName = "nathan 1";
            MainReq.LastName = "bleivns 1";
            HelpdeskService.CreateRequestor(MainReq);

            expected.MainContact = MainReq;

            Requestor SecReq = new Requestor();
            SecReq.ContactNumber = "555-222-5555";
            SecReq.Email = "*****@*****.**";
            SecReq.FirstName = "nathan 2";
            SecReq.LastName = "bleivns 2";
            HelpdeskService.CreateRequestor(SecReq);

            expected.SecondaryContact = SecReq;

            return expected;
        }
Ejemplo n.º 34
0
 public static void CreateRequestor(Requestor requestor)
 {
     LoadProviders(); _provider.CreateRequestor(requestor);
 }
Ejemplo n.º 35
0
        public int Eval(string text)
        {
            var request = Requestor.Invoke(aorServer, "eval", text);

            return(int.Parse(request));
        }
Ejemplo n.º 36
0
        public void can_set_RootUrl_on_instance_or_globally()
        {
            var requestor = new Requestor();
            requestor.RootUrl.Should(Be.Null);

            // trying to do a GET to a relative path without a RootUrl will cause an exception
            var message = "HttpRequestor.GetResponse failed for: GET /foo.  This url generated a System.Net.FileWebRequest instead of a HttpWebRequest.";
            var response = requestor.Get("/foo"); // <--- this doesn't raise an exception, but returns null
            response.Should(Be.Null);
            requestor.LastException.Should(Be.AssignableFrom(typeof(Exception)));
            requestor.LastException.Message.ShouldContain(message);

            // if we switch to our SimpleRequestor, tho, we're OK
            Requestor.Global.Implementation = new SimpleRequestor();
            requestor.Get("/foo").Body.ShouldEqual("You requested: GET /foo"); // <-- no RootUrl

            // if we pass the full path, it works
            requestor.Get("http://localhost:3000/").Body.ShouldEqual("You requested: GET http://localhost:3000/");

            // set RootUrl globally
            Requestor.Global.RootUrl = "http://google.com";
            requestor.RootUrl.ShouldEqual("http://google.com");
            requestor.Get("/foo").Body.ShouldEqual("You requested: GET http://google.com/foo");

            // override on instance
            requestor.RootUrl = "http://yahoo.com";
            requestor.RootUrl.ShouldEqual("http://yahoo.com");
            requestor.Get("/foo").Body.ShouldEqual("You requested: GET http://yahoo.com/foo");
            new Requestor().Get("/foo").Body.ShouldEqual("You requested: GET http://google.com/foo"); // new still gets global

            // if we pass the full path, it still works, even with a RootUrl
            requestor.Get("http://localhost:3000/").Body.ShouldEqual("You requested: GET http://localhost:3000/");
        }
Ejemplo n.º 37
0
        public void FakeResponse_is_returned_even_if_real_requests_are_enabled()
        {
            var requestor = new Requestor(RootUrl);
            requestor.Get("/").Body.ShouldEqual("Hello World");
            requestor.Get("/foo").Body.ShouldEqual("Not Found: GET /foo");
            requestor.Get("/bar").Body.ShouldEqual("Not Found: GET /bar");

            // fake globally
            Requestor.Global.FakeResponse("GET", "http://localhost:3000/foo", new Response { Body = "Foo!" });
            requestor.Get("/").Body.ShouldEqual("Hello World");
            requestor.Get("/foo").Body.ShouldEqual("Foo!");
            requestor.Get("/bar").Body.ShouldEqual("Not Found: GET /bar");

            // override on instance
            requestor.FakeResponse("GET", "http://localhost:3000/foo", new Response { Body = "Foo via Instance" });
            requestor.Get("/").Body.ShouldEqual("Hello World");
            requestor.Get("/foo").Body.ShouldEqual("Foo via Instance");
            requestor.Get("/bar").Body.ShouldEqual("Not Found: GET /bar");
            new Requestor(RootUrl).Get("/foo").Body.ShouldEqual("Foo!"); // <--- new requestor uses the global fake response

            // fake another on instance
            requestor.FakeResponse("GET", "http://localhost:3000/bar", new Response { Body = "BAR" });
            requestor.Get("/").Body.ShouldEqual("Hello World");
            requestor.Get("/foo").Body.ShouldEqual("Foo via Instance");
            requestor.Get("/bar").Body.ShouldEqual("BAR");

            // if you disable real connections, the fake responses still work, but not the real ones ...
            requestor.DisableRealRequests();
            requestor.Get("/foo").Body.ShouldEqual("Foo via Instance");
            requestor.Get("/bar").Body.ShouldEqual("BAR");
            Should.Throw<RealRequestsDisabledException>("Real requests are disabled. GET http://localhost:3000/", () => {
                requestor.Get("/");
            });
        }
Ejemplo n.º 38
0
        /// <summary>
        /// 创建分润结算对象
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public static RoyaltySettlement Create(Dictionary <string, object> param)
        {
            var royaltySettlement = Requestor.DoRequest(BaseUrl, "POST", param);

            return(Mapper <RoyaltySettlement> .MapFromJson(royaltySettlement));
        }
        public async Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
        {
            oprot.IncrementRecursionDepth();
            try
            {
                var struc = new TStruct("GroupByRequest");
                await oprot.WriteStructBeginAsync(struc, cancellationToken);

                var field = new TField();
                field.Name = "path";
                field.Type = TType.String;
                field.ID   = 1;
                await oprot.WriteFieldBeginAsync(field, cancellationToken);

                await oprot.WriteStringAsync(Path, cancellationToken);

                await oprot.WriteFieldEndAsync(cancellationToken);

                field.Name = "dataTypeOrdinal";
                field.Type = TType.I32;
                field.ID   = 2;
                await oprot.WriteFieldBeginAsync(field, cancellationToken);

                await oprot.WriteI32Async(DataTypeOrdinal, cancellationToken);

                await oprot.WriteFieldEndAsync(cancellationToken);

                if (TimeFilterBytes != null && __isset.timeFilterBytes)
                {
                    field.Name = "timeFilterBytes";
                    field.Type = TType.String;
                    field.ID   = 3;
                    await oprot.WriteFieldBeginAsync(field, cancellationToken);

                    await oprot.WriteBinaryAsync(TimeFilterBytes, cancellationToken);

                    await oprot.WriteFieldEndAsync(cancellationToken);
                }
                field.Name = "queryId";
                field.Type = TType.I64;
                field.ID   = 4;
                await oprot.WriteFieldBeginAsync(field, cancellationToken);

                await oprot.WriteI64Async(QueryId, cancellationToken);

                await oprot.WriteFieldEndAsync(cancellationToken);

                field.Name = "aggregationTypeOrdinals";
                field.Type = TType.List;
                field.ID   = 5;
                await oprot.WriteFieldBeginAsync(field, cancellationToken);

                {
                    await oprot.WriteListBeginAsync(new TList(TType.I32, AggregationTypeOrdinals.Count), cancellationToken);

                    foreach (int _iter43 in AggregationTypeOrdinals)
                    {
                        await oprot.WriteI32Async(_iter43, cancellationToken);
                    }
                    await oprot.WriteListEndAsync(cancellationToken);
                }
                await oprot.WriteFieldEndAsync(cancellationToken);

                field.Name = "header";
                field.Type = TType.Struct;
                field.ID   = 6;
                await oprot.WriteFieldBeginAsync(field, cancellationToken);

                await Header.WriteAsync(oprot, cancellationToken);

                await oprot.WriteFieldEndAsync(cancellationToken);

                field.Name = "requestor";
                field.Type = TType.Struct;
                field.ID   = 7;
                await oprot.WriteFieldBeginAsync(field, cancellationToken);

                await Requestor.WriteAsync(oprot, cancellationToken);

                await oprot.WriteFieldEndAsync(cancellationToken);

                field.Name = "deviceMeasurements";
                field.Type = TType.Set;
                field.ID   = 8;
                await oprot.WriteFieldBeginAsync(field, cancellationToken);

                {
                    await oprot.WriteSetBeginAsync(new TSet(TType.String, DeviceMeasurements.Count), cancellationToken);

                    foreach (string _iter44 in DeviceMeasurements)
                    {
                        await oprot.WriteStringAsync(_iter44, cancellationToken);
                    }
                    await oprot.WriteSetEndAsync(cancellationToken);
                }
                await oprot.WriteFieldEndAsync(cancellationToken);

                await oprot.WriteFieldStopAsync(cancellationToken);

                await oprot.WriteStructEndAsync(cancellationToken);
            }
            finally
            {
                oprot.DecrementRecursionDepth();
            }
        }
Ejemplo n.º 40
0
 public static void EditRequestor(Requestor requestor)
 {
     LoadProviders(); _provider.EditRequestor(requestor);
 }
Ejemplo n.º 41
0
        public static Charge Create(Dictionary <string, object> chParams)
        {
            var ch = Requestor.DoRequest(BaseUrl, "POST", chParams);

            return(Mapper <Charge> .MapFromJson(ch));
        }
Ejemplo n.º 42
0
        /// <summary>
        /// Logs an error Amazons Queing Service
        /// </summary>
        public override string Log(Error error)
        {
            string id = string.Empty;
            bool EnableSQSLogging = false;

            try
            {
                EnableSQSLogging = Convert.ToBoolean(ConfigurationManager.AppSettings["EnableSQSLogging"]);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }

            if (EnableSQSLogging)
            {
                if (error == null)
                    throw new ArgumentNullException("error");

                try
                {
                    error.ApplicationName = ApplicationName;
                    string errorXml = ErrorXml.EncodeString(error);

                    requestor = new Requestor();

                    requestor.AwsID             = ConfigurationManager.AppSettings["AwsID"];
                    requestor.AWSSecretKey      = ConfigurationManager.AppSettings["AWSSecretKey"];
                    requestor.Queue             = ConfigurationManager.AppSettings["Queue"];

                    id = requestor.MakeRequest(errorXml);
                }
                catch (Exception ex)
                {
                    throw new ApplicationException(ex.Message);
                }
            }
            return id;
        }
Ejemplo n.º 43
0
        /// <summary>
        /// Creates shiny new requestor that are not referenced / altered by other methods.
        /// </summary>
        /// <returns></returns>
        private Requestor NewRequestor()
        {
            Requestor temp = new Requestor();
            temp.ContactNumber = "444-444-4444";
            temp.Email = "*****@*****.**";
            temp.FirstName = "Nathan";
            temp.LastName = "Blevins";

            return temp;
        }
Ejemplo n.º 44
0
        /// <summary>
        /// Creates shiny new queues that are not referenced / altered by other methods.
        /// </summary>
        /// <returns></returns>
        private Ticket NewTicket()
        {
            //Make the complex objects and retunr their ID.
            TicketQueue que = new TicketQueue(0, "nblevins", "description", "QueueName", TestDate, true);
            HelpdeskService.CreateQueue(que);

            TicketCategory cat = new TicketCategory(0, "Category Name", "Category Description", true, que.QueueId);
            HelpdeskService.CreateCategory(cat);

            TicketModule mod = new TicketModule(0, que.QueueId, "Module Name", "Description", true);
            HelpdeskService.CreateModule(mod);

            Requestor req = new Requestor(0, "nbleivns", "Blevins", "444-444-4444", "*****@*****.**");
            HelpdeskService.CreateRequestor(req);

            TicketStatus stat = new TicketStatus(0, "Status Name", "Description", 1, true);
            HelpdeskService.CreateStatus(stat);

            //Set up the ticket...
            Ticket temp = new Ticket();
            temp.Category = cat;
            temp.CreationDate = TestDate;
            temp.Creator = "nblevins";
            temp.Description = "This is my ticket decription.";
            temp.DueDate = TestDate + new TimeSpan(2, 0, 0);
            temp.Module = mod;
            temp.Priority = TicketPriority.Medium;
            temp.Requestor = req;
            temp.Responses = new TicketResponseCollection();
            temp.Status = stat;
            temp.Assignment = new AssignmentCollection();
            temp.Queue = que;

            //Build the company...

            Company comp = new Company();
            comp.Address1 = "addy1";
            comp.Address2 = "addy2";
            comp.City = "some city";
            comp.ContactNumber1 = "444-444-4444";
            comp.ContactNumber2 = "322-333-3333";
            comp.Name = "New Company";
            comp.ParentId = 0;
            comp.State = "TN";
            comp.Website = "www.sworps.com";
            comp.Zip_Code = "33333-3333";

            Requestor MainReq = new Requestor();
            MainReq.ContactNumber = "555-555-5555";
            MainReq.Email = "*****@*****.**";
            MainReq.FirstName = "nathan 1";
            MainReq.LastName = "bleivns 1";
            HelpdeskService.CreateRequestor(MainReq);

            comp.MainContact = MainReq;

            Requestor SecReq = new Requestor();
            SecReq.ContactNumber = "555-222-5555";
            SecReq.Email = "*****@*****.**";
            SecReq.FirstName = "nathan 2";
            SecReq.LastName = "bleivns 2";
            HelpdeskService.CreateRequestor(SecReq);

            comp.SecondaryContact = SecReq;

            temp.Company = comp;
            return temp;
        }
Ejemplo n.º 45
0
 /// <summary>
 /// Helper method to insert values into the database.  If successful, it will set the appropriate row id.
 /// </summary>
 /// <param name="Module"></param>
 private void InsertRequestorIntoDatabase(Requestor requestor)
 {
     HelpdeskService.CreateRequestor(requestor);
 }
Ejemplo n.º 46
0
            public void can_override_for_an_instance()
            {
                new Requestor(RootUrl).Get("/").Body.ShouldEqual("Hello World");

                Requestor.Global.DisableRealRequests();
                var requestor = new Requestor(RootUrl);
                Should.Throw<RealRequestsDisabledException>("Real requests are disabled. GET http://localhost:3000/", () => {
                    requestor.Get("/");
                });

                requestor.EnableRealRequests();
                requestor.Get("/").Body.ShouldEqual("Hello World");
            }
Ejemplo n.º 47
0
        public static Requestor setRequestors(int id, Requestor re)
        {
            Requestor r = (Requestor)MakeRequest(string.Concat(Utils.ws, "requestor/" + id), re, "PUT", "application/json", typeof(Requestor));

            return(r);
        }
Ejemplo n.º 48
0
 public DocumentAccess(Requestor requestor) : base(requestor, "Documents")
 {
 }
Ejemplo n.º 49
0
 public abstract void CreateRequestor(Requestor requestor);