private void SerializeWritesTagsAsExpectedByEndpoint() { var expected = new TTelemetry(); expected.Context.Tags["Test Key"] = "Test Value"; expected.Sanitize(); TelemetryItem <TEndpointData> actual = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem <TTelemetry, TEndpointData>(expected); Assert.AreEqual("Test Value", actual.Tags["Test Key"]); }
private void SerializeWritesInstrumentationKeyAsExpectedByEndpoint() { var expected = new TTelemetry(); expected.Context.InstrumentationKey = Guid.NewGuid().ToString(); expected.Sanitize(); TelemetryItem <TEndpointData> actual = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem <TTelemetry, TEndpointData>(expected); Assert.AreEqual(expected.Context.InstrumentationKey, actual.iKey); }
private void SerializeWritesDataBaseTypeAsExpectedByEndpoint() { var telemetry = new TTelemetry(); telemetry.Sanitize(); TelemetryItem <TEndpointData> envelope = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem <TTelemetry, TEndpointData>(telemetry); string expectedBaseType = ExtractTelemetryNameFromType(typeof(TTelemetry)) + "Data"; Assert.AreEqual(expectedBaseType, envelope.data.baseType); }
private void SerializeWritesSequenceAsExpectedByEndpoint() { var expected = new TTelemetry { Sequence = "4:2" }; expected.Sanitize(); TelemetryItem <TEndpointData> actual = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem <TTelemetry, TEndpointData>(expected); Assert.AreEqual(expected.Sequence, actual.seq); }
private void SerializeWritesTimestampAsExpectedByEndpoint() { var expected = new TTelemetry { Timestamp = DateTimeOffset.UtcNow }; expected.Sanitize(); TelemetryItem <TEndpointData> actual = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem <TTelemetry, TEndpointData>(expected); Assert.AreEqual(expected.Timestamp, actual.Time); }
private void SerializeWritesTimestampAsExpectedByEndpoint() { var expected = new TTelemetry { Timestamp = DateTimeOffset.UtcNow }; expected.Sanitize(); TelemetryItem <TEndpointData> actual = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem <TTelemetry, TEndpointData>(expected); Assert.AreEqual <DateTimeOffset>(expected.Timestamp, DateTimeOffset.Parse(actual.time, null, System.Globalization.DateTimeStyles.AssumeUniversal)); }
private void SerializeWritesDataBaseTypeAsExpectedByEndpoint() { var telemetry = new TTelemetry(); telemetry.Sanitize(); TelemetryItem <TEndpointData> envelope = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem <TTelemetry, TEndpointData>(telemetry); // TODO: Why is TraceTelemetry serialized as MessageData base type instead of TraceData? string expectedBaseType = typeof(TTelemetry) == typeof(TraceTelemetry) ? "MessageData" : typeof(TTelemetry).Name.Replace("Telemetry", "Data"); Assert.AreEqual(expectedBaseType, envelope.Data.BaseType); }
private void SerializeWritesTelemetryNameAsExpectedByEndpoint() { var expected = new TTelemetry(); expected.Context.InstrumentationKey = "312CBD79-9DBB-4C48-A7DA-3CC2A931CB71"; expected.Sanitize(); TelemetryItem <TEndpointData> actual = TelemetryItemTestHelper .SerializeDeserializeTelemetryItem <TTelemetry, TEndpointData>(expected); Assert.AreEqual( Constants.TelemetryNamePrefix + "312cbd799dbb4c48a7da3cc2a931cb71." + this.ExtractTelemetryNameFromType(typeof(TTelemetry)), actual.name); }
private void SerializeWritesTelemetryNameAsExpectedByEndpoint() { var expected = new TTelemetry(); expected.Context.InstrumentationKey = "312CBD79-9DBB-4C48-A7DA-3CC2A931CB71"; expected.Sanitize(); TelemetryItem <TEndpointData> actual = TelemetryItemTestHelper .SerializeDeserializeTelemetryItem <TEndpointData>(expected); Assert.AreEqual( this.ExtractEnvelopeNameFromType(typeof(TTelemetry)), actual.name); }