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 several unit test package versions #9056

Closed
wants to merge 2 commits into from
Closed
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
20 changes: 10 additions & 10 deletions eng/imports/Packages.targets
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@
<PackageReference Update="IsExternalInit" Version="1.0.3" PrivateAssets="all" />

<!-- Tests -->
<PackageReference Update="Moq" Version="4.16.1" />
<PackageReference Update="Verify.Xunit" Version="14.2.0" />
<PackageReference Update="xunit" Version="2.4.2-pre.13" />
<PackageReference Update="xunit.analyzers" Version="0.12.0-pre.19"/>
<PackageReference Update="xunit.assert" Version="2.4.2-pre.13" />
<PackageReference Update="Moq" Version="4.18.4" />
<PackageReference Update="Verify.Xunit" Version="17.6.2" />
<PackageReference Update="xunit" Version="2.5.0-pre.11" />
<PackageReference Update="xunit.analyzers" Version="1.2.0-pre.7"/>
<PackageReference Update="xunit.assert" Version="2.5.0-pre.11" />
<PackageReference Update="xunit.combinatorial" Version="1.4.1" />
<PackageReference Update="xunit.extensibility.core" Version="2.4.2-pre.13" />
<PackageReference Update="xunit.extensibility.execution" Version="2.4.2-pre.13" NoWarn="NU1608" />
<PackageReference Update="xunit.runner.console" Version="2.4.1" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Update="xunit.extensibility.core" Version="2.5.0-pre.11" />
<PackageReference Update="xunit.extensibility.execution" Version="2.5.0-pre.11" NoWarn="NU1608" />
<PackageReference Update="xunit.runner.console" Version="2.5.0-pre.11" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.4.5" />

<!-- Integration Tests -->
<PackageReference Update="Microsoft.DotNet.Common.ProjectTemplates.1.x" Version="1.0.0-beta2-20170629-269" />
Expand All @@ -113,4 +113,4 @@
<PackageReference Update="MSTest.TestFramework" Version="2.1.2" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE.md file in the project root for more information.

using System.Collections;
using Xunit.Sdk;

