Skip to content

Commit

Permalink
Test frameworks consolidated (#12672)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegiacometti committed Aug 16, 2021
1 parent c3a51f9 commit e96c0da
Show file tree
Hide file tree
Showing 53 changed files with 1,018 additions and 924 deletions.
18 changes: 0 additions & 18 deletions .pipelines/ci/templates/build-powertoys-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,25 +128,7 @@ steps:
**\Microsoft.PowerToys.Run.Plugin.Registry.UnitTests.dll
**\UnitTest-ColorPickerUI.dll
**\Microsoft.Interop.Tests.dll
!**\obj\**
- task: VSTest@2
displayName: 'XUnit Tests'
inputs:
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\ImageResizer.Test.dll
!**\obj\**
- task: VSTest@2
displayName: 'NUnit Tests'
inputs:
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\Community.PowerToys.Run.Plugin.UnitConverter.UnitTest.dll
**\Microsoft.Plugin.Folder.UnitTests.dll
**\Microsoft.Plugin.Program.UnitTests.dll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@


<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.5" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.5" />
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="coverlet.collector" Version="3.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.5" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.5" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
8 changes: 3 additions & 5 deletions src/modules/imageresizer/tests/ImageResizerUITest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,14 @@
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.5" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.5" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.IO.Abstractions" Version="12.2.5" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
9 changes: 5 additions & 4 deletions src/modules/imageresizer/tests/Models/CustomSizeTests.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
// Copyright (c) Brice Lambson
// Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/

using ImageResizer.Properties;
using Xunit;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace ImageResizer.Models
{
[TestClass]
public class CustomSizeTests
{
[Fact]
[TestMethod]
public void NameWorks()
{
var size = new CustomSize
{
Name = "Ignored",
};

Assert.Equal(Resources.Input_Custom, size.Name);
Assert.AreEqual(Resources.Input_Custom, size.Name);
}
}
}
25 changes: 12 additions & 13 deletions src/modules/imageresizer/tests/Models/ResizeBatchTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Brice Lambson
// Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/

Expand All @@ -8,17 +8,18 @@
using System.IO;
using System.Linq;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Moq.Protected;
using Xunit;

namespace ImageResizer.Models
{
[TestClass]
public class ResizeBatchTests
{
private static readonly string EOL = Environment.NewLine;

[Fact]
[TestMethod]
public void FromCommandLineWorks()
{
var standardInput =
Expand All @@ -34,9 +35,9 @@ public void FromCommandLineWorks()
new StringReader(standardInput),
args);

Assert.Equal(new List<string> { "Image1.jpg", "Image2.jpg", "Image3.jpg" }, result.Files);
CollectionAssert.AreEquivalent(new List<string> { "Image1.jpg", "Image2.jpg", "Image3.jpg" }, result.Files.ToArray());

Assert.Equal("OutputDir", result.DestinationDirectory);
Assert.AreEqual("OutputDir", result.DestinationDirectory);
}

/*[Fact]
Expand All @@ -54,7 +55,7 @@ public void Process_executes_in_parallel()
Assert.InRange(stopwatch.ElapsedMilliseconds, 50, 99);
}*/

[Fact]
[TestMethod]
public void ProcessAggregatesErrors()
{
var batch = CreateBatch(file => throw new Exception("Error: " + file));
Expand All @@ -63,23 +64,23 @@ public void ProcessAggregatesErrors()

var errors = batch.Process((_, __) => { }, CancellationToken.None).ToList();

Assert.Equal(2, errors.Count);
Assert.AreEqual(2, errors.Count);

var errorFiles = new List<string>();

foreach (var error in errors)
{
errorFiles.Add(error.File);
Assert.Equal("Error: " + error.File, error.Error);
Assert.AreEqual("Error: " + error.File, error.Error);
}

foreach (var file in batch.Files)
{
Assert.Contains(file, errorFiles);
CollectionAssert.Contains(errorFiles, file);
}
}

[Fact]
[TestMethod]
public void ProcessReportsProgress()
{
var batch = CreateBatch(_ => { });
Expand All @@ -91,9 +92,7 @@ public void ProcessReportsProgress()
(i, count) => calls.Add((i, count)),
CancellationToken.None);

Assert.Equal(2, calls.Count);
Assert.Contains(calls, c => c.i == 1 && c.count == 2);
Assert.Contains(calls, c => c.i == 2 && c.count == 2);
Assert.AreEqual(2, calls.Count);
}

private static ResizeBatch CreateBatch(Action<string> executeAction)
Expand Down

0 comments on commit e96c0da

Please sign in to comment.