Skip to content

Commit

Permalink
Bump xunit to 2.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
drewnoakes committed May 20, 2024
1 parent a65dcb6 commit 80e3b47
Show file tree
Hide file tree
Showing 24 changed files with 58 additions and 58 deletions.
16 changes: 8 additions & 8 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,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.8.0" />
<PackageVersion Include="xunit.analyzers" Version="1.13.0"/>
<PackageVersion Include="xunit.assert" Version="2.8.0" />
<PackageVersion Include="xunit.combinatorial" Version="1.6.24" />
<PackageVersion Include="xunit.extensibility.core" Version="2.8.0" />
<PackageVersion Include="xunit.extensibility.execution" Version="2.8.0" />
<PackageVersion Include="xunit.runner.console" Version="2.8.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.0" />

<!-- Integration Tests -->
<PackageVersion Include="Microsoft.DotNet.Common.ProjectTemplates.1.x" Version="1.0.0-beta2-20170629-269" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ internal static class AssertEx
{
public static void CollectionLength<T>(IEnumerable<T> collection, int expectedCount)
{
int actualCount = collection.Count();
int count = collection.Count();

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

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
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 @@ -276,7 +276,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 @@ -306,7 +306,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 @@ -350,7 +350,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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async Task<int> func()
await Task.WhenAll(tasks);
for (int i = 0; i < NumberOfTasks; i++)
{
Assert.Equal(i, tasks[i].Result);
Assert.Equal(i, await tasks[i]);
}
}

Expand Down Expand Up @@ -110,11 +110,11 @@ await sequencer.ExecuteTask(async () =>
}

[Fact]
public void CallToDisposedObjectShouldThrow()
public async Task CallToDisposedObjectShouldThrow()
{
var sequencer = new SequentialTaskExecutor(new(_joinableTaskContext), "UnitTests");
sequencer.Dispose();
Assert.ThrowsAsync<ObjectDisposedException>(() => sequencer.ExecuteTask(() => Task.CompletedTask));
await Assert.ThrowsAsync<ObjectDisposedException>(() => sequencer.ExecuteTask(() => Task.CompletedTask));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static IVsHierarchy ImplementGetProperty(int hr)
return mock.Object;
}

public static IVsHierarchy ImplementGetProperty(object result)
public static IVsHierarchy ImplementGetProperty(object? result)
{
var mock = new Mock<IVsHierarchy>();
mock.Setup(h => h.GetProperty(It.IsAny<uint>(), It.IsAny<int>(), out result))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ await Assert.ThrowsAsync<ArgumentException>("path", () =>
[InlineData(@"C:\Path\To\TemplateFile", true)]
[InlineData(@"C:\Path\To\TemplateFile", false)]
[InlineData(null, false)]
public async Task CreateFile(string templateFilePath, bool expectedResult)
public async Task CreateFile(string? templateFilePath, bool expectedResult)
{
string templateName = "SettingsInternal.zip";
string fileName = "Settings.settings";
Expand All @@ -54,7 +54,7 @@ public async Task CreateFile(string templateFilePath, bool expectedResult)
var solution = (Solution)SolutionFactory.CreateWithGetProjectItemTemplate((templateFile, language) =>
{
Assert.Equal(templateName, templateFile);
return templateFilePath;
return templateFilePath!;
});

var vsProject = (IVsProject4)IVsHierarchyFactory.Create();
Expand All @@ -63,7 +63,7 @@ public async Task CreateFile(string templateFilePath, bool expectedResult)
Assert.Equal(VSADDITEMOPERATION.VSADDITEMOP_RUNWIZARD, itemOperation);
Assert.Equal(fileName, itemName);
Assert.Equal((uint)1, cOpen);
Assert.Equal(new string[] { templateFilePath }, files);
Assert.Equal(new string?[] { templateFilePath }, files);

result[0] = expectedResult ? VSADDRESULT.ADDRESULT_Success : VSADDRESULT.ADDRESULT_Failure;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public async Task QueryDebugTargetsAsync_ProjectProfileAsyncF5()
Assert.Equal(@"c:\program files\dotnet\dotnet.exe", targets[0].Executable);
Assert.Equal(DebugLaunchOperation.CreateProcess, targets[0].LaunchOperation);
Assert.Equal(DebuggerEngines.ManagedCoreEngine, targets[0].LaunchDebugEngineGuid);
Assert.Equal(0, targets[0].AdditionalDebugEngines.Count);
Assert.Empty(targets[0].AdditionalDebugEngines);
Assert.Equal("exec \"c:\\test\\project\\bin\\project.dll\" --someArgs", targets[0].Arguments);
}

Expand Down Expand Up @@ -189,7 +189,7 @@ public async Task QueryDebugTargetsAsync_ExeProfileAsyncCtrlF5()
[InlineData(@"bin\")]
[InlineData(@"doesntExist\")]
[InlineData(null)]
public async Task QueryDebugTargetsAsync_ExeProfileAsyncExeRelativeNoWorkingDir(string outdir)
public async Task QueryDebugTargetsAsync_ExeProfileAsyncExeRelativeNoWorkingDir(string? outdir)
{
var properties = new Dictionary<string, string?>
{
Expand Down
Loading

0 comments on commit 80e3b47

Please sign in to comment.