protected static void Because_of()
        {
            client.DefaultHeaders.Add("If-Match", long.MaxValue.ToString());

            response = client.Post(ServiceUrl["Person"] +  string.Format("{0}/Mapping/{1}", entity.Id,
                entity.Mappings[0].Id), content);
        }
        protected static void Because_of()
        {
            client.DefaultHeaders.Add("If-Match", entity.Mappings[0].Version.ToUnsignedLongVersion().ToString());

            response = client.Post(ServiceUrl["LegalEntity"] +  string.Format("{0}/Mapping/{1}", entity.Id,
                int.MaxValue), content);
        }
        protected static void Because_of()
        {
            client = new HttpClient(ServiceUrl["Counterparty"] +
                "crossmap?source-system=trayport&destination-system=endur&mapping-string=abc");

            response = client.Get();
        }
        protected static void Because_of()
        {
            client.DefaultHeaders.Add("If-Match", entity.Version.ToString(System.Globalization.CultureInfo.InvariantCulture));

            response = client.Post(ServiceUrl["Person"] +  string.Format("{0}/Mapping/{1}", entity.Id,
                int.MaxValue), content);
        }
        protected static void Because_of()
        {
            var entity = CurveData.CreateBasicEntityWithOneMapping();

            client = new HttpClient(ServiceUrl["Curve"] + string.Format("{0}/mapping/{1}", entity.Id, int.MaxValue));

            response = client.Get();
        }
 private RestfulieProxy NewRestfulieProxy(HttpResponseMessage httpResponseMessage)
 {
     return new RestfulieProxy(_httpClient, _dynamicContentParserFactory, _httpMethodDiscoverer)
     {
         LatestHttpResponseMessage = httpResponseMessage,
         DynamicContentParser = _dynamicContentParserFactory.New(httpResponseMessage.Content)
     };
 }
        protected static void Because_of()
        {
            client = new HttpClient(ServiceUrl["Exchange"] +
                    "map?source-system=Trayport&mapping-string=" + exchange.Mappings[0].MappingValue + "&as-of=" +
                    exchange.Validity.Start.ToString(DateFormatString));

            response = client.Get();
        }
        protected static void Because_of()
        {
            client = new HttpClient(ServiceUrl["Location"] +
                "crossmap?source-system=" + trayport.Name + "&destination-system=" + endur.Name + "&mapping-string=" + trayportMapping.MappingValue);

            response = client.Get();

            mappingResponse = response.Content.ReadAsDataContract<EnergyTrading.Mdm.Contracts.Fault>();
        }
            protected override void ProcessRequestAndTryGetResponse(HttpRequestMessage request, out HttpResponseMessage response, out object state)
            {
                response = _httpResponseMessage;

                response.Request = request;
                response.Method = request.Method;

                state = _state;
            }
        protected static void Because_of()
        {
            entity = BrokerData.CreateBasicEntityWithOneMapping();
            mapping = entity.Mappings[0];
            client = new HttpClient(ServiceUrl["Broker"] + string.Format("{0}/mapping/{1}", entity.Id, mapping.Id));

            response = client.Get();
            mappingResponse = response.Content.ReadAsDataContract<EnergyTrading.Mdm.Contracts.MappingResponse>();
        }
        public void ShouldProvideHttpStatusCodeUponRecievingResponse()
        {
            var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK };

            dynamic resource = new RestfulieProxy(It.IsAny<IHttpClient>(), It.IsAny<IDynamicContentParserFactory>(), It.IsAny<IHttpMethodDiscoverer>())
            {
                LatestHttpResponseMessage = httpResponseMessage
            };

            Assert.AreEqual("200", resource.StatusCode);
        }
Beispiel #12
0
        public void SetUp()
        {
            MockedHttpClientAdapter = new Mock<IHttpClientAdapter>();
            MockedHttpClient = new Mock<IHttpClient>();
            MockedConfigSettings = new Mock<IConfigSettings>();

            PackageAuthenticator = new Infrastructure.Impl.PackageAuthenticator(MockedHttpClientAdapter.Object, MockedConfigSettings.Object,
                new Mock<ILogger>().Object);

            OkHttpResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = HttpContent.Create("true") };
        }