namespace Xunit
{
internal static class AssertEx
{
public static void CollectionLength<T>(IEnumerable<T> collection, int expectedCount)
{
int actualCount = collection.Count();

if (actualCount != expectedCount)
{
throw new CollectionException(collection, expectedCount, actualCount);
}
}

public static void CollectionLength(IEnumerable collection, int expectedCount)
{
CollectionLength(collection.Cast<object>(), expectedCount);
}

public static void SequenceSame<T>(IEnumerable<T> expected, IEnumerable<T> actual) where T : class
{
using IEnumerator<T> expectedEnumerator = expected.GetEnumerator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void GetOrAddProperty_FirstGroup()
var project = ProjectRootElementFactory.Create(projectXml);
BuildUtilities.GetOrAddProperty(project, "MyProperty");
Assert.Single(project.Properties);
AssertEx.CollectionLength(project.PropertyGroups, 2);
Assert.Equal(2, project.PropertyGroups.Count);

var group = project.PropertyGroups.First();
Assert.Single(group.Properties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public async Task GetProjectConfigurationDimensionsAsync()
var (key, value) = Assert.Single(values);
Assert.Equal(DimensionName, key);
string[] dimensionValues = value.ToArray();
AssertEx.CollectionLength(dimensionValues, 3);
Assert.Equal(3, dimensionValues.Length);
Assert.Equal("A", dimensionValues[0]);
Assert.Equal("B", dimensionValues[1]);
Assert.Equal("C", dimensionValues[2]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public async Task ReadProfilesFromDisk_JsonWithExtensionsNoProvider()

var (profiles, globalSettings) = await provider.ReadSettingsFileFromDiskTestAsync();

AssertEx.CollectionLength(profiles, 2);
Assert.Equal(2, profiles.Count());

var (name, value) = Assert.Single(globalSettings);
Assert.Equal("iisSettings", name);
Expand All @@ -337,9 +337,9 @@ public async Task ReadProfilesFromDisk_JsonWithExtensionsWithProvider()
SetJsonSerializationProviders(provider);

var (profiles, globalSettings) = await provider.ReadSettingsFileFromDiskTestAsync();
AssertEx.CollectionLength(profiles, 2);

Assert.Equal(2, profiles.Count());

var (name, value) = Assert.Single(globalSettings);
Assert.Equal("iisSettings", name);
Assert.IsType<IISSettingsData>(value);
Expand Down Expand Up @@ -436,11 +436,11 @@ public async Task LaunchSettingsFile_TestTimeStampFlag()
await moqFS.WriteAllTextAsync(provider.LaunchSettingsFile, JsonStringWithWebSettings);
provider.LastSettingsFileSyncTimeTest = moqFS.GetLastFileWriteTimeOrMinValueUtc(provider.LaunchSettingsFile);
Assert.Equal(provider.LaunchSettingsFile_ChangedTest(), Task.CompletedTask);
AssertEx.CollectionLength(provider.CurrentSnapshot.Profiles, 4);
Assert.Equal(4, provider.CurrentSnapshot.Profiles.Count);

await moqFS.WriteAllTextAsync(provider.LaunchSettingsFile, JsonStringWithWebSettings);
await provider.LaunchSettingsFile_ChangedTest();
AssertEx.CollectionLength(provider.CurrentSnapshot.Profiles, 2);
Assert.Equal(2, provider.CurrentSnapshot.Profiles.Count);
}

[Fact]
Expand Down Expand Up @@ -503,7 +503,7 @@ public async Task UpdateAndSaveProfilesAsync()
Assert.Equal(JsonStringWithWebSettings, await moqFS.ReadAllTextAsync(provider.LaunchSettingsFile), ignoreLineEndingDifferences: true);

// Check snapshot
AssertEx.CollectionLength(provider.CurrentSnapshot.Profiles, 2);
Assert.Equal(2, provider.CurrentSnapshot.Profiles.Count);
Assert.Single(provider.CurrentSnapshot.GlobalSettings);
Assert.Equal(123, ((IVersionedLaunchSettings)provider.CurrentSnapshot).Version);

Expand Down Expand Up @@ -607,7 +607,7 @@ public async Task AddOrUpdateProfileAsync_ProfileDoesntExist(bool addToFront, in
Assert.Equal(!isInMemory, moqFS.FileExists(provider.LaunchSettingsFile));

// Check snapshot
AssertEx.CollectionLength(provider.CurrentSnapshot.Profiles, 3);
Assert.Equal(3, provider.CurrentSnapshot.Profiles.Count);
Assert.Equal("Test", provider.CurrentSnapshot.Profiles[expectedIndex].CommandName);
Assert.Null(provider.CurrentSnapshot.Profiles[expectedIndex].ExecutablePath);
Assert.True(((IVersionedLaunchSettings)provider.CurrentSnapshot).Version >= 123);
Expand Down Expand Up @@ -643,7 +643,7 @@ public async Task AddOrUpdateProfileAsync_ProfileExists(bool addToFront, int exp
Assert.Equal(!isInMemory || (isInMemory && !existingIsInMemory), moqFS.FileExists(provider.LaunchSettingsFile));

// Check snapshot
AssertEx.CollectionLength(provider.CurrentSnapshot.Profiles, 3);
Assert.Equal(3, provider.CurrentSnapshot.Profiles.Count);
Assert.Equal("test", provider.CurrentSnapshot.Profiles[expectedIndex].Name);
Assert.Equal("Test", provider.CurrentSnapshot.Profiles[expectedIndex].CommandName);
Assert.Null(provider.CurrentSnapshot.Profiles[expectedIndex].ExecutablePath);
Expand Down Expand Up @@ -684,7 +684,7 @@ await provider.TryUpdateProfileAsync("test", p =>
Assert.Equal(!isInMemory || (isInMemory && !existingIsInMemory), moqFS.FileExists(provider.LaunchSettingsFile));

// Check snapshot
AssertEx.CollectionLength(provider.CurrentSnapshot.Profiles, 3);
Assert.Equal(3, provider.CurrentSnapshot.Profiles.Count);
Assert.Equal("test", provider.CurrentSnapshot.Profiles[expectedIndex].Name);
Assert.Equal("Test", provider.CurrentSnapshot.Profiles[expectedIndex].CommandName);
Assert.Equal("c:\\test\\project\\bin\\test.exe", provider.CurrentSnapshot.Profiles[expectedIndex].ExecutablePath);
Expand Down Expand Up @@ -717,7 +717,7 @@ public async Task RemoveProfileAsync_ProfileExists(bool isInMemory)
Assert.Equal(!isInMemory, moqFS.FileExists(provider.LaunchSettingsFile));

// Check snapshot
AssertEx.CollectionLength(provider.CurrentSnapshot.Profiles, 2);
Assert.Equal(2, provider.CurrentSnapshot.Profiles.Count);
Assert.Null(provider.CurrentSnapshot.Profiles.FirstOrDefault(p => p.Name!.Equals("test")));
Assert.True(((IVersionedLaunchSettings)provider.CurrentSnapshot).Version >= 123);
}
Expand Down Expand Up @@ -747,7 +747,7 @@ public async Task RemoveProfileAsync_ProfileDoesntExists()
Assert.False(moqFS.FileExists(provider.LaunchSettingsFile));

// Check snapshot
AssertEx.CollectionLength(provider.CurrentSnapshot.Profiles, 2);
Assert.Equal(2, provider.CurrentSnapshot.Profiles.Count);
Assert.Equal(42, ((IVersionedLaunchSettings)provider.CurrentSnapshot).Version);
}

Expand Down Expand Up @@ -775,7 +775,7 @@ public async Task AddOrUpdateGlobalSettingAsync_SettingDoesntExist(bool isInMemo

// Check disk file was written
Assert.Equal(!isInMemory, moqFS.FileExists(provider.LaunchSettingsFile));
AssertEx.CollectionLength(provider.CurrentSnapshot.GlobalSettings, 2);
Assert.Equal(2, provider.CurrentSnapshot.GlobalSettings.Count);

// Check snapshot
Assert.True(provider.CurrentSnapshot.GlobalSettings.TryGetValue("iisSettings", out object? updatedSettings));
Expand Down Expand Up @@ -811,7 +811,7 @@ await provider.UpdateGlobalSettingsAsync(existing => {

// Check disk file was written
Assert.Equal(!isInMemory, moqFS.FileExists(provider.LaunchSettingsFile));
AssertEx.CollectionLength(provider.CurrentSnapshot.GlobalSettings, 2);
Assert.Equal(2, provider.CurrentSnapshot.GlobalSettings.Count);

// Check snapshot
Assert.True(provider.CurrentSnapshot.GlobalSettings.TryGetValue("iisSettings", out object? updatedSettings));
Expand Down Expand Up @@ -849,7 +849,7 @@ public async Task AddOrUpdateGlobalSettingAsync_SettingExists(bool isInMemory, b
Assert.Equal(!isInMemory || (isInMemory && !existingIsInMemory), moqFS.FileExists(provider.LaunchSettingsFile));

// Check snapshot
AssertEx.CollectionLength(provider.CurrentSnapshot.GlobalSettings, 2);
Assert.Equal(2, provider.CurrentSnapshot.GlobalSettings.Count);
Assert.True(provider.CurrentSnapshot.GlobalSettings.TryGetValue("iisSettings", out object? updatedSettings));
Assert.True(((IISSettingsData)updatedSettings).WindowsAuthentication);
Assert.True(((IVersionedLaunchSettings)provider.CurrentSnapshot).Version >= 123);
Expand Down Expand Up @@ -889,7 +889,7 @@ await provider.UpdateGlobalSettingsAsync(existing => {
Assert.Equal(!isInMemory || (isInMemory && !existingIsInMemory), moqFS.FileExists(provider.LaunchSettingsFile));

// Check snapshot
AssertEx.CollectionLength(provider.CurrentSnapshot.GlobalSettings, 2);
Assert.Equal(2, provider.CurrentSnapshot.GlobalSettings.Count);
Assert.True(provider.CurrentSnapshot.GlobalSettings.TryGetValue("iisSettings", out object? updatedSettings));
Assert.True(((IISSettingsData)updatedSettings).WindowsAuthentication);
Assert.True(((IVersionedLaunchSettings)provider.CurrentSnapshot).Version >= 123);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Task DebugProfileEnumValuesGenerator_GetListsValuesAsyncTests()
var generator =
new DebugProfileEnumValuesGenerator(moqProfileProvider.Object, threadingService);
ICollection<IEnumValue> results = await generator.GetListedValuesAsync();
AssertEx.CollectionLength(results, 5);
Assert.Equal(5, results.Count);
Assert.True(results.ElementAt(0).Name == "Profile1" && results.ElementAt(0).DisplayName == "Profile1");
Assert.True(results.ElementAt(1).Name == "MyCommand" && results.ElementAt(1).DisplayName == "MyCommand");
Assert.True(results.ElementAt(2).Name == "Foo" && results.ElementAt(2).DisplayName == "Foo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void UniqueSourceFilesPushedToWorkspace()

handler.Handle(context, 10, added: added, removed: empty, new ContextState(isActiveEditorContext: true, isActiveConfiguration: false), logger: logger);

AssertEx.CollectionLength(sourceFilesPushedToWorkspace, 2);
Assert.Equal(2, sourceFilesPushedToWorkspace.Count);
Assert.Contains(@"C:\file1.cs", sourceFilesPushedToWorkspace);
Assert.Contains(@"C:\file2.cs", sourceFilesPushedToWorkspace);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void DuplicateMetadataReferencesPushedToWorkspace()

handler.Handle(context, 10, added: added, removed: empty, new ContextState(isActiveEditorContext: true, isActiveConfiguration: false), logger: logger);

AssertEx.CollectionLength(referencesPushedToWorkspace, 2);
Assert.Equal(2, referencesPushedToWorkspace.Count);
Assert.Contains(@"C:\Assembly1.dll", referencesPushedToWorkspace);
Assert.Contains(@"C:\Assembly2.dll", referencesPushedToWorkspace);

Expand Down Expand Up @@ -54,7 +54,7 @@ public void RootedReferencesPushedToWorkspace()

handler.Handle(context, 10, added: added, removed: removed, new ContextState(isActiveEditorContext: true, isActiveConfiguration: false), logger: logger);

AssertEx.CollectionLength(referencesPushedToWorkspace, 3);
Assert.Equal(3, referencesPushedToWorkspace.Count);
Assert.Contains(@"C:\ProjectFolder\Assembly1.dll", referencesPushedToWorkspace);
Assert.Contains(@"C:\ProjectFolder\Assembly2.dll", referencesPushedToWorkspace);
Assert.Contains(@"C:\ProjectFolder\Assembly3.dll", referencesPushedToWorkspace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private async Task VerifyOutput(int numberOfOutputExpected, Action actionThatCau
{
if (_outputProduced.Count != numberOfOutputExpected)
{
throw new AssertActualExpectedException(numberOfOutputExpected, _outputProduced.Count, $"Timed out after {TestTimeoutMillisecondsDelay}ms");
throw EqualException.ForMismatchedValues(numberOfOutputExpected, _outputProduced.Count, $"Timed out after {TestTimeoutMillisecondsDelay}ms");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ private async Task VerifyDLLsCompiled(int numberOfDLLsExpected, Action actionTha
var actualDLLs = _compilationResults.Count - initialCompilations;
if (numberOfDLLsExpected != actualDLLs)
{
throw new AssertActualExpectedException(numberOfDLLsExpected, actualDLLs, $"Timed out after {TestTimeoutMillisecondsDelay}ms");
throw EqualException.ForMismatchedValues(numberOfDLLsExpected, actualDLLs, $"Timed out after {TestTimeoutMillisecondsDelay}ms");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ internal async Task VerifyDesignTimeInputsWatched(string[] designTimeInputs, str
// The timeout here is annoying, but even though our test is "smart" and waits for data, unfortunately if the code breaks the test is more likely to hang than fail
if (await Task.WhenAny(finished.Task, Task.Delay(TestTimeoutMillisecondsDelay)) != finished.Task)
{
throw new AssertActualExpectedException(fileChangeNotificationsExpected.Length, notificationCount, $"Timed out after {TestTimeoutMillisecondsDelay}ms");
throw EqualException.ForMismatchedValues(fileChangeNotificationsExpected.Length, notificationCount, $"Timed out after {TestTimeoutMillisecondsDelay}ms");
}

// Observe the task in case of exceptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

using System.IO.Compression;
using Microsoft.VisualStudio.Utilities;
using VerifyTests;
using VerifyXunit;

namespace Microsoft.VisualStudio.Setup
{
Expand All @@ -19,15 +17,15 @@ public Task ProjectSystem()
{
IEnumerable<string> files = GetPackageContents("ProjectSystem.vsix");
VerifierSettings.ScrubLinesContaining(DigitalSignature, Rels);
return Verifier.Verify(files);
return Verify(files);
}

[Fact]
public Task VisualStudioEditorsSetup()
{
IEnumerable<string> files = GetPackageContents("VisualStudioEditorsSetup.vsix");
VerifierSettings.ScrubLinesContaining(DigitalSignature, Rels);
return Verifier.Verify(files);
return Verify(files);
}

[Fact]
Expand All @@ -38,7 +36,7 @@ public Task CommonFiles()
// manifest.json is the last line for non-signed builds.
// It will not contain a comma in this situation, so we need special logic for that.
VerifierSettings.ScrubLinesWithReplace(s => s.EndsWith("manifest.json") ? " manifest.json," : s);
return Verifier.Verify(files);
return Verify(files);
}

private static IEnumerable<string> GetPackageContents(string vsixName)
Expand Down