Fix version comparison
This commit is contained in:
Родитель
48149f6a10
Коммит
b994364b60
|
@ -6,12 +6,12 @@
|
|||
|
||||
public static class SdkVersionHelper
|
||||
{
|
||||
public static string GetExpectedSdkVersion(string prefix)
|
||||
public static string GetExpectedSdkVersion(string prefix, Type loggerType)
|
||||
{
|
||||
#if NET45 || NET46
|
||||
string versionStr = typeof(SdkVersionHelper).Assembly.GetCustomAttributes(false).OfType<AssemblyFileVersionAttribute>().First().Version;
|
||||
string versionStr = loggerType.Assembly.GetCustomAttributes(false).OfType<AssemblyFileVersionAttribute>().First().Version;
|
||||
#else
|
||||
string versionStr = typeof(SdkVersionHelper).GetTypeInfo().Assembly.GetCustomAttributes<AssemblyFileVersionAttribute>().First().Version;
|
||||
string versionStr = loggerType.GetTypeInfo().Assembly.GetCustomAttributes<AssemblyFileVersionAttribute>().First().Version;
|
||||
#endif
|
||||
string[] versionParts = new Version(versionStr).ToString().Split('.');
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace Microsoft.ApplicationInsights.DiagnosticSourceListener.Tests
|
|||
Assert.AreEqual(testDiagnosticSource.Name, telemetry.Properties["DiagnosticSource"]);
|
||||
Assert.AreEqual(SeverityLevel.Information, telemetry.SeverityLevel);
|
||||
Assert.AreEqual(1234.ToString(InvariantCulture), telemetry.Properties["Prop1"]);
|
||||
string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(prefix: "dsl:");
|
||||
string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(prefix: "dsl:", loggerType: typeof(DiagnosticSourceTelemetryModule));
|
||||
Assert.AreEqual(expectedVersion, telemetry.Context.GetInternalContext().SdkVersion);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace Microsoft.ApplicationInsights.EventSourceListener.Tests
|
|||
Assert.AreEqual("Hey!", telemetry.Message);
|
||||
Assert.AreEqual("Hey!", telemetry.Properties["information"]);
|
||||
Assert.AreEqual(SeverityLevel.Information, telemetry.SeverityLevel);
|
||||
string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(prefix: "evl:");
|
||||
string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(prefix: "evl:", loggerType: typeof(EventSourceTelemetryModule));
|
||||
Assert.AreEqual(expectedVersion, telemetry.Context.GetInternalContext().SdkVersion);
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ namespace Microsoft.ApplicationInsights.EventSourceListener.Tests
|
|||
Assert.AreEqual("Hey!", telemetry.Properties["information"]);
|
||||
Assert.AreEqual(SeverityLevel.Information, telemetry.SeverityLevel);
|
||||
|
||||
string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(prefix: "evl:");
|
||||
string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(prefix: "evl:", loggerType: typeof(EventSourceTelemetryModule));
|
||||
Assert.AreEqual(expectedVersion, telemetry.Context.GetInternalContext().SdkVersion);
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ namespace Microsoft.ApplicationInsights.EventSourceListener.Tests
|
|||
Assert.AreEqual("Hey!", telemetry.Message);
|
||||
Assert.AreEqual("Hey!", telemetry.Properties["message"]);
|
||||
Assert.AreEqual(SeverityLevel.Information, telemetry.SeverityLevel);
|
||||
string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(prefix: "evl:");
|
||||
string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(prefix: "evl:", loggerType: typeof(EventSourceTelemetryModule));
|
||||
Assert.AreEqual(expectedVersion, telemetry.Context.GetInternalContext().SdkVersion);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace Microsoft.ApplicationInsights.Log4NetAppender.Tests
|
|||
var telemetry = (TraceTelemetry)sentItems[0];
|
||||
Assert.AreNotEqual(default(DateTimeOffset), telemetry.Context);
|
||||
|
||||
string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(prefix: "log4net:");
|
||||
string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(prefix: "log4net:", loggerType: typeof(AppendableLogger));
|
||||
Assert.AreEqual(expectedVersion, telemetry.Context.GetInternalContext().SdkVersion);
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@
|
|||
|
||||
var telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.First();
|
||||
|
||||
string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(prefix: "nlog:");
|
||||
string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(prefix: "nlog:", loggerType: typeof(ApplicationInsightsTarget));
|
||||
Assert.AreEqual(expectedVersion, telemetry.Context.GetInternalContext().SdkVersion);
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
|
||||
TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.First();
|
||||
|
||||
string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(prefix: "sd:");
|
||||
string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(prefix: "sd:", loggerType: typeof(ApplicationInsightsTraceListener));
|
||||
Assert.AreEqual(expectedVersion, telemetry.Context.GetInternalContext().SdkVersion);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче