Skip to content

Commit

Permalink
Migrate from nUnit to xUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
FrediKats committed May 14, 2024
1 parent 790ddc9 commit 26cbdd6
Show file tree
Hide file tree
Showing 20 changed files with 84 additions and 117 deletions.
3 changes: 3 additions & 0 deletions Sources/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="TestableIO.System.IO.Abstractions.Wrappers" Version="21.0.2" />
<PackageVersion Include="MinVer" Version="5.0.0" />
<PackageVersion Include="xunit" Version="2.8.0" />
<PackageVersion Include="xunit.analyzers" Version="1.13.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.0" />
</ItemGroup>
</Project>
6 changes: 2 additions & 4 deletions Sources/Kysect.Configuin.Tests/CmdProcessTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using FluentAssertions;
using Kysect.Configuin.DotnetFormatIntegration.Cli;
using Kysect.Configuin.DotnetFormatIntegration.Cli;
using Kysect.Configuin.Tests.Tools;
using NUnit.Framework;

namespace Kysect.Configuin.Tests;

Expand All @@ -14,7 +12,7 @@ public CmdProcessTests()
_cmdProcess = new CmdProcess(TestLogger.ProviderForTests());
}

[Test]
[Fact]
public void Execute_ForInvalidCommand_ThrowError()
{
CmdExecutionResult cmdExecutionResult = _cmdProcess.ExecuteCommand("qwerasdf1234");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using FluentAssertions;
using Kysect.CommonLib.BaseTypes.Extensions;
using Kysect.CommonLib.BaseTypes.Extensions;
using Kysect.Configuin.CodeStyleDoc;
using Kysect.Configuin.CodeStyleDoc.Models;
using Kysect.Configuin.EditorConfig;
using Kysect.Configuin.MsLearn;
using Kysect.Configuin.MsLearn.Models;
using Kysect.Configuin.RoslynModels;
using Kysect.Configuin.Tests.Tools;
using NUnit.Framework;

namespace Kysect.Configuin.Tests.CodeStyleGeneration;

Expand All @@ -23,7 +21,7 @@ public CodeStyleGeneratorTests()
_sut = new CodeStyleGenerator(TestLogger.ProviderForTests());
}

