Rename test class namespace. Remove xunit dependency.

This commit is contained in:
xiang17 2021-05-11 12:34:41 -07:00
Родитель 690dc8a3c8
Коммит 84c05123da
3 изменённых файлов: 20 добавлений и 22 удалений

Просмотреть файл

@ -1,44 +1,43 @@
namespace Microsoft.ApplicationInsights.TestFramework.Extensibility.Implementation.Tracing.SelfDiagnostics
namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.SelfDiagnostics
{
using Xunit;
using Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.SelfDiagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class SelfDiagnosticsConfigParserTest
{
[Fact]
[TestMethod]
public void SelfDiagnosticsConfigParser_TryParseFilePath_Success()
{
string configJson = "{ \t \n "
+ "\t \"LogDirectory\" \t : \"Diagnostics\", \n"
+ "FileSize \t : \t \n"
+ " 1024 \n}\n";
Assert.True(SelfDiagnosticsConfigParser.TryParseLogDirectory(configJson, out string logDirectory));
Assert.Equal("Diagnostics", logDirectory);
Assert.IsTrue(SelfDiagnosticsConfigParser.TryParseLogDirectory(configJson, out string logDirectory));
Assert.AreEqual("Diagnostics", logDirectory);
}
[Fact]
[TestMethod]
public void SelfDiagnosticsConfigParser_TryParseFilePath_MissingField()
{
string configJson = @"{
""path"": ""Diagnostics"",
""FileSize"": 1024
}";
Assert.False(SelfDiagnosticsConfigParser.TryParseLogDirectory(configJson, out string logDirectory));
Assert.IsFalse(SelfDiagnosticsConfigParser.TryParseLogDirectory(configJson, out string logDirectory));
}
[Fact]
[TestMethod]
public void SelfDiagnosticsConfigParser_TryParseFileSize()
{
string configJson = @"{
""LogDirectory"": ""Diagnostics"",
""FileSize"": 1024
}";
Assert.True(SelfDiagnosticsConfigParser.TryParseFileSize(configJson, out int fileSize));
Assert.Equal(1024, fileSize);
Assert.IsTrue(SelfDiagnosticsConfigParser.TryParseFileSize(configJson, out int fileSize));
Assert.AreEqual(1024, fileSize);
}
[Fact]
[TestMethod]
public void SelfDiagnosticsConfigParser_TryParseFileSize_CaseInsensitive()
{
string configJson = @"{
@ -46,21 +45,21 @@
""fileSize"" :
2048
}";
Assert.True(SelfDiagnosticsConfigParser.TryParseFileSize(configJson, out int fileSize));
Assert.Equal(2048, fileSize);
Assert.IsTrue(SelfDiagnosticsConfigParser.TryParseFileSize(configJson, out int fileSize));
Assert.AreEqual(2048, fileSize);
}
[Fact]
[TestMethod]
public void SelfDiagnosticsConfigParser_TryParseFileSize_MissingField()
{
string configJson = @"{
""LogDirectory"": ""Diagnostics"",
""size"": 1024
}";
Assert.False(SelfDiagnosticsConfigParser.TryParseFileSize(configJson, out int fileSize));
Assert.IsFalse(SelfDiagnosticsConfigParser.TryParseFileSize(configJson, out int fileSize));
}
[Fact]
[TestMethod]
public void SelfDiagnosticsConfigParser_TryParseLogLevel()
{
string configJson = @"{
@ -68,8 +67,8 @@
""FileSize"": 1024,
""LogLevel"": ""Error""
}";
Assert.True(SelfDiagnosticsConfigParser.TryParseLogLevel(configJson, out string logLevelString));
Assert.Equal("Error", logLevelString);
Assert.IsTrue(SelfDiagnosticsConfigParser.TryParseLogLevel(configJson, out string logLevelString));
Assert.AreEqual("Error", logLevelString);
}
}
}

Просмотреть файл

@ -22,7 +22,6 @@
<PackageReference Include="Moq" Version="4.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net452' ">

Просмотреть файл

@ -64,7 +64,7 @@
Activity.ForceDefaultIdFormat = true;
}
});
SelfDiagnostics.EnsureInitialized();
SelfDiagnosticsInitializer.EnsureInitialized();
}
/// <summary>