Beispiel #13
0
 public static void LogResponse(this IDnaLogger logger,HttpStatusCode httpStatusCode, HttpResponseMessage httpResponse)
 {
     var props = new Dictionary<string, object>() 
     { 
         { "Result", httpStatusCode.ToString()},
         { "Uri", httpResponse.Uri.ToString()},
         { "Content", httpResponse.Content.ReadAsString()}
     };
     string category = Assembly.GetCallingAssembly().GetName().Name + ".Responses";
     logger.LogGeneral(TraceEventType.Information, category, "", DateTime.MaxValue, props);
 }
        protected static void Because_of()
        {
            entity = BrokerData.CreateEntityWithTwoDetailsAndTwoMappings();

            client = new HttpClient(ServiceUrl["Broker"] +
                "crossmap?source-system=trayport&destination-system=endur&mapping-string=" + entity.Mappings[0].MappingValue
                + "&as-of=" + entity.Mappings[0].Validity.Start.ToString(DateFormatString));

            response = client.Get();
            mappingResponse = response.Content.ReadAsDataContract<EnergyTrading.Mdm.Contracts.MappingResponse>();
        }
        protected static void Because_of()
        {
            pageOneResponse = client.Post(ServiceUrl["Broker"] + "search", content);
            var feed1 = LoadFeed(pageOneResponse);
            pageOne = GetPeopleFromFeed(feed1);
            pageOneNextPage = GetNextPageFromFeed(feed1);

            pageTwoResponse = client.Get(pageOneNextPage);
            var feed2 = LoadFeed(pageTwoResponse);
            pageTwo = GetPeopleFromFeed(feed2);
            pageTwoNextPage = GetNextPageFromFeed(feed2);
        }
 private static Fault FaultFor(HttpResponseMessage response)
 {
     Fault fault;
     try
     {
         fault = response.Content.ReadAsDataContract<Fault>();
     }
     catch (Exception)
     {
         fault = new Fault() {Message = response.StatusCode.ToString()};
     }
     return fault;
 }
 private static DataPackets.HttpResponseMessage ToNativeResponse(HttpResponseMessage response)
 {
     var responseFormat = new DataPackets.HttpResponseMessage
     {
         Content =
         {
             Content = Zip.GetUnzippedContent(response),
             ContentType = response.Content.ContentType,
             Encoding = GetEncoding(response.Content.ContentType)
         },
         Method = response.Method,
         Properties = response.Properties,
         StatusCode = response.StatusCode,
         Uri = response.Uri
     };
     return responseFormat;
 }
        private static DataPackets.HttpResponseMessage ToNativeResponse(HttpResponseMessage response)
        {
            var responseFormat = new DataPackets.HttpResponseMessage
            {
                Content =
                {
                    Content     = Zip.GetUnzippedContent(response),
                    ContentType = response.Content.ContentType,
                    Encoding    = GetEncoding(response.Content.ContentType)
                },
                Method     = response.Method,
                Properties = response.Properties,
                StatusCode = response.StatusCode,
                Uri        = response.Uri
            };

            return(responseFormat);
        }
Beispiel #19
0
        public static void AssertHttpResponse(HttpResponseMessage response,string methodName)
        {
            bool succeed = false;

            if (response.StatusCode == HttpStatusCode.OK)
            {
                succeed = true;
                TextLog.LogMessage(methodName + ": Test Case Pass.");
                Console.WriteLine(methodName + ": Get Response successfully.");
            }
            else
            {
                succeed = false;
                TextLog.LogMessage(methodName + ": Test Case Pass.");
                Console.WriteLine(methodName + ": Get Response failed.");
            }

            Assert.AreEqual(true, succeed);
        }
Beispiel #20
0
 bool InvokeHandler(HttpResponseMessage response)
 {
     ConditionalGetEventArgs args = new ConditionalGetEventArgs() { Response = response };
     return InvokeHandler(args);
 }
 protected static void Because_of()
 {
     client = new HttpClient(ServiceUrl["SourceSystem"] +
     "map?source-system=trayport&mapping-string=xxx&as-of=2010-03-16T11:21:23Z");
     response = client.Get();
 }
 protected static void Because_of()
 {
     client.DefaultHeaders.Add("If-Match", 0.ToString());
     response = client.Post(ServiceUrl["Party"] + int.MaxValue, content);
 }
 protected static void Because_of()
 {
     client = new HttpClient();
     var uri = ServiceUrl["LegalEntity"] + legalentity.Id + "/Mapping/" + legalentity.Mappings[0].Id;
     response = client.Delete(uri);
 }
 protected static void Because_of()
 {
     response = client.Post(new Uri(ServiceUrl["Person"]), content);
 }
 protected static void Because_of()
 {
     client.DefaultHeaders.Add("If-Match", long.MaxValue.ToString());
     response = client.Post(ServiceUrl["Person"] + entity.Id, content);
 }
 protected static void Because_of()
 {
     response = client.Post(ServiceUrl["Counterparty"] + "search", content);
 }
 protected static void Because_of()
 {
     client.Post(ServiceUrl["Exchange"] + string.Format("{0}/Mapping", entity.Id), content);
     response2 = client.Post(ServiceUrl["Exchange"] + string.Format("{0}/Mapping", entity.Id), content2);
 }
        public void ShouldThrowWhenGivenResponseReturnedBadRequest()
        {
            var response = new HttpResponseMessage {StatusCode = HttpStatusCode.BadRequest};
            MockedHttpClientAdapter.Setup(hca => hca.GetHttpClient(It.IsAny<string>())).Returns(MockedHttpClient.Object);
            MockedHttpClient.Setup(hc => hc.Get(It.IsAny<string>())).Returns(response);

            TestDelegate methodThatShouldThrow = () => PackageAuthenticator.EnsureKeyCanAccessPackage("key", "packageId", "packageVersion");

            Assert.Throws<Exception>(methodThatShouldThrow, "Should have thrown when reponse returned not-OK status code.");
        }
 protected static void Because_of()
 {
     client.TransportSettings.MaximumAutomaticRedirections = 0;
     response = client.Post(ServiceUrl["Location"] + "Search", content);
 }
 protected static void Because_of()
 {
     response = client.Post(ServiceUrl["Exchange"] + "search", content);
 }
 private static SyndicationFeed LoadFeed(HttpResponseMessage message)
 {
     XmlReader reader = XmlReader.Create(
         message.Content.ReadAsStream(), new XmlReaderSettings { ProhibitDtd = false });
     SyndicationFeed feed = SyndicationFeed.Load(reader);
     return feed;
 }