Esempio n. 1
0
        private IEnumerable <string> ReadFromFakeDatabaseForDepthZero()
        {
            var apmContext    = ApmContext.GetContext();
            var methodHandler = apmContext.GetMethodHander();

            return(methodHandler.Execute <IEnumerable <string> >(() => new[] { "zero" }));
        }
Esempio n. 2
0
        public List <string> GetDepthThreeException(int id)
        {
            var context = ApmContext.GetContext();

            context["id"] = id.ToString();

            using (var client = new HttpClient(context.GetDelegatingHandler()))
            {
                client.BaseAddress = _baseUrl;
                var url      = string.Format("api/DepthThree/GetDepthThreeException/{0}", id);
                var response = client.GetAsync(url).ConfigureAwait(false).GetAwaiter().GetResult();

                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception(string.Format("GetDepthThreeException - {0} {1} {2}", url, response.StatusCode,
                                                      response.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult()));
                }

                var results =
                    Newtonsoft.Json.JsonConvert.DeserializeObject <List <string> >(
                        response.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult());

                return(results);
            }
        }
Esempio n. 3
0
        public void WhenLoggingStartOfRequest()
        {
            var apmContext = ApmContext.GetContext();

            var startActionLogged = false;

            _startAction = (context, information) =>
            {
                startActionLogged = true;
            };

            var testApmMethodHandler = new TestApmMethodHandler(apmContext, _applicationName, _startAction, _finishAction);

            testApmMethodHandler.OnActionExecuting();

            Assert.IsTrue(startActionLogged);
        }
Esempio n. 4
0
        public PingResponse Ping()
        {
            var context = ApmContext.GetContext();

            using (var client = new HttpClient(context.GetDelegatingHandler()))
            {
                client.BaseAddress = _baseUrl;
                var url      = string.Format("api/SmokeTest/Ping");
                var response = client.GetAsync(url).ConfigureAwait(false).GetAwaiter().GetResult();

                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception(string.Format("Ping - {0} {1} {2}", url, response.StatusCode, response.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult()));
                }

                var results = Newtonsoft.Json.JsonConvert.DeserializeObject <PingResponse>(response.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult());

                return(results);
            }
        }