[Test]
[Fact]
public void Generate_ForAllMsLearnDocumentation_FinishWithoutErrors()
{
string pathToIniFile = Path.Combine("Resources", "Editor-config-sample.ini");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
using FluentAssertions;
using Kysect.Configuin.CodeStyleDoc.Markdown;
using Kysect.Configuin.CodeStyleDoc.Markdown;
using Kysect.Configuin.CodeStyleDoc.Models;
using Kysect.Configuin.RoslynModels;
using Kysect.Configuin.Tests.Resources;
using Kysect.Configuin.Tests.Tools;
using NUnit.Framework;

namespace Kysect.Configuin.Tests.CodeStyleGeneration;

public class MarkdownCodeStyleFormatterTests
{
private readonly MarkdownCodeStyleFormatter _formatter = new MarkdownCodeStyleFormatter(TestLogger.ProviderForTests());

[Test]
[Fact]
public void FormatStyleRule_ForIDE0001_ReturnExpected()
{
const string expected = """
Expand Down Expand Up @@ -50,7 +48,7 @@ class C
formatterRule.Should().Be(expected);
}

[Test]
[Fact]
public void FormatStyleRule_ForIDE0040_ReturnExpected()
{
const string expected = """
Expand Down Expand Up @@ -94,7 +92,7 @@ class MyClass
formatterRule.Should().Be(expected);
}

[Test]
[Fact]
public void FormatQualityRule_ForCA1064_ReturnExpected()
{
// TODO: add description
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Kysect.Configuin.DotnetFormatIntegration.Cli;
using Kysect.Configuin.Tests.Tools;
using NUnit.Framework;

namespace Kysect.Configuin.Tests.DotnetFormat;

Expand All @@ -13,15 +12,13 @@ public DotnetFormatCliTests()
_dotnetFormatCli = new DotnetFormatCli(TestLogger.ProviderForTests());
}

[Test]
[Ignore("This test require infrastructure")]
[Fact(Skip = "This test require infrastructure")]
public void Validate_FinishedWithoutErrors()
{
_dotnetFormatCli.Validate();
}

[Test]
[Ignore("This test require infrastructure")]
[Fact(Skip = "This test require infrastructure")]
public void GenerateWarnings_CreateReportFile()
{
//const string pathToSln = "./../../../../";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using FluentAssertions;
using Kysect.CommonLib.Collections.Diff;
using Kysect.CommonLib.Collections.Diff;
using Kysect.Configuin.DotnetFormatIntegration.Cli;
using Kysect.Configuin.Tests.Tools;
using NUnit.Framework;

namespace Kysect.Configuin.Tests;

Expand All @@ -15,7 +13,7 @@ public DotnetFormatReportComparatorTests()
_dotnetFormatReportComparator = new DotnetFormatReportComparator(TestLogger.ProviderForTests());
}

[Test]
[Fact]
public void Compare_ChangedFile_ReturnExpectedDiff()
{
string left = File.ReadAllText(Path.Combine("Resources", "DotnetFormatOutput-one-report.json"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using FluentAssertions;
using Kysect.Configuin.EditorConfig;
using Kysect.Configuin.EditorConfig;
using Kysect.Configuin.EditorConfig.Analyzing;
using Kysect.Configuin.EditorConfig.Settings;
using Kysect.Configuin.RoslynModels;
using Kysect.Configuin.Tests.Resources;
using NUnit.Framework;

namespace Kysect.Configuin.Tests.EditorConfig;

Expand All @@ -17,7 +15,7 @@ public EditorConfigAnalyzerTests()
_editorConfigAnalyzer = new EditorConfigAnalyzer();
}

[Test]
[Fact]
public void GetMissedConfigurations_AllOptionAreMissed_ReturnAllOptions()
{
var editorConfigSettings = new EditorConfigSettings(Array.Empty<IEditorConfigSetting>());
Expand All @@ -41,7 +39,7 @@ public void GetMissedConfigurations_AllOptionAreMissed_ReturnAllOptions()
.And.Contain(WellKnownRoslynRuleDefinitions.IDE0040().Options.Single().Name);
}

[Test]
[Fact]
public void GetMissedConfigurations_AllOptionExists_ReturnAllOptions()
{
var editorConfigSettings = new EditorConfigSettings(new IEditorConfigSetting[]
Expand All @@ -63,7 +61,7 @@ public void GetMissedConfigurations_AllOptionExists_ReturnAllOptions()
editorConfigMissedConfiguration.StyleRuleOptions.Should().BeEmpty();
}

[Test]
[Fact]
public void GetIncorrectOptionValues_AllOptionsValid_NoElementReturn()
{
var editorConfigSettings = new EditorConfigSettings(new IEditorConfigSetting[]
Expand All @@ -80,7 +78,7 @@ public void GetIncorrectOptionValues_AllOptionsValid_NoElementReturn()
invalidOptionValues.Should().BeEmpty();
}

[Test]
[Fact]
public void GetIncorrectOptionValues_ForInvalidOptionValue_ReturnInvalidOption()
{
string incorrectOptionValue = "null";
Expand All @@ -106,7 +104,7 @@ public void GetIncorrectOptionValues_ForInvalidOptionValue_ReturnInvalidOption()
.And.Subject.ElementAt(0).Should().BeEquivalentTo(expected);
}

[Test]
[Fact]
public void GetIncorrectOptionValues_ForInvalidOptionKey_ReturnInvalidOption()
{
string incorrectOptionKey = "null";
Expand All @@ -132,7 +130,7 @@ public void GetIncorrectOptionValues_ForInvalidOptionKey_ReturnInvalidOption()
.And.Subject.ElementAt(0).Should().BeEquivalentTo(expected);
}

[Test]
[Fact]
public void GetIncorrectOptionSeverity_ForInvalidSeverityConfiguration_ReturnInvalidRuleIds()
{
var editorConfigSettings = new EditorConfigSettings(new IEditorConfigSetting[]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FluentAssertions;
using Kysect.Configuin.EditorConfig;
using Kysect.Configuin.EditorConfig;
using Kysect.Configuin.EditorConfig.Diff;
using Kysect.Configuin.EditorConfig.Settings;
using Kysect.Configuin.RoslynModels;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
using FluentAssertions;
using Kysect.Configuin.EditorConfig;
using Kysect.Configuin.EditorConfig;
using Kysect.Configuin.EditorConfig.Settings;
using Kysect.Configuin.RoslynModels;
using Kysect.Configuin.Tests.Tools;
using NUnit.Framework;

namespace Kysect.Configuin.Tests.EditorConfig;

public class EditorConfigSettingsParserTests
{
private readonly EditorConfigSettingsParser _parser = new EditorConfigSettingsParser(TestLogger.ProviderForTests());

[Test]
[Fact]
public void Parse_TabWidth_ReturnGeneralEditorRule()
{
string content = "tab_width = 4";
Expand All @@ -24,7 +22,7 @@ public void Parse_TabWidth_ReturnGeneralEditorRule()
.And.Contain(expected);
}

[Test]
[Fact]
public void Parse_DotnetDiagnosticSeverity_ReturnRoslyntSeverityRule()
{
string content = "dotnet_diagnostic.IDE0001.severity = warning";
Expand All @@ -37,7 +35,7 @@ public void Parse_DotnetDiagnosticSeverity_ReturnRoslyntSeverityRule()
.And.Contain(expected);
}

[Test]
[Fact]
public void Parse_KeyWithDots_ReturnCompositeOptionRule()
{
string content = "dotnet_naming_style.camel_case_style.capitalization = camel_case";
Expand All @@ -52,7 +50,7 @@ public void Parse_KeyWithDots_ReturnCompositeOptionRule()
.And.ContainEquivalentOf(expected);
}

[Test]
[Fact]
public void Parse_StyleOption_ReturnOptionRule()
{
string content = "csharp_style_var_when_type_is_apparent = true";
Expand All @@ -67,7 +65,7 @@ public void Parse_StyleOption_ReturnOptionRule()
.And.Contain(expected);
}

[Test]
[Fact]
public void Parse_StyleOptionWithSeverity_ReturnOptionRuleWithSeverity()
{
string content = "csharp_style_var_when_type_is_apparent = true";
Expand All @@ -82,7 +80,7 @@ public void Parse_StyleOptionWithSeverity_ReturnOptionRuleWithSeverity()
.And.Contain(expected);
}

[Test]
[Fact]
public void Parse_EditorConfigFile_ReturnWithoutErrors()
{
string fileText = File.ReadAllText(Path.Combine("Resources", "Editor-config-sample.ini"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using FluentAssertions;
using Kysect.Configuin.EditorConfig.Template;
using Kysect.Configuin.EditorConfig.Template;
using Kysect.Configuin.RoslynModels;
using Kysect.Configuin.Tests.Resources;
using Kysect.Configuin.Tests.Tools;
using NUnit.Framework;

namespace Kysect.Configuin.Tests.EditorConfig;

Expand All @@ -16,7 +14,7 @@ public EditorConfigTemplateGeneratorTests()
_editorConfigTemplateGenerator = new EditorConfigTemplateGenerator(TestLogger.ProviderForTests());
}

[Test]
[Fact]
public void GenerateTemplate_ForIDE0001_ReturnExpectedString()
{
RoslynRules roslynRules = RoslynRulesBuilder.New()
Expand Down Expand Up @@ -45,7 +43,7 @@ public void GenerateTemplate_ForIDE0001_ReturnExpectedString()
generateTemplate.Should().Be(expected);
}

[Test]
[Fact]
public void GenerateTemplate_ForIDE0007_0008_ReturnExpectedString()
{
RoslynRules roslynRules = RoslynRulesBuilder.New()
Expand All @@ -67,7 +65,7 @@ public void GenerateTemplate_ForIDE0007_0008_ReturnExpectedString()
generateTemplate.Should().Be(expected);
}

[Test]
[Fact]
public void GenerateTemplate_ForIDE0040_ReturnExpectedString()
{
RoslynRules roslynRules = RoslynRulesBuilder.New()
Expand Down Expand Up @@ -107,7 +105,7 @@ public void GenerateTemplate_ForIDE0040_ReturnExpectedString()
generateTemplate.Should().Be(expected);
}

[Test]
[Fact]
public void GenerateTemplate_ForCA1064_ReturnExpectedString()
{
RoslynRules roslynRules = RoslynRulesBuilder.New()
Expand Down
10 changes: 4 additions & 6 deletions Sources/Kysect.Configuin.Tests/EditorConfig/IniParserTests.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using FluentAssertions;
using Kysect.Configuin.EditorConfig.IniParsing;
using NUnit.Framework;
using Kysect.Configuin.EditorConfig.IniParsing;

namespace Kysect.Configuin.Tests.EditorConfig;

public class IniParserTests
{
private readonly IniParser _parser = new IniParser();

[Test]
[Fact]
public void Parse_SimpleLine_ReturnParsedKeyValue()
{
string content = "key = value";
Expand All @@ -20,7 +18,7 @@ public void Parse_SimpleLine_ReturnParsedKeyValue()
.And.Contain(new IniFileLine("key", "value"));
}

[Test]
[Fact]
public void Parse_LineWithComment_ReturnParsedKeyValue()
{
string content = "# key = value";
Expand All @@ -30,7 +28,7 @@ public void Parse_LineWithComment_ReturnParsedKeyValue()
result.Should().HaveCount(0);
}

[Test]
[Fact]
public void Parse_EditorConfigFile_ParsedWithoutErrors()
{
string fileText = File.ReadAllText(Path.Combine("Resources", "Editor-config-sample.ini"));
Expand Down
4 changes: 4 additions & 0 deletions Sources/Kysect.Configuin.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Global using directives

global using FluentAssertions;
global using Xunit;
14 changes: 7 additions & 7 deletions Sources/Kysect.Configuin.Tests/Kysect.Configuin.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
Expand All @@ -10,16 +10,16 @@
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Kysect.CommonLib" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="NUnit.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog" />
<PackageReference Include="Serilog.Extensions.Logging" />
<PackageReference Include="Serilog.Settings.Configuration" />
<PackageReference Include="Serilog.Sinks.Console" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.analyzers" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 26cbdd6

Please sign in to comment.