Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to ensure code containing <auto-generated> comment is treated as generated. #857

Merged
merged 1 commit into from Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 15 additions & 15 deletions tests/CodeFormatterTests.cs
Expand Up @@ -86,7 +86,7 @@ public async Task FilesFormattedInUnformattedProject()
includeGenerated: false,
expectedExitCode: 0,
expectedFilesFormatted: 2,
expectedFileCount: 5);
expectedFileCount: 6);
}

[Fact]
Expand All @@ -101,7 +101,7 @@ public async Task NoFilesFormattedInUnformattedProjectWhenFixingCodeStyle()
codeStyleSeverity: DiagnosticSeverity.Error,
expectedExitCode: 0,
expectedFilesFormatted: 0,
expectedFileCount: 5);
expectedFileCount: 6);
}

[Fact]
Expand All @@ -113,8 +113,8 @@ public async Task GeneratedFilesFormattedInUnformattedProject()
exclude: EmptyFilesList,
includeGenerated: true,
expectedExitCode: 0,
expectedFilesFormatted: 4,
expectedFileCount: 5);
expectedFilesFormatted: 5,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When includeGenerated is true the added file is formatted.

expectedFileCount: 6);

var logLines = log.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
Assert.Contains(logLines, line => line.Contains("unformatted_project.AssemblyInfo.cs"));
Expand All @@ -131,7 +131,7 @@ public async Task FilesFormattedInUnformattedSolution()
includeGenerated: false,
expectedExitCode: 0,
expectedFilesFormatted: 2,
expectedFileCount: 5);
expectedFileCount: 6);
}

[Fact]
Expand All @@ -145,7 +145,7 @@ public async Task FilesFormattedInUnformattedProjectFolder()
includeGenerated: false,
expectedExitCode: 0,
expectedFilesFormatted: 2,
expectedFileCount: 5);
expectedFileCount: 6);
}

[Fact]
Expand Down Expand Up @@ -193,7 +193,7 @@ public async Task OnlyFormatPathsFromList()
includeGenerated: false,
expectedExitCode: 0,
expectedFilesFormatted: 2,
expectedFileCount: 5);
expectedFileCount: 6);
}

[Fact]
Expand All @@ -208,7 +208,7 @@ public async Task OnlyFormatFilesFromList()
includeGenerated: false,
expectedExitCode: 0,
expectedFilesFormatted: 1,
expectedFileCount: 5);
expectedFileCount: 6);
}

[Fact]
Expand All @@ -223,7 +223,7 @@ public async Task NoFilesFormattedWhenNotInList()
includeGenerated: false,
expectedExitCode: 0,
expectedFilesFormatted: 0,
expectedFileCount: 5);
expectedFileCount: 6);
}

[Fact]
Expand All @@ -238,7 +238,7 @@ public async Task OnlyLogFormattedFiles()
includeGenerated: false,
expectedExitCode: 0,
expectedFilesFormatted: 1,
expectedFileCount: 5);
expectedFileCount: 6);

var pattern = string.Format(Resources.Formatted_code_file_0, @"(.*)");
var match = new Regex(pattern, RegexOptions.Multiline).Match(log);
Expand All @@ -257,7 +257,7 @@ public async Task FormatLocationsLoggedInUnformattedProject()
includeGenerated: false,
expectedExitCode: 0,
expectedFilesFormatted: 2,
expectedFileCount: 5);
expectedFileCount: 6);

var formatLocations = log.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries)
.Where(line => FindFormattingLogLine.Match(line).Success)
Expand Down Expand Up @@ -328,7 +328,7 @@ public async Task LogFilesThatDontMatchExclude()
includeGenerated: false,
expectedExitCode: 0,
expectedFilesFormatted: 1,
expectedFileCount: 5);
expectedFileCount: 6);

var pattern = string.Format(Resources.Formatted_code_file_0, @"(.*)");
var match = new Regex(pattern, RegexOptions.Multiline).Match(log);
Expand All @@ -349,7 +349,7 @@ public async Task IgnoreFileWhenListedInExcludeList()
includeGenerated: false,
expectedExitCode: 0,
expectedFilesFormatted: 0,
expectedFileCount: 5);
expectedFileCount: 6);
}

[Fact]
Expand All @@ -365,7 +365,7 @@ public async Task IgnoreFileWhenContainingFolderListedInExcludeList()
includeGenerated: false,
expectedExitCode: 0,
expectedFilesFormatted: 0,
expectedFileCount: 5);
expectedFileCount: 6);
}

[Fact]
Expand All @@ -381,7 +381,7 @@ public async Task IgnoreAllFileWhenExcludingAllFiles()
includeGenerated: false,
expectedExitCode: 0,
expectedFilesFormatted: 0,
expectedFileCount: 5);
expectedFileCount: 6);
}

[Fact]
Expand Down
Expand Up @@ -2,7 +2,7 @@
root = true

# C# files
[{Program.cs,other_items/*.cs,obj/**/*.cs}]
[{Program.cs,GeneratedTest.cs,other_items/*.cs,obj/**/*.cs}]

#### Core EditorConfig Options ####

Expand Down
@@ -0,0 +1,17 @@

// This is a file that should be ignored.
//
// <auto-generated />

using System;

namespace for_code_formatter
{
class GeneratedTest
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}