Esempio n. 1
0
        public void TestAddMetricDataPoint()
        {
            var httpResponseMock = new Mock <HttpResponse>();
            var headerDictionary = new HeaderDictionary();

            httpResponseMock.SetupGet(m => m.Headers).Returns(headerDictionary);

            Extensions.AddMetricDataPoint(httpResponseMock.Object, null);
            Assert.Empty(headerDictionary);

            Extensions.AddMetricDataPoint(httpResponseMock.Object, new DataPoint());
            Assert.Empty(headerDictionary);

            var dp = BuildDataPoint();

            httpResponseMock.Object.AddMetricDataPoint(dp);
            Assert.Single(headerDictionary);

            var header = headerDictionary.First();

            Assert.StartsWith("sfx_metric_datapoint-", header.Key);
            Assert.Equal(JsonConvert.SerializeObject(dp), header.Value);
        }