Example #1
0
        /// <summary>
        /// An override of the SendAsync Function from HttpClient. This is done to automatically add the needed MS-CV tracking header to every request (along with our user-agent).
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) //Overriding the SendAsync so we can easily add the CorrelationVector and User-Agent to every request.
        {
            request.Headers.Add("MS-CV", _cv.GetValue());
            _cv.Increment();
            HttpResponseMessage response = await base.SendAsync(request);

            return(response);
        }
        public void SimpleIncrementCorrelationVectorTest()
        {
            var correlationVector = new CorrelationVector();

            correlationVector.Increment();
            var splitVector = correlationVector.Value.Split('.');

            Assert.AreEqual("1", splitVector[1], "Correlation Vector extension should have been incremented by one");
        }
        public void ValidateCreationTest()
        {
            CorrelationVector.ValidateCorrelationVectorDuringCreation = true;
            var correlationVector = new CorrelationVector();

            correlationVector.Increment();
            var splitVector = correlationVector.Value.Split('.');

            Assert.AreEqual("1", splitVector[1], "Correlation Vector extension should have been incremented by one");
        }