public void SendCustomPingsWithSnakeCase() { PingType <NoReasonCodes> customPing = new PingType <NoReasonCodes>( name: "custom_ping", includeClientId: true, sendIfEmpty: false, reasonCodes: null ); BooleanMetricType sampleMetric = new BooleanMetricType( disabled: false, category: "test", lifetime: Lifetime.Ping, name: "boolean_metric", sendInPings: new string[] { "custom_ping" } ); sampleMetric.Set(true); Assert.True(sampleMetric.TestHasValue()); customPing.Submit(); MockUploader.UploadRequest request = mockUploader.GetPendingUpload(); Assert.Equal("custom_ping", request.docType); // Check that we have a non-null client id. JsonDocument jsonPayload = JsonDocument.Parse(request.payload); JsonElement root = jsonPayload.RootElement; Assert.NotNull(root.GetProperty("client_info").GetProperty("client_id").GetString()); // TODO: Check the ping schema. // checkPingSchema(pingJson) }
public void SendCustomPingsWithAnUnknownNameNoOp() { const string unknownPingName = "unknown"; Assert.False(GleanInstance.TestHasPingType(unknownPingName)); BooleanMetricType sampleMetric = new BooleanMetricType( disabled: false, category: "test", lifetime: Lifetime.Ping, name: "boolean_metric", sendInPings: new string[] { unknownPingName } ); sampleMetric.Set(true); Assert.True(sampleMetric.TestHasValue()); GleanInstance.SubmitPingByName(unknownPingName); // We don't expect any ping to be sent. Assert.Equal(0, mockUploader.GetUploadRequestCount()); }