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); }
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); }
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); }