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

Bump xunit to 2.9.0 #9457

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0-preview-20221003-04" />
<PackageVersion Include="Moq" Version="4.16.1" />
<PackageVersion Include="Verify.Xunit" Version="14.2.0" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.analyzers" Version="1.0.0"/>
<PackageVersion Include="xunit.assert" Version="2.4.2" />
<PackageVersion Include="xunit.combinatorial" Version="1.5.25" />
<PackageVersion Include="xunit.extensibility.core" Version="2.4.2" />
<PackageVersion Include="xunit.extensibility.execution" Version="2.4.2" />
<PackageVersion Include="xunit.runner.console" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="xunit" Version="2.9.0" />
<PackageVersion Include="xunit.analyzers" Version="1.15.0"/>
<PackageVersion Include="xunit.assert" Version="2.9.0" />
<PackageVersion Include="xunit.combinatorial" Version="1.6.24" />
<PackageVersion Include="xunit.extensibility.core" Version="2.9.0" />
<PackageVersion Include="xunit.extensibility.execution" Version="2.9.0" />
<PackageVersion Include="xunit.runner.console" Version="2.9.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />

<!-- Integration Tests -->
<PackageVersion Include="Microsoft.DotNet.Common.ProjectTemplates.1.x" Version="1.0.0-beta2-20170629-269" />
Expand Down
2 changes: 1 addition & 1 deletion eng/imports/UnitTests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<Delete Files="$(TrxTestResultsFile);$(HtmlTestResultsFile)" />

<!-- xUnit writes to STDERR (test name) and STDOUT (error message, stack). STDERR gets logged as an error. -->
<Exec Command='$(TestRunner) --verbosity quiet --nologo --logger "trx;logfilename=$(TrxTestResultsFile)" --logger "html;logfilename=$(HtmlTestResultsFile)" $(TargetPath)' LogStandardErrorAsError="true" IgnoreExitCode="true">
<Exec Command='$(TestRunner) --verbosity diagnostic --nologo --logger "trx;logfilename=$(TrxTestResultsFile)" --logger "html;logfilename=$(HtmlTestResultsFile)" $(TargetPath)' LogStandardErrorAsError="true" IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="ExitCode" />
</Exec>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static void CollectionLength<T>(IEnumerable<T> collection, int expectedCo

if (actualCount != expectedCount)
{
throw new CollectionException(collection, expectedCount, actualCount);
throw CollectionException.ForMismatchedItemCount(expectedCount, actualCount, "Collection lengths not equal.");
}
}

