Exemple #1
0
        public void Invoke_WithNullMetricsRequest_ReturnsExpected()
        {
            var opts  = new MetricsOptions();
            var stats = new OpenCensusStats();

            SetupStats(stats);

            var ep     = new MetricsEndpoint(opts, stats);
            var result = ep.Invoke(null);

            Assert.NotNull(result);
            Assert.IsType <MetricsListNamesResponse>(result);
            MetricsListNamesResponse resp = result as MetricsListNamesResponse;

            Assert.NotEmpty(resp.Names);
            Assert.Contains("http.server.requests", resp.Names);
            Assert.Contains("jvm.memory.used", resp.Names);
            Assert.Equal(2, resp.Names.Count);

            opts  = new MetricsOptions();
            stats = new OpenCensusStats();

            ep     = new MetricsEndpoint(opts, stats);
            result = ep.Invoke(null);
            Assert.NotNull(result);

            Assert.IsType <MetricsListNamesResponse>(result);
            resp = result as MetricsListNamesResponse;
            Assert.Empty(resp.Names);
        }
Exemple #2
0
        public void JsonSerialization_ReturnsExpected()
        {
            var names = new HashSet <string>()
            {
                "foo.bar",
                "bar.foo"
            };
            var resp   = new MetricsListNamesResponse(names);
            var result = Serialize(resp);

            Assert.Equal("{\"names\":[\"foo.bar\",\"bar.foo\"]}", result);
        }
Exemple #3
0
        public void Constructor_SetsValues()
        {
            var names = new HashSet <string>()
            {
                "foo.bar",
                "bar.foo"
            };
            var resp = new MetricsListNamesResponse(names);

            Assert.NotNull(resp.Names);
            Assert.Same(names, resp.Names);
        }