Expand Down Expand Up @@ -42,7 +42,7 @@ public static void SequenceSame<T>(IEnumerable<T> expected, IEnumerable<T> actua
}
else
{
throw new XunitException("Sequences have different lengths");
throw new XunitException("Sequences have different lengths.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public void GetProperty_ExistentProperty()
public void GetPropertyValues_SingleValue()
{
var values = BuildUtilities.GetPropertyValues("MyPropertyValue");
Assert.Collection(values, firstValue => Assert.Equal("MyPropertyValue", firstValue));
var firstValue = Assert.Single(values);
Assert.Equal("MyPropertyValue", firstValue);
}

[Fact]
Expand Down Expand Up @@ -89,9 +90,9 @@ public void GetOrAddProperty_NoGroups()
var project = ProjectRootElementFactory.Create();
BuildUtilities.GetOrAddProperty(project, "MyProperty");
Assert.Single(project.Properties);
Assert.Collection(project.PropertyGroups,
group => Assert.Collection(group.Properties,
firstProperty => Assert.Equal(string.Empty, firstProperty.Value)));
var group = Assert.Single(project.PropertyGroups);
var property = Assert.Single(group.Properties);
Assert.Equal(string.Empty, property.Value);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static Mock<IProjectProperties> MockWithProperties(IEnumerable<string> pr
return mock;
}

public static Mock<IProjectProperties> MockWithPropertyAndValue(string propertyName, string setValue)
public static Mock<IProjectProperties> MockWithPropertyAndValue(string propertyName, string? setValue)
{
return MockWithPropertiesAndValues(new Dictionary<string, string?>() { { propertyName, setValue } });
}
Expand Down Expand Up @@ -72,7 +72,7 @@ public static Mock<IProjectProperties> MockWithPropertiesAndValues(IDictionary<s
public static IProjectProperties CreateWithProperty(string propertyName)
=> MockWithProperty(propertyName).Object;

public static IProjectProperties CreateWithPropertyAndValue(string propertyName, string setValue)
public static IProjectProperties CreateWithPropertyAndValue(string propertyName, string? setValue)
=> MockWithPropertyAndValue(propertyName, setValue).Object;

public static IProjectProperties CreateWithPropertiesAndValues(IDictionary<string, string?> propertyNameAndValues, HashSet<string>? inheritedPropertyNames = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public async Task VerifyExpectedBehaviors(string projectPath, bool crossTargetin

if (expectTargetFrameworkSet)
{
Assert.Equal(expected: 1, actual: globalProperties.Count);
Assert.Single(globalProperties);
Assert.Equal(expected: "myFramework1.0", actual: globalProperties[ConfigurationGeneral.TargetFrameworkProperty]);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task VerifyNoTargetFrameworkOverrideForRegularBuild()
var provider = new TargetFrameworkGlobalBuildPropertyProvider(projectService, configuredProject);

var properties = await provider.GetGlobalPropertiesAsync(CancellationToken.None);
Assert.Equal(0, properties.Count);
Assert.Empty(properties);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ public async Task ReplaceTokensInProfileTests()
[InlineData("this is msbuild: %env3% $(msbuildProperty2) $(msbuildProperty3)", "this is msbuild: Property6 Property2 Property3", true)]
[InlineData(null, null, true)]
[InlineData(" ", " ", true)]
public async Task ReplaceTokensInStringTests(string input, string expected, bool expandEnvVars)
public async Task ReplaceTokensInStringTests(string? input, string? expected, bool expandEnvVars)
{
var replacer = CreateInstance();

// Test msbuild vars
string result = await replacer.ReplaceTokensInStringAsync(input, expandEnvVars);
// Test MSBuild vars
string? result = await replacer.ReplaceTokensInStringAsync(input!, expandEnvVars);
Assert.Equal(expected, result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void GetLogicalFolderNames_EmptyAsFullPath_ThrowsArgument()
[InlineData("C:\\Folder\\Project", "C:\\Folder\\Project\\Source.cs", "Folder\\..\\..\\Source.cs", null)]
[InlineData("C:\\Folder\\Project", "C:\\Folder\\Project\\Source.cs", "D:\\Folder\\Source.cs", null)]
[InlineData("C:\\Folder\\Project", "C:\\Folder\\Project\\Source.cs", "C:\\Folder\\Project\\Source.cs", null)]
public void GetLogicalFolderNames_Returns(string basePath, string fullPath, string link, params string[] expected)
public void GetLogicalFolderNames_Returns(string basePath, string fullPath, string? link, params string?[] expected)
{
var metadata = ImmutableDictionary<string, string>.Empty;
if (link is not null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ namespace Microsoft.VisualStudio.ProjectSystem
public class OnceInitializedOnceDisposedUnderLockAsyncTests
{
[Fact]
public void ExecuteUnderLockAsync_NullAsAction_ThrowsArgumentNullException()
public async Task ExecuteUnderLockAsync_NullAsAction_ThrowsArgumentNullException()
{
var instance = CreateInstance();

Assert.ThrowsAsync<ArgumentNullException>(() =>
await Assert.ThrowsAsync<ArgumentNullException>(() =>
{
return instance.ExecuteUnderLockAsync(null!, CancellationToken.None);
});
}

[Fact]
public void ExecuteUnderLockAsyncOfT_NullAsAction_ThrowsArgumentNullException()
public async Task ExecuteUnderLockAsyncOfT_NullAsAction_ThrowsArgumentNullException()
{
var instance = CreateInstance();

Assert.ThrowsAsync<ArgumentNullException>(() =>
await Assert.ThrowsAsync<ArgumentNullException>(() =>
{
return instance.ExecuteUnderLockAsync<string>(null!, CancellationToken.None);
});
Expand Down Expand Up @@ -364,7 +364,7 @@ private static async Task AssertNoOverlap(Func<Task> firstAction, Func<Task> sec
{
// Run first task and wait until we've entered it
var firstTask = firstAction();
await firstEntered.WaitAsync();
await firstEntered.WaitAsync().WithTimeout(TimeSpan.FromSeconds(30));

// Run second task, we should never enter it
var secondTask = secondAction();
Expand All @@ -374,7 +374,7 @@ private static async Task AssertNoOverlap(Func<Task> firstAction, Func<Task> sec
firstRelease.Set();

// Now we should enter first one
await secondEntered.WaitAsync();
await secondEntered.WaitAsync().WithTimeout(TimeSpan.FromSeconds(30));
await Task.WhenAll(firstTask, secondTask);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static TestProjectFileOrAssemblyInfoPropertiesProvider CreateProviderFor
private static TestProjectFileOrAssemblyInfoPropertiesProvider CreateProviderForProjectFileValidation(
string code,
string propertyName,
string propertyValueInProjectFile,
string? propertyValueInProjectFile,
out Workspace workspace,
Lazy<IInterceptingPropertyValueProvider, IInterceptingPropertyValueProviderMetadata2>? interceptingProvider = null,
Dictionary<string, string?>? additionalProps = null)
Expand Down Expand Up @@ -151,7 +151,7 @@ public async Task SourceFileProperties_GetEvaluatedPropertyAsync(string code, st
[InlineData("""[assembly: System.Reflection.AssemblyDescriptionAttribute(true)]""", "Description", "MyDescription", "MyDescription")]
[InlineData("""[assembly: System.Reflection.AssemblyDescriptionAttribute("MyDescription"]""", "Description", "", "")]
[InlineData("""[assembly: System.Reflection.AssemblyDescriptionAttribute("MyDescription"]""", "Description", null, "")]
public async Task ProjectFileProperties_GetEvaluatedPropertyAsync(string code, string propertyName, string propertyValueInProjectFile, string expectedValue)
public async Task ProjectFileProperties_GetEvaluatedPropertyAsync(string code, string propertyName, string? propertyValueInProjectFile, string expectedValue)
{
var provider = CreateProviderForProjectFileValidation(code, propertyName, propertyValueInProjectFile, out Workspace workspace);
var projectFilePath = workspace.CurrentSolution.Projects.First().FilePath;
Expand Down Expand Up @@ -278,7 +278,7 @@ public async Task ProjectFileProperties_GetUnevaluatedPropertyAsync(string code,
[InlineData("""[assembly: System.Reflection.AssemblyInformationalVersionAttribute("2.0.0")]""", "Version", "2.0.0", null)]
[InlineData("""[assembly: System.Reflection.AssemblyInformationalVersionAttribute("2.0.1-beta1")]""", "Version", "2.0.1-beta1", null)]
[InlineData("""[assembly: System.Reflection.AssemblyInformationalVersionAttribute("2016.2")]""", "Version", "2016.2", null)]
internal async Task SourceFileProperties_DefaultValues_GetEvaluatedPropertyAsync(string code, string propertyName, string expectedValue, Type interceptingProviderType)
internal async Task SourceFileProperties_DefaultValues_GetEvaluatedPropertyAsync(string code, string propertyName, string expectedValue, Type? interceptingProviderType)
{
var interceptingProvider = interceptingProviderType is not null
? new Lazy<IInterceptingPropertyValueProvider, IInterceptingPropertyValueProviderMetadata2>(
Expand Down Expand Up @@ -308,7 +308,7 @@ internal async Task SourceFileProperties_DefaultValues_GetEvaluatedPropertyAsync
[InlineData("MyApp", "Product", null, "")]
[InlineData("MyApp", "Product", "", "")]
[InlineData("MyApp", "Product", "ExistingValue", "ExistingValue")]
internal async Task ProjectFileProperties_DefaultValues_GetEvaluatedPropertyAsync(string assemblyName, string propertyName, string existingPropertyValue, string expectedValue)
internal async Task ProjectFileProperties_DefaultValues_GetEvaluatedPropertyAsync(string assemblyName, string propertyName, string? existingPropertyValue, string expectedValue)
{
var additionalProps = new Dictionary<string, string?>() { { "AssemblyName", assemblyName } };

Expand Down Expand Up @@ -352,7 +352,7 @@ internal async Task ProjectFileProperties_DefaultValues_GetEvaluatedPropertyAsyn
[InlineData("Version", "1.1.1", "1.0.0.0", "1.0.0.0", null)]
[InlineData("Version", "1.0.0", "1.0.0.0", "1.0.0.0", null)]
[InlineData("Version", null, "2016.2", "2016.2", null)]
internal async Task ProjectFileProperties_WithInterception_SetEvaluatedPropertyAsync(string propertyName, string existingPropertyValue, string propertyValueToSet, string expectedValue, Type interceptingProviderType)
internal async Task ProjectFileProperties_WithInterception_SetEvaluatedPropertyAsync(string propertyName, string? existingPropertyValue, string propertyValueToSet, string expectedValue, Type? interceptingProviderType)
{
var interceptingProvider = interceptingProviderType is not null
? new Lazy<IInterceptingPropertyValueProvider, IInterceptingPropertyValueProviderMetadata2>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ApplicationManifestValueProviderTests
[InlineData("", "TRue", "NoManifest")]
[InlineData("", "false", "DefaultManifest")]
[InlineData("", null, "DefaultManifest")]
public async Task GetApplicationManifest(string appManifestPropValue, string noManifestValue, string expectedValue)
public async Task GetApplicationManifest(string appManifestPropValue, string? noManifestValue, string expectedValue)
{
var provider = new ApplicationManifestValueProvider(UnconfiguredProjectFactory.Create());
var defaultProperties = IProjectPropertiesFactory.CreateWithPropertyAndValue("NoWin32Manifest", noManifestValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public async Task WhenAskedForLaunchProfileItemTypes_GetItemsAsyncReturnsAnItemF

items = await itemProvider.GetItemsAsync(LaunchProfileProjectItemProvider.ItemType, "Profile2");

Assert.Collection(items,
item => Assert.Equal("Profile2", item.EvaluatedInclude));
var item = Assert.Single(items);
Assert.Equal("Profile2", item.EvaluatedInclude);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,44 @@ namespace Microsoft.VisualStudio.ProjectSystem.References
public class AlwaysAllowValidProjectReferenceCheckerTests
{
[Fact]
public void CanAddProjectReferenceAsync_NullAsReferencedProject_ThrowsArgumentNull()
public async Task CanAddProjectReferenceAsync_NullAsReferencedProject_ThrowsArgumentNull()
{
var checker = CreateInstance();

Assert.ThrowsAsync<ArgumentNullException>("referencedProject", () =>
await Assert.ThrowsAsync<ArgumentNullException>("referencedProject", () =>
{
return checker.CanAddProjectReferenceAsync(null!);
});
}

[Fact]
public void CanAddProjectReferencesAsync_NullAsReferencedProjects_ThrowsArgumentNull()
public async Task CanAddProjectReferencesAsync_NullAsReferencedProjects_ThrowsArgumentNull()
{
var checker = CreateInstance();

Assert.ThrowsAsync<ArgumentNullException>("referencedProjects", () =>
await Assert.ThrowsAsync<ArgumentNullException>("referencedProjects", () =>
{
return checker.CanAddProjectReferencesAsync(null!);
});
}

[Fact]
public void CanAddProjectReferencesAsync_EmptyAsReferencedProjects_ThrowsArgument()
public async Task CanAddProjectReferencesAsync_EmptyAsReferencedProjects_ThrowsArgument()
{
var checker = CreateInstance();

Assert.ThrowsAsync<ArgumentException>("referencedProjects", () =>
await Assert.ThrowsAsync<ArgumentException>("referencedProjects", () =>
{
return checker.CanAddProjectReferencesAsync(ImmutableHashSet<object>.Empty);
});
}

[Fact]
public void CanBeReferencedAsync_NullAsReferencingProject_ThrowsArgumentNull()
public async Task CanBeReferencedAsync_NullAsReferencingProject_ThrowsArgumentNull()
{
var checker = CreateInstance();

Assert.ThrowsAsync<ArgumentNullException>("referencingProject", () =>
await Assert.ThrowsAsync<ArgumentNullException>("referencingProject", () =>
{
return checker.CanBeReferencedAsync(null!);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ My Project (flags: {Folder AppDesignerFolder BubbleUp})
[InlineData(@"My Project", @"C:\Project\My Project")]
[InlineData(@"Folder\AppDesigner", @"C:\Project\Folder\AppDesigner")]
[InlineData(@"", null)]
public async Task GetFile_WhenTreeWithoutAppDesignerFolder_ReturnsDefaultAppDesignerFolder(string input, string expected)
public async Task GetFile_WhenTreeWithoutAppDesignerFolder_ReturnsDefaultAppDesignerFolder(string input, string? expected)
{
var tree = ProjectTreeParser.Parse(
"""
Expand Down
Loading
Loading