diff --git a/.pipelines/ci/templates/build-powertoys-steps.yml b/.pipelines/ci/templates/build-powertoys-steps.yml
index 2b915c4bda..80fc0383d3 100644
--- a/.pipelines/ci/templates/build-powertoys-steps.yml
+++ b/.pipelines/ci/templates/build-powertoys-steps.yml
@@ -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
diff --git a/src/common/interop/interop-tests/Microsoft.Interop.Tests.csproj b/src/common/interop/interop-tests/Microsoft.Interop.Tests.csproj
index 2001931efd..263863e579 100644
--- a/src/common/interop/interop-tests/Microsoft.Interop.Tests.csproj
+++ b/src/common/interop/interop-tests/Microsoft.Interop.Tests.csproj
@@ -52,9 +52,9 @@
-
-
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/modules/colorPicker/UnitTest-ColorPickerUI/UnitTest-ColorPickerUI.csproj b/src/modules/colorPicker/UnitTest-ColorPickerUI/UnitTest-ColorPickerUI.csproj
index 3b353c7f80..39d27237f4 100644
--- a/src/modules/colorPicker/UnitTest-ColorPickerUI/UnitTest-ColorPickerUI.csproj
+++ b/src/modules/colorPicker/UnitTest-ColorPickerUI/UnitTest-ColorPickerUI.csproj
@@ -28,13 +28,13 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/modules/imageresizer/tests/ImageResizerUITest.csproj b/src/modules/imageresizer/tests/ImageResizerUITest.csproj
index 2a82c19f61..5644684dd3 100644
--- a/src/modules/imageresizer/tests/ImageResizerUITest.csproj
+++ b/src/modules/imageresizer/tests/ImageResizerUITest.csproj
@@ -64,16 +64,14 @@
all
-
+
+
+
all
-
-
- all
-
\ No newline at end of file
diff --git a/src/modules/imageresizer/tests/Models/CustomSizeTests.cs b/src/modules/imageresizer/tests/Models/CustomSizeTests.cs
index bad98b4a35..a3382fa949 100644
--- a/src/modules/imageresizer/tests/Models/CustomSizeTests.cs
+++ b/src/modules/imageresizer/tests/Models/CustomSizeTests.cs
@@ -1,15 +1,16 @@
-// 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
@@ -17,7 +18,7 @@ namespace ImageResizer.Models
Name = "Ignored",
};
- Assert.Equal(Resources.Input_Custom, size.Name);
+ Assert.AreEqual(Resources.Input_Custom, size.Name);
}
}
}
diff --git a/src/modules/imageresizer/tests/Models/ResizeBatchTests.cs b/src/modules/imageresizer/tests/Models/ResizeBatchTests.cs
index a659931651..26cb03d8b0 100644
--- a/src/modules/imageresizer/tests/Models/ResizeBatchTests.cs
+++ b/src/modules/imageresizer/tests/Models/ResizeBatchTests.cs
@@ -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/
@@ -8,17 +8,18 @@ using System.Collections.Generic;
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 =
@@ -34,9 +35,9 @@ namespace ImageResizer.Models
new StringReader(standardInput),
args);
- Assert.Equal(new List { "Image1.jpg", "Image2.jpg", "Image3.jpg" }, result.Files);
+ CollectionAssert.AreEquivalent(new List { "Image1.jpg", "Image2.jpg", "Image3.jpg" }, result.Files.ToArray());
- Assert.Equal("OutputDir", result.DestinationDirectory);
+ Assert.AreEqual("OutputDir", result.DestinationDirectory);
}
/*[Fact]
@@ -54,7 +55,7 @@ namespace ImageResizer.Models
Assert.InRange(stopwatch.ElapsedMilliseconds, 50, 99);
}*/
- [Fact]
+ [TestMethod]
public void ProcessAggregatesErrors()
{
var batch = CreateBatch(file => throw new Exception("Error: " + file));
@@ -63,23 +64,23 @@ namespace ImageResizer.Models
var errors = batch.Process((_, __) => { }, CancellationToken.None).ToList();
- Assert.Equal(2, errors.Count);
+ Assert.AreEqual(2, errors.Count);
var errorFiles = new List();
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(_ => { });
@@ -91,9 +92,7 @@ namespace ImageResizer.Models
(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 executeAction)
diff --git a/src/modules/imageresizer/tests/Models/ResizeOperationTests.cs b/src/modules/imageresizer/tests/Models/ResizeOperationTests.cs
index 90ec1b0501..93cd302910 100644
--- a/src/modules/imageresizer/tests/Models/ResizeOperationTests.cs
+++ b/src/modules/imageresizer/tests/Models/ResizeOperationTests.cs
@@ -1,24 +1,25 @@
-// 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 System;
-using System.Collections.ObjectModel;
using System.IO;
+using System.Linq;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using ImageResizer.Properties;
using ImageResizer.Test;
-using Xunit;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ImageResizer.Models
{
+ [TestClass]
public class ResizeOperationTests : IDisposable
{
private readonly TestDirectory _directory = new TestDirectory();
private bool disposedValue;
- [Fact]
+ [TestMethod]
public void ExecuteCopiesFrameMetadata()
{
var operation = new ResizeOperation("Test.jpg", _directory, Settings());
@@ -27,10 +28,10 @@ namespace ImageResizer.Models
AssertEx.Image(
_directory.File(),
- image => Assert.Equal("Test", ((BitmapMetadata)image.Frames[0].Metadata).Comment));
+ image => Assert.AreEqual("Test", ((BitmapMetadata)image.Frames[0].Metadata).Comment));
}
- [Fact]
+ [TestMethod]
public void ExecuteCopiesFrameMetadataExceptWhenMetadataCannotBeCloned()
{
var operation = new ResizeOperation("TestMetadataIssue2447.jpg", _directory, Settings());
@@ -39,20 +40,20 @@ namespace ImageResizer.Models
AssertEx.Image(
_directory.File(),
- image => Assert.Null(((BitmapMetadata)image.Frames[0].Metadata).CameraModel));
+ image => Assert.IsNull(((BitmapMetadata)image.Frames[0].Metadata).CameraModel));
}
- [Fact]
+ [TestMethod]
public void ExecuteKeepsDateModified()
{
var operation = new ResizeOperation("Test.png", _directory, Settings(s => s.KeepDateModified = true));
operation.Execute();
- Assert.Equal(File.GetLastWriteTimeUtc("Test.png"), File.GetLastWriteTimeUtc(_directory.File()));
+ Assert.AreEqual(File.GetLastWriteTimeUtc("Test.png"), File.GetLastWriteTimeUtc(_directory.File()));
}
- [Fact]
+ [TestMethod]
public void ExecuteKeepsDateModifiedWhenReplacingOriginals()
{
var path = Path.Combine(_directory, "Test.png");
@@ -72,10 +73,10 @@ namespace ImageResizer.Models
operation.Execute();
- Assert.Equal(originalDateModified, File.GetLastWriteTimeUtc(_directory.File()));
+ Assert.AreEqual(originalDateModified, File.GetLastWriteTimeUtc(_directory.File()));
}
- [Fact]
+ [TestMethod]
public void ExecuteReplacesOriginals()
{
var path = Path.Combine(_directory, "Test.png");
@@ -85,10 +86,10 @@ namespace ImageResizer.Models
operation.Execute();
- AssertEx.Image(_directory.File(), image => Assert.Equal(96, image.Frames[0].PixelWidth));
+ AssertEx.Image(_directory.File(), image => Assert.AreEqual(96, image.Frames[0].PixelWidth));
}
- [Fact]
+ [TestMethod]
public void ExecuteTransformsEachFrame()
{
var operation = new ResizeOperation("Test.gif", _directory, Settings());
@@ -99,12 +100,12 @@ namespace ImageResizer.Models
_directory.File(),
image =>
{
- Assert.Equal(2, image.Frames.Count);
- AssertEx.All(image.Frames, frame => Assert.Equal(96, frame.PixelWidth));
+ Assert.AreEqual(2, image.Frames.Count);
+ AssertEx.All(image.Frames, frame => Assert.AreEqual(96, frame.PixelWidth));
});
}
- [Fact]
+ [TestMethod]
public void ExecuteUsesFallbackEncoder()
{
var operation = new ResizeOperation(
@@ -114,10 +115,10 @@ namespace ImageResizer.Models
operation.Execute();
- Assert.Contains("Test (Test).png", _directory.FileNames);
+ CollectionAssert.Contains(_directory.FileNames.ToList(), "Test (Test).png");
}
- [Fact]
+ [TestMethod]
public void TransformIgnoresOrientationWhenLandscapeToPortrait()
{
var operation = new ResizeOperation(
@@ -137,12 +138,12 @@ namespace ImageResizer.Models
_directory.File(),
image =>
{
- Assert.Equal(192, image.Frames[0].PixelWidth);
- Assert.Equal(96, image.Frames[0].PixelHeight);
+ Assert.AreEqual(192, image.Frames[0].PixelWidth);
+ Assert.AreEqual(96, image.Frames[0].PixelHeight);
});
}
- [Fact]
+ [TestMethod]
public void TransformIgnoresOrientationWhenPortraitToLandscape()
{
var operation = new ResizeOperation(
@@ -162,12 +163,12 @@ namespace ImageResizer.Models
_directory.File(),
image =>
{
- Assert.Equal(96, image.Frames[0].PixelWidth);
- Assert.Equal(192, image.Frames[0].PixelHeight);
+ Assert.AreEqual(96, image.Frames[0].PixelWidth);
+ Assert.AreEqual(192, image.Frames[0].PixelHeight);
});
}
- [Fact]
+ [TestMethod]
public void TransformIgnoresIgnoreOrientationWhenAuto()
{
var operation = new ResizeOperation(
@@ -187,12 +188,12 @@ namespace ImageResizer.Models
_directory.File(),
image =>
{
- Assert.Equal(96, image.Frames[0].PixelWidth);
- Assert.Equal(48, image.Frames[0].PixelHeight);
+ Assert.AreEqual(96, image.Frames[0].PixelWidth);
+ Assert.AreEqual(48, image.Frames[0].PixelHeight);
});
}
- [Fact]
+ [TestMethod]
public void TransformIgnoresIgnoreOrientationWhenPercent()
{
var operation = new ResizeOperation(
@@ -214,12 +215,12 @@ namespace ImageResizer.Models
_directory.File(),
image =>
{
- Assert.Equal(96, image.Frames[0].PixelWidth);
- Assert.Equal(192, image.Frames[0].PixelHeight);
+ Assert.AreEqual(96, image.Frames[0].PixelWidth);
+ Assert.AreEqual(192, image.Frames[0].PixelHeight);
});
}
- [Fact]
+ [TestMethod]
public void TransformHonorsShrinkOnly()
{
var operation = new ResizeOperation(
@@ -239,12 +240,12 @@ namespace ImageResizer.Models
_directory.File(),
image =>
{
- Assert.Equal(192, image.Frames[0].PixelWidth);
- Assert.Equal(96, image.Frames[0].PixelHeight);
+ Assert.AreEqual(192, image.Frames[0].PixelWidth);
+ Assert.AreEqual(96, image.Frames[0].PixelHeight);
});
}
- [Fact]
+ [TestMethod]
public void TransformIgnoresShrinkOnlyWhenPercent()
{
var operation = new ResizeOperation(
@@ -264,12 +265,12 @@ namespace ImageResizer.Models
_directory.File(),
image =>
{
- Assert.Equal(256, image.Frames[0].PixelWidth);
- Assert.Equal(128, image.Frames[0].PixelHeight);
+ Assert.AreEqual(256, image.Frames[0].PixelWidth);
+ Assert.AreEqual(128, image.Frames[0].PixelHeight);
});
}
- [Fact]
+ [TestMethod]
public void TransformHonorsShrinkOnlyWhenAutoHeight()
{
var operation = new ResizeOperation(
@@ -287,10 +288,10 @@ namespace ImageResizer.Models
AssertEx.Image(
_directory.File(),
- image => Assert.Equal(192, image.Frames[0].PixelWidth));
+ image => Assert.AreEqual(192, image.Frames[0].PixelWidth));
}
- [Fact]
+ [TestMethod]
public void TransformHonorsShrinkOnlyWhenAutoWidth()
{
var operation = new ResizeOperation(
@@ -308,10 +309,10 @@ namespace ImageResizer.Models
AssertEx.Image(
_directory.File(),
- image => Assert.Equal(96, image.Frames[0].PixelHeight));
+ image => Assert.AreEqual(96, image.Frames[0].PixelHeight));
}
- [Fact]
+ [TestMethod]
public void TransformHonorsUnit()
{
var operation = new ResizeOperation(
@@ -327,10 +328,10 @@ namespace ImageResizer.Models
operation.Execute();
- AssertEx.Image(_directory.File(), image => Assert.Equal(image.Frames[0].DpiX, image.Frames[0].PixelWidth, 0));
+ AssertEx.Image(_directory.File(), image => Assert.AreEqual(Math.Ceiling(image.Frames[0].DpiX), image.Frames[0].PixelWidth));
}
- [Fact]
+ [TestMethod]
public void TransformHonorsFitWhenFit()
{
var operation = new ResizeOperation(
@@ -344,12 +345,12 @@ namespace ImageResizer.Models
_directory.File(),
image =>
{
- Assert.Equal(96, image.Frames[0].PixelWidth);
- Assert.Equal(48, image.Frames[0].PixelHeight);
+ Assert.AreEqual(96, image.Frames[0].PixelWidth);
+ Assert.AreEqual(48, image.Frames[0].PixelHeight);
});
}
- [Fact]
+ [TestMethod]
public void TransformHonorsFitWhenFill()
{
var operation = new ResizeOperation(
@@ -363,13 +364,13 @@ namespace ImageResizer.Models
_directory.File(),
image =>
{
- Assert.Equal(Colors.White, image.Frames[0].GetFirstPixel());
- Assert.Equal(96, image.Frames[0].PixelWidth);
- Assert.Equal(96, image.Frames[0].PixelHeight);
+ Assert.AreEqual(Colors.White, image.Frames[0].GetFirstPixel());
+ Assert.AreEqual(96, image.Frames[0].PixelWidth);
+ Assert.AreEqual(96, image.Frames[0].PixelHeight);
});
}
- [Fact]
+ [TestMethod]
public void TransformHonorsFitWhenStretch()
{
var operation = new ResizeOperation(
@@ -383,13 +384,13 @@ namespace ImageResizer.Models
_directory.File(),
image =>
{
- Assert.Equal(Colors.Black, image.Frames[0].GetFirstPixel());
- Assert.Equal(96, image.Frames[0].PixelWidth);
- Assert.Equal(96, image.Frames[0].PixelHeight);
+ Assert.AreEqual(Colors.Black, image.Frames[0].GetFirstPixel());
+ Assert.AreEqual(96, image.Frames[0].PixelWidth);
+ Assert.AreEqual(96, image.Frames[0].PixelHeight);
});
}
- [Fact]
+ [TestMethod]
public void GetDestinationPathUniquifiesOutputFilename()
{
File.WriteAllBytes(Path.Combine(_directory, "Test (Test).png"), Array.Empty());
@@ -398,10 +399,10 @@ namespace ImageResizer.Models
operation.Execute();
- Assert.Contains("Test (Test) (1).png", _directory.FileNames);
+ CollectionAssert.Contains(_directory.FileNames.ToList(), "Test (Test) (1).png");
}
- [Fact]
+ [TestMethod]
public void GetDestinationPathUniquifiesOutputFilenameAgain()
{
File.WriteAllBytes(Path.Combine(_directory, "Test (Test).png"), Array.Empty());
@@ -411,10 +412,10 @@ namespace ImageResizer.Models
operation.Execute();
- Assert.Contains("Test (Test) (2).png", _directory.FileNames);
+ CollectionAssert.Contains(_directory.FileNames.ToList(), "Test (Test) (2).png");
}
- [Fact]
+ [TestMethod]
public void GetDestinationPathUsesFileNameFormat()
{
var operation = new ResizeOperation(
@@ -424,10 +425,10 @@ namespace ImageResizer.Models
operation.Execute();
- Assert.Contains("Test_Test_96_96_96_48.png", _directory.FileNames);
+ CollectionAssert.Contains(_directory.FileNames.ToList(), "Test_Test_96_96_96_48.png");
}
- [Fact]
+ [TestMethod]
public void ExecuteHandlesDirectoriesInFileNameFormat()
{
var operation = new ResizeOperation(
@@ -437,7 +438,7 @@ namespace ImageResizer.Models
operation.Execute();
- Assert.True(File.Exists(_directory + @"\Directory\Test (Test).png"));
+ Assert.IsTrue(File.Exists(_directory + @"\Directory\Test (Test).png"));
}
private static Settings Settings(Action action = null)
diff --git a/src/modules/imageresizer/tests/Models/ResizeSizeTests.cs b/src/modules/imageresizer/tests/Models/ResizeSizeTests.cs
index a79a10d68b..93e296f9aa 100644
--- a/src/modules/imageresizer/tests/Models/ResizeSizeTests.cs
+++ b/src/modules/imageresizer/tests/Models/ResizeSizeTests.cs
@@ -1,18 +1,20 @@
-// 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 System;
using System.Collections.Generic;
using System.ComponentModel;
using ImageResizer.Properties;
using ImageResizer.Test;
-using Xunit;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ImageResizer.Models
{
+ [TestClass]
public class ResizeSizeTests
{
- [Fact]
+ [TestMethod]
public void NameWorks()
{
var size = new ResizeSize();
@@ -22,11 +24,11 @@ namespace ImageResizer.Models
h => size.PropertyChanged -= h,
() => size.Name = "Test");
- Assert.Equal("Test", size.Name);
- Assert.Equal(nameof(ResizeSize.Name), e.Arguments.PropertyName);
+ Assert.AreEqual("Test", size.Name);
+ Assert.AreEqual(nameof(ResizeSize.Name), e.Arguments.PropertyName);
}
- [Fact]
+ [TestMethod]
public void NameReplacesTokens()
{
var args = new List<(string, string)>
@@ -43,11 +45,11 @@ namespace ImageResizer.Models
Name = name,
};
- Assert.Equal(expected, size.Name);
+ Assert.AreEqual(expected, size.Name);
}
}
- [Fact]
+ [TestMethod]
public void FitWorks()
{
var size = new ResizeSize();
@@ -57,11 +59,11 @@ namespace ImageResizer.Models
h => size.PropertyChanged -= h,
() => size.Fit = ResizeFit.Stretch);
- Assert.Equal(ResizeFit.Stretch, size.Fit);
- Assert.Equal(nameof(ResizeSize.Fit), e.Arguments.PropertyName);
+ Assert.AreEqual(ResizeFit.Stretch, size.Fit);
+ Assert.AreEqual(nameof(ResizeSize.Fit), e.Arguments.PropertyName);
}
- [Fact]
+ [TestMethod]
public void WidthWorks()
{
var size = new ResizeSize();
@@ -71,11 +73,11 @@ namespace ImageResizer.Models
h => size.PropertyChanged -= h,
() => size.Width = 42);
- Assert.Equal(42, size.Width);
- Assert.Equal(nameof(ResizeSize.Width), e.Arguments.PropertyName);
+ Assert.AreEqual(42, size.Width);
+ Assert.AreEqual(nameof(ResizeSize.Width), e.Arguments.PropertyName);
}
- [Fact]
+ [TestMethod]
public void HeightWorks()
{
var size = new ResizeSize();
@@ -85,11 +87,11 @@ namespace ImageResizer.Models
h => size.PropertyChanged -= h,
() => size.Height = 42);
- Assert.Equal(42, size.Height);
- Assert.Equal(nameof(ResizeSize.Height), e.Arguments.PropertyName);
+ Assert.AreEqual(42, size.Height);
+ Assert.AreEqual(nameof(ResizeSize.Height), e.Arguments.PropertyName);
}
- [Fact]
+ [TestMethod]
public void HasAutoReturnsTrueWhenWidthUnset()
{
var size = new ResizeSize
@@ -98,10 +100,10 @@ namespace ImageResizer.Models
Height = 42,
};
- Assert.True(size.HasAuto);
+ Assert.IsTrue(size.HasAuto);
}
- [Fact]
+ [TestMethod]
public void HasAutoReturnsTrueWhenHeightUnset()
{
var size = new ResizeSize
@@ -110,10 +112,10 @@ namespace ImageResizer.Models
Height = 0,
};
- Assert.True(size.HasAuto);
+ Assert.IsTrue(size.HasAuto);
}
- [Fact]
+ [TestMethod]
public void HasAutoReturnsFalseWhenWidthAndHeightSet()
{
var size = new ResizeSize
@@ -122,10 +124,10 @@ namespace ImageResizer.Models
Height = 42,
};
- Assert.False(size.HasAuto);
+ Assert.IsFalse(size.HasAuto);
}
- [Fact]
+ [TestMethod]
public void UnitWorks()
{
var size = new ResizeSize();
@@ -135,11 +137,11 @@ namespace ImageResizer.Models
h => size.PropertyChanged -= h,
() => size.Unit = ResizeUnit.Inch);
- Assert.Equal(ResizeUnit.Inch, size.Unit);
- Assert.Equal(nameof(ResizeSize.Unit), e.Arguments.PropertyName);
+ Assert.AreEqual(ResizeUnit.Inch, size.Unit);
+ Assert.AreEqual(nameof(ResizeSize.Unit), e.Arguments.PropertyName);
}
- [Fact]
+ [TestMethod]
public void GetPixelWidthWorks()
{
var size = new ResizeSize
@@ -150,10 +152,10 @@ namespace ImageResizer.Models
var result = size.GetPixelWidth(100, 96);
- Assert.Equal(96, result);
+ Assert.AreEqual(96, result);
}
- [Fact]
+ [TestMethod]
public void GetPixelHeightWorks()
{
var size = new ResizeSize
@@ -164,12 +166,12 @@ namespace ImageResizer.Models
var result = size.GetPixelHeight(100, 96);
- Assert.Equal(96, result);
+ Assert.AreEqual(96, result);
}
- [Theory]
- [InlineData(ResizeFit.Fit)]
- [InlineData(ResizeFit.Fill)]
+ [DataTestMethod]
+ [DataRow(ResizeFit.Fit)]
+ [DataRow(ResizeFit.Fill)]
public void GetPixelHeightUsesWidthWhenScaleByPercent(ResizeFit fit)
{
var size = new ResizeSize
@@ -182,10 +184,10 @@ namespace ImageResizer.Models
var result = size.GetPixelHeight(100, 96);
- Assert.Equal(100, result);
+ Assert.AreEqual(100, result);
}
- [Fact]
+ [TestMethod]
public void ConvertToPixelsWorksWhenAutoAndFit()
{
var size = new ResizeSize
@@ -196,10 +198,10 @@ namespace ImageResizer.Models
var result = size.GetPixelWidth(100, 96);
- Assert.Equal(double.PositiveInfinity, result);
+ Assert.AreEqual(double.PositiveInfinity, result);
}
- [Fact]
+ [TestMethod]
public void ConvertToPixelsWorksWhenAutoAndNotFit()
{
var size = new ResizeSize
@@ -210,10 +212,10 @@ namespace ImageResizer.Models
var result = size.GetPixelWidth(100, 96);
- Assert.Equal(100, result);
+ Assert.AreEqual(100, result);
}
- [Fact]
+ [TestMethod]
public void ConvertToPixelsWorksWhenInches()
{
var size = new ResizeSize
@@ -224,10 +226,10 @@ namespace ImageResizer.Models
var result = size.GetPixelWidth(100, 96);
- Assert.Equal(48, result);
+ Assert.AreEqual(48, result);
}
- [Fact]
+ [TestMethod]
public void ConvertToPixelsWorksWhenCentimeters()
{
var size = new ResizeSize
@@ -238,10 +240,10 @@ namespace ImageResizer.Models
var result = size.GetPixelWidth(100, 96);
- Assert.Equal(38, result, 0);
+ Assert.AreEqual(38, Math.Ceiling(result));
}
- [Fact]
+ [TestMethod]
public void ConvertToPixelsWorksWhenPercent()
{
var size = new ResizeSize
@@ -252,10 +254,10 @@ namespace ImageResizer.Models
var result = size.GetPixelWidth(200, 96);
- Assert.Equal(100, result);
+ Assert.AreEqual(100, result);
}
- [Fact]
+ [TestMethod]
public void ConvertToPixelsWorksWhenPixels()
{
var size = new ResizeSize
@@ -266,20 +268,20 @@ namespace ImageResizer.Models
var result = size.GetPixelWidth(100, 96);
- Assert.Equal(50, result);
+ Assert.AreEqual(50, result);
}
- [Theory]
- [InlineData(ResizeFit.Fill, ResizeUnit.Centimeter)]
- [InlineData(ResizeFit.Fill, ResizeUnit.Inch)]
- [InlineData(ResizeFit.Fill, ResizeUnit.Pixel)]
- [InlineData(ResizeFit.Fit, ResizeUnit.Centimeter)]
- [InlineData(ResizeFit.Fit, ResizeUnit.Inch)]
- [InlineData(ResizeFit.Fit, ResizeUnit.Pixel)]
- [InlineData(ResizeFit.Stretch, ResizeUnit.Centimeter)]
- [InlineData(ResizeFit.Stretch, ResizeUnit.Inch)]
- [InlineData(ResizeFit.Stretch, ResizeUnit.Percent)]
- [InlineData(ResizeFit.Stretch, ResizeUnit.Pixel)]
+ [DataTestMethod]
+ [DataRow(ResizeFit.Fill, ResizeUnit.Centimeter)]
+ [DataRow(ResizeFit.Fill, ResizeUnit.Inch)]
+ [DataRow(ResizeFit.Fill, ResizeUnit.Pixel)]
+ [DataRow(ResizeFit.Fit, ResizeUnit.Centimeter)]
+ [DataRow(ResizeFit.Fit, ResizeUnit.Inch)]
+ [DataRow(ResizeFit.Fit, ResizeUnit.Pixel)]
+ [DataRow(ResizeFit.Stretch, ResizeUnit.Centimeter)]
+ [DataRow(ResizeFit.Stretch, ResizeUnit.Inch)]
+ [DataRow(ResizeFit.Stretch, ResizeUnit.Percent)]
+ [DataRow(ResizeFit.Stretch, ResizeUnit.Pixel)]
public void HeightVisible(ResizeFit fit, ResizeUnit unit)
{
var size = new ResizeSize
@@ -288,12 +290,12 @@ namespace ImageResizer.Models
Unit = unit,
};
- Assert.True(size.ShowHeight);
+ Assert.IsTrue(size.ShowHeight);
}
- [Theory]
- [InlineData(ResizeFit.Fill, ResizeUnit.Percent)]
- [InlineData(ResizeFit.Fit, ResizeUnit.Percent)]
+ [DataTestMethod]
+ [DataRow(ResizeFit.Fill, ResizeUnit.Percent)]
+ [DataRow(ResizeFit.Fit, ResizeUnit.Percent)]
public void HeightNotVisible(ResizeFit fit, ResizeUnit unit)
{
var size = new ResizeSize
@@ -302,7 +304,7 @@ namespace ImageResizer.Models
Unit = unit,
};
- Assert.False(size.ShowHeight);
+ Assert.IsFalse(size.ShowHeight);
}
}
}
diff --git a/src/modules/imageresizer/tests/Properties/AppFixture.cs b/src/modules/imageresizer/tests/Properties/AppFixture.cs
deleted file mode 100644
index 433a869cb1..0000000000
--- a/src/modules/imageresizer/tests/Properties/AppFixture.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-
-[module: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1636:FileHeaderCopyrightTextMustMatch", Justification = "File created under PowerToys.")]
-
-namespace ImageResizer.Properties
-{
- public class AppFixture : IDisposable
- {
- public AppFixture()
- {
- // new App() needs to be created since Settings.Reload() uses App.Current to update properties on the UI thread. App() can be created only once otherwise it results in System.InvalidOperationException : Cannot create more than one System.Windows.Application instance in the same AppDomain.
- _imageResizerApp = new App();
- }
-
- [System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0052:Remove unread private members", Justification = "new App() needs to be created since Settings.Reload() uses App.Current to update properties on the UI thread. App() can be created only once otherwise it results in System.InvalidOperationException : Cannot create more than one System.Windows.Application instance in the same AppDomain")]
- private App _imageResizerApp;
- private bool _disposedValue;
-
- protected virtual void Dispose(bool disposing)
- {
- if (!_disposedValue)
- {
- if (disposing)
- {
- _imageResizerApp.Dispose();
- _imageResizerApp = null;
- }
-
- // TODO: free unmanaged resources (unmanaged objects) and override finalizer
- // TODO: set large fields to null
- _disposedValue = true;
- }
- }
-
- public void Dispose()
- {
- // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
- Dispose(disposing: true);
- GC.SuppressFinalize(this);
- }
- }
-}
diff --git a/src/modules/imageresizer/tests/Properties/SettingsTests.cs b/src/modules/imageresizer/tests/Properties/SettingsTests.cs
index 67f9be0f4e..799f3e1c68 100644
--- a/src/modules/imageresizer/tests/Properties/SettingsTests.cs
+++ b/src/modules/imageresizer/tests/Properties/SettingsTests.cs
@@ -1,23 +1,21 @@
-// 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 System;
-using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
+using System.Linq;
using ImageResizer.Models;
using ImageResizer.Test;
-using Xunit;
-using Xunit.Abstractions;
-using Xunit.Extensions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ImageResizer.Properties
{
- public class SettingsTests : IClassFixture, IDisposable
+ [TestClass]
+ public class SettingsTests
{
- private bool disposedValue;
+ private static App _imageResizerApp;
public SettingsTests()
{
@@ -25,7 +23,16 @@ namespace ImageResizer.Properties
Settings.SettingsPath = ".\\test_settings.json";
}
- [Fact]
+ [ClassInitialize]
+#pragma warning disable CA1801 // Review unused parameters
+ public static void ClassInitialize(TestContext context)
+#pragma warning restore CA1801 // Review unused parameters
+ {
+ // new App() needs to be created since Settings.Reload() uses App.Current to update properties on the UI thread. App() can be created only once otherwise it results in System.InvalidOperationException : Cannot create more than one System.Windows.Application instance in the same AppDomain.
+ _imageResizerApp = new App();
+ }
+
+ [TestMethod]
public void AllSizesPropagatesSizesCollectionEvents()
{
var settings = new Settings
@@ -41,10 +48,10 @@ namespace ImageResizer.Properties
h => ncc.CollectionChanged -= h,
() => settings.Sizes.Add(new ResizeSize()));
- Assert.Equal(NotifyCollectionChangedAction.Add, result.Arguments.Action);
+ Assert.AreEqual(NotifyCollectionChangedAction.Add, result.Arguments.Action);
}
- [Fact]
+ [TestMethod]
public void AllSizesPropagatesSizesPropertyEvents()
{
var settings = new Settings
@@ -53,13 +60,22 @@ namespace ImageResizer.Properties
};
settings.Sizes.Clear();
- Assert.PropertyChanged(
- (INotifyPropertyChanged)settings.AllSizes,
- "Item[]",
- () => settings.Sizes.Add(new ResizeSize()));
+
+ var result = false;
+ ((INotifyPropertyChanged)settings.AllSizes).PropertyChanged += (sender, e) =>
+ {
+ if (e.PropertyName == "Item[]")
+ {
+ result = true;
+ }
+ };
+
+ settings.Sizes.Add(new ResizeSize());
+
+ Assert.IsTrue(result);
}
- [Fact]
+ [TestMethod]
public void AllSizesContainsSizes()
{
var settings = new Settings
@@ -68,10 +84,10 @@ namespace ImageResizer.Properties
};
settings.Sizes.Add(new ResizeSize());
- Assert.Contains(settings.Sizes[0], settings.AllSizes);
+ CollectionAssert.Contains(settings.AllSizes.ToList(), settings.Sizes[0]);
}
- [Fact]
+ [TestMethod]
public void AllSizesContainsCustomSize()
{
var settings = new Settings
@@ -80,10 +96,10 @@ namespace ImageResizer.Properties
};
settings.Sizes.Clear();
- Assert.Contains(settings.CustomSize, settings.AllSizes);
+ CollectionAssert.Contains(settings.AllSizes.ToList(), settings.CustomSize);
}
- [Fact]
+ [TestMethod]
public void AllSizesHandlesPropertyEventsForCustomSize()
{
var originalCustomSize = new CustomSize();
@@ -100,29 +116,29 @@ namespace ImageResizer.Properties
h => ncc.CollectionChanged -= h,
() => settings.CustomSize = new CustomSize());
- Assert.Equal(NotifyCollectionChangedAction.Replace, result.Arguments.Action);
- Assert.Equal(1, result.Arguments.NewItems.Count);
- Assert.Equal(settings.CustomSize, result.Arguments.NewItems[0]);
- Assert.Equal(0, result.Arguments.NewStartingIndex);
- Assert.Equal(1, result.Arguments.OldItems.Count);
- Assert.Equal(originalCustomSize, result.Arguments.OldItems[0]);
- Assert.Equal(0, result.Arguments.OldStartingIndex);
+ Assert.AreEqual(NotifyCollectionChangedAction.Replace, result.Arguments.Action);
+ Assert.AreEqual(1, result.Arguments.NewItems.Count);
+ Assert.AreEqual(settings.CustomSize, result.Arguments.NewItems[0]);
+ Assert.AreEqual(0, result.Arguments.NewStartingIndex);
+ Assert.AreEqual(1, result.Arguments.OldItems.Count);
+ Assert.AreEqual(originalCustomSize, result.Arguments.OldItems[0]);
+ Assert.AreEqual(0, result.Arguments.OldStartingIndex);
}
- [Fact]
+ [TestMethod]
public void FileNameFormatWorks()
{
var settings = new Settings { FileName = "{T}%1e%2s%3t%4%5%6%7" };
var result = settings.FileNameFormat;
- Assert.Equal("{{T}}{0}e{1}s{2}t{3}{4}{5}%7", result);
+ Assert.AreEqual("{{T}}{0}e{1}s{2}t{3}{4}{5}%7", result);
}
- [Theory]
- [InlineData(0)]
- [InlineData(1)]
- [InlineData(2)]
+ [DataTestMethod]
+ [DataRow(0)]
+ [DataRow(1)]
+ [DataRow(2)]
public void SelectedSizeReturnsCustomSizeWhenOutOfRange(int index)
{
var settings = new Settings
@@ -134,10 +150,10 @@ namespace ImageResizer.Properties
var result = settings.SelectedSize;
- Assert.Same(settings.CustomSize, result);
+ Assert.AreEqual(settings.CustomSize, result);
}
- [Fact]
+ [TestMethod]
public void SelectedSizeReturnsSizeWhenInRange()
{
var settings = new Settings
@@ -148,22 +164,22 @@ namespace ImageResizer.Properties
settings.Sizes.Add(new ResizeSize());
var result = settings.SelectedSize;
- Assert.Same(settings.Sizes[0], result);
+ Assert.AreEqual(settings.Sizes[0], result);
}
- [Fact]
+ [TestMethod]
public void IDataErrorInfoErrorReturnsEmpty()
{
var settings = new Settings();
var result = ((IDataErrorInfo)settings).Error;
- Assert.Empty(result);
+ Assert.AreEqual(result, string.Empty);
}
- [Theory]
- [InlineData(0)]
- [InlineData(101)]
+ [DataTestMethod]
+ [DataRow(0)]
+ [DataRow(101)]
public void IDataErrorInfoItemJpegQualityLevelReturnsErrorWhenOutOfRange(int value)
{
var settings = new Settings { JpegQualityLevel = value };
@@ -171,129 +187,180 @@ namespace ImageResizer.Properties
var result = ((IDataErrorInfo)settings)["JpegQualityLevel"];
// Using InvariantCulture since this is used internally
- Assert.Equal(
+ Assert.AreEqual(
string.Format(CultureInfo.InvariantCulture, Resources.ValueMustBeBetween, 1, 100),
result);
}
- [Theory]
- [InlineData(1)]
- [InlineData(100)]
+ [DataTestMethod]
+ [DataRow(1)]
+ [DataRow(100)]
public void IDataErrorInfoItemJpegQualityLevelReturnsEmptyWhenInRange(int value)
{
var settings = new Settings { JpegQualityLevel = value };
var result = ((IDataErrorInfo)settings)["JpegQualityLevel"];
- Assert.Empty(result);
+ Assert.AreEqual(result, string.Empty);
}
- [Fact]
+ [TestMethod]
public void IDataErrorInfoItemReturnsEmptyWhenNotJpegQualityLevel()
{
var settings = new Settings();
var result = ((IDataErrorInfo)settings)["Unknown"];
- Assert.Empty(result);
+ Assert.AreEqual(result, string.Empty);
}
- [Fact]
+ [TestMethod]
public void ReloadCreatesFileWhenFileNotFound()
{
// Arrange
var settings = new Settings();
// Assert
- Assert.False(System.IO.File.Exists(Settings.SettingsPath));
+ Assert.IsFalse(System.IO.File.Exists(Settings.SettingsPath));
// Act
settings.Reload();
// Assert
- Assert.True(System.IO.File.Exists(Settings.SettingsPath));
+ Assert.IsTrue(System.IO.File.Exists(Settings.SettingsPath));
}
- [Fact]
+ [TestMethod]
public void SaveCreatesFile()
{
// Arrange
var settings = new Settings();
// Assert
- Assert.False(System.IO.File.Exists(Settings.SettingsPath));
+ Assert.IsFalse(System.IO.File.Exists(Settings.SettingsPath));
// Act
settings.Save();
// Assert
- Assert.True(System.IO.File.Exists(Settings.SettingsPath));
+ Assert.IsTrue(System.IO.File.Exists(Settings.SettingsPath));
}
- [Fact]
+ [TestMethod]
public void SaveJsonIsReadableByReload()
{
// Arrange
var settings = new Settings();
// Assert
- Assert.False(System.IO.File.Exists(Settings.SettingsPath));
+ Assert.IsFalse(System.IO.File.Exists(Settings.SettingsPath));
// Act
settings.Save();
settings.Reload(); // If the JSON file created by Save() is not readable this function will throw an error
// Assert
- Assert.True(System.IO.File.Exists(Settings.SettingsPath));
+ Assert.IsTrue(System.IO.File.Exists(Settings.SettingsPath));
}
- [Fact]
+ [TestMethod]
public void ReloadRaisesPropertyChanged()
{
// Arrange
var settings = new Settings();
settings.Save(); // To create the settings file
+ var shrinkOnlyChanged = false;
+ var replaceChanged = false;
+ var ignoreOrientationChanged = false;
+ var jpegQualityLevelChanged = false;
+ var pngInterlaceOptionChanged = false;
+ var tiffCompressOptionChanged = false;
+ var fileNameChanged = false;
+ var keepDateModifiedChanged = false;
+ var fallbackEncoderChanged = false;
+ var customSizeChanged = false;
+ var selectedSizeIndexChanged = false;
+
+ settings.PropertyChanged += (sender, e) =>
+ {
+ if (e.PropertyName == "ShrinkOnly")
+ {
+ shrinkOnlyChanged = true;
+ }
+ else if (e.PropertyName == "Replace")
+ {
+ replaceChanged = true;
+ }
+ else if (e.PropertyName == "IgnoreOrientation")
+ {
+ ignoreOrientationChanged = true;
+ }
+ else if (e.PropertyName == "JpegQualityLevel")
+ {
+ jpegQualityLevelChanged = true;
+ }
+ else if (e.PropertyName == "PngInterlaceOption")
+ {
+ pngInterlaceOptionChanged = true;
+ }
+ else if (e.PropertyName == "TiffCompressOption")
+ {
+ tiffCompressOptionChanged = true;
+ }
+ else if (e.PropertyName == "FileName")
+ {
+ fileNameChanged = true;
+ }
+ else if (e.PropertyName == "KeepDateModified")
+ {
+ keepDateModifiedChanged = true;
+ }
+ else if (e.PropertyName == "FallbackEncoder")
+ {
+ fallbackEncoderChanged = true;
+ }
+ else if (e.PropertyName == "CustomSize")
+ {
+ customSizeChanged = true;
+ }
+ else if (e.PropertyName == "SelectedSizeIndex")
+ {
+ selectedSizeIndexChanged = true;
+ }
+ };
+
// Act
- var action = new System.Action(settings.Reload);
+ settings.Reload();
// Assert
- Assert.PropertyChanged(settings, "ShrinkOnly", action);
- Assert.PropertyChanged(settings, "Replace", action);
- Assert.PropertyChanged(settings, "IgnoreOrientation", action);
- Assert.PropertyChanged(settings, "JpegQualityLevel", action);
- Assert.PropertyChanged(settings, "PngInterlaceOption", action);
- Assert.PropertyChanged(settings, "TiffCompressOption", action);
- Assert.PropertyChanged(settings, "FileName", action);
- Assert.PropertyChanged(settings, "KeepDateModified", action);
- Assert.PropertyChanged(settings, "FallbackEncoder", action);
- Assert.PropertyChanged(settings, "CustomSize", action);
- Assert.PropertyChanged(settings, "SelectedSizeIndex", action);
+ Assert.IsTrue(shrinkOnlyChanged);
+ Assert.IsTrue(replaceChanged);
+ Assert.IsTrue(ignoreOrientationChanged);
+ Assert.IsTrue(jpegQualityLevelChanged);
+ Assert.IsTrue(pngInterlaceOptionChanged);
+ Assert.IsTrue(tiffCompressOptionChanged);
+ Assert.IsTrue(fileNameChanged);
+ Assert.IsTrue(keepDateModifiedChanged);
+ Assert.IsTrue(fallbackEncoderChanged);
+ Assert.IsTrue(customSizeChanged);
+ Assert.IsTrue(selectedSizeIndexChanged);
}
- protected virtual void Dispose(bool disposing)
+ [ClassCleanup]
+ public static void ClassCleanup()
{
- if (!disposedValue)
+ _imageResizerApp.Dispose();
+ _imageResizerApp = null;
+ }
+
+ [TestCleanup]
+ public void TestCleanUp()
+ {
+ if (System.IO.File.Exists(Settings.SettingsPath))
{
- if (disposing)
- {
- if (System.IO.File.Exists(Settings.SettingsPath))
- {
- System.IO.File.Delete(Settings.SettingsPath);
- }
- }
-
- // TODO: free unmanaged resources (unmanaged objects) and override finalizer
- // TODO: set large fields to null
- disposedValue = true;
+ System.IO.File.Delete(Settings.SettingsPath);
}
}
-
- public void Dispose()
- {
- // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
- Dispose(disposing: true);
- GC.SuppressFinalize(this);
- }
}
}
diff --git a/src/modules/imageresizer/tests/Test/AssertEx.cs b/src/modules/imageresizer/tests/Test/AssertEx.cs
index 1251e6f245..5c05ecec44 100644
--- a/src/modules/imageresizer/tests/Test/AssertEx.cs
+++ b/src/modules/imageresizer/tests/Test/AssertEx.cs
@@ -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/
@@ -8,7 +8,9 @@ using System.Collections.Specialized;
using System.ComponentModel;
using System.IO.Abstractions;
using System.Windows.Media.Imaging;
-using Xunit;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+[module: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1636:FileHeaderCopyrightTextMustMatch", Justification = "File created under PowerToys.")]
namespace ImageResizer.Test
{
@@ -50,7 +52,7 @@ namespace ImageResizer.Test
testCode();
detach(handler);
- Assert.NotNull(raisedEvent);
+ Assert.IsNotNull(raisedEvent);
return raisedEvent;
}
@@ -68,7 +70,7 @@ namespace ImageResizer.Test
testCode();
detach(handler);
- Assert.NotNull(raisedEvent);
+ Assert.IsNotNull(raisedEvent);
return raisedEvent;
}
diff --git a/src/modules/imageresizer/tests/Test/TestDirectory.cs b/src/modules/imageresizer/tests/Test/TestDirectory.cs
index ef56289f3e..1db98133e7 100644
--- a/src/modules/imageresizer/tests/Test/TestDirectory.cs
+++ b/src/modules/imageresizer/tests/Test/TestDirectory.cs
@@ -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/
@@ -8,7 +8,6 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
-using Xunit;
using IOPath = System.IO.Path;
namespace ImageResizer
@@ -32,8 +31,7 @@ namespace ImageResizer
public IEnumerable FileNames
=> Files.Select(IOPath.GetFileName);
- public string File()
- => Assert.Single(Files);
+ public string File() => Files.Single();
public static implicit operator string(TestDirectory directory)
{
diff --git a/src/modules/imageresizer/tests/Views/TimeRemainingConverterTests.cs b/src/modules/imageresizer/tests/Views/TimeRemainingConverterTests.cs
index 189f1ff050..f832d87fc4 100644
--- a/src/modules/imageresizer/tests/Views/TimeRemainingConverterTests.cs
+++ b/src/modules/imageresizer/tests/Views/TimeRemainingConverterTests.cs
@@ -1,28 +1,27 @@
-// 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 System;
using System.Globalization;
using ImageResizer.Properties;
-using Xunit;
-using Xunit.Extensions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ImageResizer.Views
{
public class TimeRemainingConverterTests
{
- [Theory]
- [InlineData("HourMinute", 1, 1, 0)]
- [InlineData("HourMinutes", 1, 2, 0)]
- [InlineData("HoursMinute", 2, 1, 0)]
- [InlineData("HoursMinutes", 2, 2, 0)]
- [InlineData("MinuteSecond", 0, 1, 1)]
- [InlineData("MinuteSeconds", 0, 1, 2)]
- [InlineData("MinutesSecond", 0, 2, 1)]
- [InlineData("MinutesSeconds", 0, 2, 2)]
- [InlineData("Second", 0, 0, 1)]
- [InlineData("Seconds", 0, 0, 2)]
+ [DataTestMethod]
+ [DataRow("HourMinute", 1, 1, 0)]
+ [DataRow("HourMinutes", 1, 2, 0)]
+ [DataRow("HoursMinute", 2, 1, 0)]
+ [DataRow("HoursMinutes", 2, 2, 0)]
+ [DataRow("MinuteSecond", 0, 1, 1)]
+ [DataRow("MinuteSeconds", 0, 1, 2)]
+ [DataRow("MinutesSecond", 0, 2, 1)]
+ [DataRow("MinutesSeconds", 0, 2, 2)]
+ [DataRow("Second", 0, 0, 1)]
+ [DataRow("Seconds", 0, 0, 2)]
public void ConvertWorks(string resource, int hours, int minutes, int seconds)
{
var timeRemaining = new TimeSpan(hours, minutes, seconds);
@@ -35,7 +34,7 @@ namespace ImageResizer.Views
parameter: null,
CultureInfo.InvariantCulture);
- Assert.Equal(
+ Assert.AreEqual(
string.Format(
CultureInfo.InvariantCulture,
Resources.ResourceManager.GetString("Progress_TimeRemaining_" + resource, CultureInfo.InvariantCulture),
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest.csproj b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest.csproj
index d30c233c44..df81c98476 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest.csproj
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest.csproj
@@ -21,9 +21,9 @@
-
-
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/InputInterpreterTests.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/InputInterpreterTests.cs
index cf09485649..92b5c19b1d 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/InputInterpreterTests.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/InputInterpreterTests.cs
@@ -3,55 +3,60 @@
// See the LICENSE file in the project root for more information.
using System.Globalization;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wox.Plugin;
namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
{
- [TestFixture]
+ [TestClass]
public class InputInterpreterTests
{
- [TestCase(new string[] { "1,5'" }, new string[] { "1,5", "'" })]
- [TestCase(new string[] { "1.5'" }, new string[] { "1.5", "'" })]
- [TestCase(new string[] { "1'" }, new string[] { "1", "'" })]
- [TestCase(new string[] { "1'5\"" }, new string[] { "1", "'", "5", "\"" })]
- [TestCase(new string[] { "5\"" }, new string[] { "5", "\"" })]
- [TestCase(new string[] { "1'5" }, new string[] { "1", "'", "5" })]
+ [DataTestMethod]
+ [DataRow(new string[] { "1,5'" }, new object[] { new string[] { "1,5", "'" } })]
+ [DataRow(new string[] { "1.5'" }, new object[] { new string[] { "1.5", "'" } })]
+ [DataRow(new string[] { "1'" }, new object[] { new string[] { "1", "'" } })]
+ [DataRow(new string[] { "1'5\"" }, new object[] { new string[] { "1", "'", "5", "\"" } })]
+ [DataRow(new string[] { "5\"" }, new object[] { new string[] { "5", "\"" } })]
+ [DataRow(new string[] { "1'5" }, new object[] { new string[] { "1", "'", "5" } })]
public void RegexSplitsInput(string[] input, string[] expectedResult)
{
string[] shortsplit = InputInterpreter.RegexSplitter(input);
- Assert.AreEqual(expectedResult, shortsplit);
+ CollectionAssert.AreEqual(expectedResult, shortsplit);
}
- [TestCase(new string[] { "1cm", "to", "mm" }, new string[] { "1", "cm", "to", "mm" })]
+ [DataTestMethod]
+ [DataRow(new string[] { "1cm", "to", "mm" }, new object[] { new string[] { "1", "cm", "to", "mm" } })]
public void InsertsSpaces(string[] input, string[] expectedResult)
{
InputInterpreter.InputSpaceInserter(ref input);
- Assert.AreEqual(expectedResult, input);
+ CollectionAssert.AreEqual(expectedResult, input);
}
- [TestCase(new string[] { "1'", "in", "cm" }, new string[] { "1", "foot", "in", "cm" })]
- [TestCase(new string[] { "1\"", "in", "cm" }, new string[] { "1", "inch", "in", "cm" })]
- [TestCase(new string[] { "1'6", "in", "cm" }, new string[] { "1.5", "foot", "in", "cm" })]
- [TestCase(new string[] { "1'6\"", "in", "cm" }, new string[] { "1.5", "foot", "in", "cm" })]
+ [DataTestMethod]
+ [DataRow(new string[] { "1'", "in", "cm" }, new object[] { new string[] { "1", "foot", "in", "cm" } })]
+ [DataRow(new string[] { "1\"", "in", "cm" }, new object[] { new string[] { "1", "inch", "in", "cm" } })]
+ [DataRow(new string[] { "1'6", "in", "cm" }, new object[] { new string[] { "1.5", "foot", "in", "cm" } })]
+ [DataRow(new string[] { "1'6\"", "in", "cm" }, new object[] { new string[] { "1.5", "foot", "in", "cm" } })]
public void HandlesShorthandFeetInchNotation(string[] input, string[] expectedResult)
{
InputInterpreter.ShorthandFeetInchHandler(ref input, CultureInfo.InvariantCulture);
- Assert.AreEqual(expectedResult, input);
+ CollectionAssert.AreEqual(expectedResult, input);
}
- [TestCase(new string[] { "5", "CeLsIuS", "in", "faHrenheiT" }, new string[] { "5", "DegreeCelsius", "in", "DegreeFahrenheit" })]
- [TestCase(new string[] { "5", "f", "in", "celsius" }, new string[] { "5", "°f", "in", "DegreeCelsius" })]
- [TestCase(new string[] { "5", "c", "in", "f" }, new string[] { "5", "°c", "in", "°f" })]
- [TestCase(new string[] { "5", "f", "in", "c" }, new string[] { "5", "°f", "in", "°c" })]
+ [DataTestMethod]
+ [DataRow(new string[] { "5", "CeLsIuS", "in", "faHrenheiT" }, new object[] { new string[] { "5", "DegreeCelsius", "in", "DegreeFahrenheit" } })]
+ [DataRow(new string[] { "5", "f", "in", "celsius" }, new object[] { new string[] { "5", "°f", "in", "DegreeCelsius" } })]
+ [DataRow(new string[] { "5", "c", "in", "f" }, new object[] { new string[] { "5", "°c", "in", "°f" } })]
+ [DataRow(new string[] { "5", "f", "in", "c" }, new object[] { new string[] { "5", "°f", "in", "°c" } })]
public void PrefixesDegrees(string[] input, string[] expectedResult)
{
InputInterpreter.DegreePrefixer(ref input);
- Assert.AreEqual(expectedResult, input);
+ CollectionAssert.AreEqual(expectedResult, input);
}
- [TestCase("a f in c")]
- [TestCase("12 f in")]
+ [DataTestMethod]
+ [DataRow("a f in c")]
+ [DataRow("12 f in")]
public void ParseInvalidQueries(string queryString)
{
Query query = new Query(queryString);
@@ -59,8 +64,9 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
Assert.AreEqual(null, result);
}
- [TestCase("12 f in c", 12)]
- [TestCase("10m to cm", 10)]
+ [DataTestMethod]
+ [DataRow("12 f in c", 12)]
+ [DataRow("10m to cm", 10)]
public void ParseValidQueries(string queryString, double result)
{
Query query = new Query(queryString);
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/UnitHandlerTests.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/UnitHandlerTests.cs
index fb18180569..f7ef57fdc2 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/UnitHandlerTests.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/UnitHandlerTests.cs
@@ -3,14 +3,14 @@
// See the LICENSE file in the project root for more information.
using System.Linq;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
{
- [TestFixture]
+ [TestClass]
public class UnitHandlerTests
{
- [Test]
+ [TestMethod]
public void HandleTemperature()
{
var convertModel = new ConvertModel(1, "DegreeCelsius", "DegreeFahrenheit");
@@ -18,7 +18,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
Assert.AreEqual(33.79999999999999d, result);
}
- [Test]
+ [TestMethod]
public void HandleLength()
{
var convertModel = new ConvertModel(1, "meter", "centimeter");
@@ -26,7 +26,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
Assert.AreEqual(100, result);
}
- [Test]
+ [TestMethod]
public void HandlesByteCapitals()
{
var convertModel = new ConvertModel(1, "kB", "kb");
@@ -34,7 +34,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
Assert.AreEqual(8, result);
}
- [Test]
+ [TestMethod]
public void HandleInvalidModel()
{
var convertModel = new ConvertModel(1, "aa", "bb");
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/DriveOrSharedFolderTests.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/DriveOrSharedFolderTests.cs
index 78ebef1b43..1c6ea106f6 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/DriveOrSharedFolderTests.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/DriveOrSharedFolderTests.cs
@@ -4,26 +4,29 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using Microsoft.Plugin.Folder.Sources;
using Microsoft.Plugin.Folder.Sources.Result;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
-using NUnit.Framework;
namespace Microsoft.Plugin.Folder.UnitTests
{
+ [TestClass]
public class DriveOrSharedFolderTests
{
- [TestCase(@"\\test-server\testdir", true)]
- [TestCase(@"c:", true)]
- [TestCase(@"c:\", true)]
- [TestCase(@"C:\", true)]
- [TestCase(@"d:\", true)]
- [TestCase(@"z:\", false)]
- [TestCase(@"nope.exe", false)]
- [TestCase(@"win32\test.dll", false)]
- [TestCase(@"a\b\c\d", false)]
- [TestCase(@"D", false)]
- [TestCase(@"ZZ:\test", false)]
+ [DataTestMethod]
+ [DataRow(@"\\test-server\testdir", true)]
+ [DataRow(@"c:", true)]
+ [DataRow(@"c:\", true)]
+ [DataRow(@"C:\", true)]
+ [DataRow(@"d:\", true)]
+ [DataRow(@"z:\", false)]
+ [DataRow(@"nope.exe", false)]
+ [DataRow(@"win32\test.dll", false)]
+ [DataRow(@"a\b\c\d", false)]
+ [DataRow(@"D", false)]
+ [DataRow(@"ZZ:\test", false)]
public void IsDriveOrSharedFolder_WhenCalled(string search, bool expectedSuccess)
{
// Setup
@@ -42,15 +45,16 @@ namespace Microsoft.Plugin.Folder.UnitTests
Assert.AreEqual(expectedSuccess, isDriveOrSharedFolder);
}
- [TestCase('A', true)]
- [TestCase('C', true)]
- [TestCase('c', true)]
- [TestCase('Z', true)]
- [TestCase('z', true)]
- [TestCase('ª', false)]
- [TestCase('α', false)]
- [TestCase('Ω', false)]
- [TestCase('É€', false)]
+ [DataTestMethod]
+ [DataRow('A', true)]
+ [DataRow('C', true)]
+ [DataRow('c', true)]
+ [DataRow('Z', true)]
+ [DataRow('z', true)]
+ [DataRow('ª', false)]
+ [DataRow('α', false)]
+ [DataRow('Ω', false)]
+ [DataRow('É€', false)]
public void ValidDriveLetter_WhenCalled(char letter, bool expectedSuccess)
{
// Setup
@@ -61,10 +65,11 @@ namespace Microsoft.Plugin.Folder.UnitTests
Assert.AreEqual(expectedSuccess, isDriveOrSharedFolder);
}
- [TestCase("C:", true)]
- [TestCase("C:\test", true)]
- [TestCase("D:", false)]
- [TestCase("INVALID", false)]
+ [DataTestMethod]
+ [DataRow("C:", true)]
+ [DataRow("C:\test", true)]
+ [DataRow("D:", false)]
+ [DataRow("INVALID", false)]
public void GenerateMaxFiles_WhenCalled(string search, bool hasValues)
{
// Setup
@@ -88,11 +93,11 @@ namespace Microsoft.Plugin.Folder.UnitTests
// Assert
if (hasValues)
{
- CollectionAssert.IsNotEmpty(results);
+ Assert.IsTrue(results.Count() > 0);
}
else
{
- CollectionAssert.IsEmpty(results);
+ Assert.IsTrue(results.Count() == 0);
}
}
}
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/InternalQueryFolderTests.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/InternalQueryFolderTests.cs
index 2f1b133ffe..b73908c750 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/InternalQueryFolderTests.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/InternalQueryFolderTests.cs
@@ -4,22 +4,21 @@
using System;
using System.Collections.Generic;
-using System.IO;
using System.IO.Abstractions.TestingHelpers;
using System.Linq;
using Microsoft.Plugin.Folder.Sources;
using Microsoft.Plugin.Folder.Sources.Result;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Microsoft.Plugin.Folder.UnitTests
{
- [TestFixture]
+ [TestClass]
public class InternalQueryFolderTests
{
private static IQueryFileSystemInfo _queryFileSystemInfoMock;
private static MockFileSystem _fileSystem;
- [SetUp]
+ [TestInitialize]
public void SetupMock()
{
// Note: This mock filesystem adds a 'c:\temp' directory.
@@ -35,23 +34,24 @@ namespace Microsoft.Plugin.Folder.UnitTests
_queryFileSystemInfoMock = new QueryFileSystemInfo(_fileSystem.DirectoryInfo);
}
- [Test]
+ [TestMethod]
public void Query_ThrowsException_WhenCalledNull()
{
// Setup
var queryInternalDirectory = new QueryInternalDirectory(new FolderSettings(), _queryFileSystemInfoMock, _fileSystem.Directory);
// Act & Assert
- Assert.Throws(() => queryInternalDirectory.Query(null).ToArray());
+ Assert.ThrowsException(() => queryInternalDirectory.Query(null).ToArray());
}
- [TestCase(@"c", 0, 0, false, Reason = "String empty is nothing")]
- [TestCase(@"c:", 2, 1, false, Reason = "Root without \\")]
- [TestCase(@"c:\", 2, 1, false, Reason = "Normal root")]
- [TestCase(@"c:\Test", 2, 2, false, Reason = "Select yourself")]
- [TestCase(@"c:\not-exist", 2, 1, false, Reason = "Folder not exist, return root")]
- [TestCase(@"c:\not-exist\not-exist2", 0, 0, false, Reason = "Folder not exist, return root")]
- [TestCase(@"c:\bla.t", 2, 1, false, Reason = "Partial match file")]
+ [DataTestMethod]
+ [DataRow(@"c", 0, 0, false, DisplayName = "String empty is nothing")]
+ [DataRow(@"c:", 2, 1, false, DisplayName = "Root without \\")]
+ [DataRow(@"c:\", 2, 1, false, DisplayName = "Normal root")]
+ [DataRow(@"c:\Test", 2, 2, false, DisplayName = "Select yourself")]
+ [DataRow(@"c:\not-exist", 2, 1, false, DisplayName = "Folder not exist, return root")]
+ [DataRow(@"c:\not-exist\not-exist2", 0, 0, false, DisplayName = "Folder not exist, return root")]
+ [DataRow(@"c:\bla.t", 2, 1, false, DisplayName = "Partial match file")]
public void Query_WhenCalled(string search, int folders, int files, bool truncated)
{
const int maxFolderSetting = 3;
@@ -74,8 +74,8 @@ namespace Microsoft.Plugin.Folder.UnitTests
Assert.AreEqual(folders, isDriveOrSharedFolder[typeof(FolderItemResult)].Count(), "folder count doesn't match");
// Always check if there is less than max folders
- Assert.LessOrEqual(isDriveOrSharedFolder[typeof(FileItemResult)].Count(), maxFolderSetting, "Files are not limited");
- Assert.LessOrEqual(isDriveOrSharedFolder[typeof(FolderItemResult)].Count(), maxFolderSetting, "Folders are not limited");
+ Assert.IsTrue(isDriveOrSharedFolder[typeof(FileItemResult)].Count() <= maxFolderSetting, "Files are not limited");
+ Assert.IsTrue(isDriveOrSharedFolder[typeof(FolderItemResult)].Count() <= maxFolderSetting, "Folders are not limited");
// Checks if CreateOpenCurrentFolder is displayed
Assert.AreEqual(Math.Min(folders + files, 1), isDriveOrSharedFolder[typeof(CreateOpenCurrentFolderResult)].Count(), "CreateOpenCurrentFolder displaying is incorrect");
@@ -83,10 +83,11 @@ namespace Microsoft.Plugin.Folder.UnitTests
Assert.AreEqual(truncated, isDriveOrSharedFolder[typeof(TruncatedItemResult)].Count() == 1, "CreateOpenCurrentFolder displaying is incorrect");
}
- [TestCase(@"c:\>", 3, 3, true, Reason = "Max Folder test recursive")]
- [TestCase(@"c:\Test>", 3, 3, true, Reason = "2 Folders recursive")]
- [TestCase(@"c:\not-exist>", 3, 3, true, Reason = "Folder not exist, return root recursive")]
- [TestCase(@"c:\not-exist\not-exist2>", 0, 0, false, Reason = "Folder not exist, return root recursive")]
+ [DataTestMethod]
+ [DataRow(@"c:\>", 3, 3, true, DisplayName = "Max Folder test recursive")]
+ [DataRow(@"c:\Test>", 3, 3, true, DisplayName = "2 Folders recursive")]
+ [DataRow(@"c:\not-exist>", 3, 3, true, DisplayName = "Folder not exist, return root recursive")]
+ [DataRow(@"c:\not-exist\not-exist2>", 0, 0, false, DisplayName = "Folder not exist, return root recursive")]
public void Query_Recursive_WhenCalled(string search, int folders, int files, bool truncated)
{
const int maxFolderSetting = 3;
@@ -109,8 +110,8 @@ namespace Microsoft.Plugin.Folder.UnitTests
Assert.AreEqual(folders, isDriveOrSharedFolder[typeof(FolderItemResult)].Count(), "folder count doesn't match");
// Always check if there is less than max folders
- Assert.LessOrEqual(isDriveOrSharedFolder[typeof(FileItemResult)].Count(), maxFolderSetting, "Files are not limited");
- Assert.LessOrEqual(isDriveOrSharedFolder[typeof(FolderItemResult)].Count(), maxFolderSetting, "Folders are not limited");
+ Assert.IsTrue(isDriveOrSharedFolder[typeof(FileItemResult)].Count() <= maxFolderSetting, "Files are not limited");
+ Assert.IsTrue(isDriveOrSharedFolder[typeof(FolderItemResult)].Count() <= maxFolderSetting, "Folders are not limited");
// Checks if CreateOpenCurrentFolder is displayed
Assert.AreEqual(Math.Min(folders + files, 1), isDriveOrSharedFolder[typeof(CreateOpenCurrentFolderResult)].Count(), "CreateOpenCurrentFolder displaying is incorrect");
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/Microsoft.Plugin.Folder.UnitTests.csproj b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/Microsoft.Plugin.Folder.UnitTests.csproj
index 613d6a9f66..fdb9f0a4c0 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/Microsoft.Plugin.Folder.UnitTests.csproj
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/Microsoft.Plugin.Folder.UnitTests.csproj
@@ -11,9 +11,9 @@
-
-
-
+
+
+
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Microsoft.Plugin.Program.UnitTests.csproj b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Microsoft.Plugin.Program.UnitTests.csproj
index 4cf3c81355..ecff2a34c0 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Microsoft.Plugin.Program.UnitTests.csproj
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Microsoft.Plugin.Program.UnitTests.csproj
@@ -26,9 +26,9 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
+
+
+
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/ProgramArgumentParser/ProgramArgumentParserTests.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/ProgramArgumentParser/ProgramArgumentParserTests.cs
index aa8178ddc5..12f1d8221e 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/ProgramArgumentParser/ProgramArgumentParserTests.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/ProgramArgumentParser/ProgramArgumentParserTests.cs
@@ -3,25 +3,25 @@
// See the LICENSE file in the project root for more information.
using Microsoft.Plugin.Program.ProgramArgumentParser;
-using Mono.Collections.Generic;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wox.Plugin;
namespace Microsoft.Plugin.Program.UnitTests.ProgramArgumentParser
{
- [TestFixture]
+ [TestClass]
public class ProgramArgumentParserTests
{
- [TestCase("Microsoft Edge", "Microsoft Edge", null)]
- [TestCase("Microsoft Edge ---inprivate", "Microsoft Edge ---inprivate", null)]
- [TestCase("Microsoft Edge -- -inprivate", "Microsoft Edge", "-inprivate")]
- [TestCase("Microsoft Edge -inprivate", "Microsoft Edge", "-inprivate")]
- [TestCase("Microsoft Edge /inprivate", "Microsoft Edge", "/inprivate")]
- [TestCase("edge.exe --inprivate", "edge.exe", "--inprivate")]
- [TestCase("edge.exe -- --inprivate", "edge.exe", "--inprivate")]
- [TestCase("edge.exe", "edge.exe", null)]
- [TestCase("edge", "edge", null)]
- [TestCase("cmd /c \"ping 1.1.1.1\"", "cmd", "/c \"ping 1.1.1.1\"")]
+ [DataTestMethod]
+ [DataRow("Microsoft Edge", "Microsoft Edge", null)]
+ [DataRow("Microsoft Edge ---inprivate", "Microsoft Edge ---inprivate", null)]
+ [DataRow("Microsoft Edge -- -inprivate", "Microsoft Edge", "-inprivate")]
+ [DataRow("Microsoft Edge -inprivate", "Microsoft Edge", "-inprivate")]
+ [DataRow("Microsoft Edge /inprivate", "Microsoft Edge", "/inprivate")]
+ [DataRow("edge.exe --inprivate", "edge.exe", "--inprivate")]
+ [DataRow("edge.exe -- --inprivate", "edge.exe", "--inprivate")]
+ [DataRow("edge.exe", "edge.exe", null)]
+ [DataRow("edge", "edge", null)]
+ [DataRow("cmd /c \"ping 1.1.1.1\"", "cmd", "/c \"ping 1.1.1.1\"")]
public void ProgramArgumentParserTestsCanParseQuery(string inputQuery, string expectedProgram, string expectedProgramArguments)
{
// Arrange
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/UWPTests.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/UWPTests.cs
index 2ba526781b..c0dacc4683 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/UWPTests.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/UWPTests.cs
@@ -5,12 +5,12 @@
using System.Collections.Generic;
using Castle.Core.Internal;
using Microsoft.Plugin.Program.Programs;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
-using NUnit.Framework;
namespace Microsoft.Plugin.Program.UnitTests.Programs
{
- [TestFixture]
+ [TestClass]
public class UWPTests
{
private static readonly PackageWrapper DevelopmentModeApp = new PackageWrapper(
@@ -37,7 +37,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
false,
"AppxManifests/PackagedApp");
- [Test]
+ [TestMethod]
public void AllShouldReturnPackagesWithDevelopmentModeWhenCalled()
{
// Arrange
@@ -56,7 +56,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.IsTrue(applications.FindAll(x => x.Name == "PackagedApp").Length > 0);
}
- [Test]
+ [TestMethod]
public void AllShouldNotReturnPackageFrameworksWhenCalled()
{
// Arrange
@@ -74,7 +74,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.IsTrue(applications.FindAll(x => x.Name == "PackagedApp").Length > 0);
}
- [Test]
+ [TestMethod]
public void PowerToysRunShouldNotAddInvalidAppWhenIndexingUWPApplications()
{
// Arrange
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/Win32Tests.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/Win32Tests.cs
index 47de8c8091..c5d46a6f7c 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/Win32Tests.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/Win32Tests.cs
@@ -5,17 +5,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
-using NUnit.Framework;
using Wox.Infrastructure;
using Wox.Infrastructure.FileSystemHelper;
using Wox.Plugin;
+using Win32Program = Microsoft.Plugin.Program.Programs.Win32Program;
namespace Microsoft.Plugin.Program.UnitTests.Programs
{
- using Win32Program = Microsoft.Plugin.Program.Programs.Win32Program;
-
- [TestFixture]
+ [TestClass]
public class Win32Tests
{
private static readonly Win32Program _imagingDevices = new Win32Program
@@ -253,7 +252,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
return mockDirectory.Object;
}
- [Test]
+ [TestMethod]
public void DedupFunctionWhenCalledMustRemoveDuplicateNotepads()
{
// Arrange
@@ -270,7 +269,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.AreEqual(1, apps.Count);
}
- [Test]
+ [TestMethod]
public void DedupFunctionWhenCalledMustRemoveInternetShortcuts()
{
// Arrange
@@ -287,7 +286,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.AreEqual(1, apps.Count);
}
- [Test]
+ [TestMethod]
public void DedupFunctionWhenCalledMustNotRemovelnkWhichdoesNotHaveExe()
{
// Arrange
@@ -303,7 +302,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.AreEqual(1, apps.Count);
}
- [Test]
+ [TestMethod]
public void DedupFunctionMustRemoveDuplicatesForExeExtensionsWithoutLnkResolvedPath()
{
// Arrange
@@ -321,7 +320,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.IsTrue(!string.IsNullOrEmpty(apps[0].LnkResolvedPath));
}
- [Test]
+ [TestMethod]
public void DedupFunctionMustNotRemoveProgramsWithSameExeNameAndFullPath()
{
// Arrange
@@ -339,7 +338,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.AreEqual(3, apps.Count);
}
- [Test]
+ [TestMethod]
public void FunctionIsWebApplicationShouldReturnTrueForWebApplications()
{
// The IsWebApplication(() function must return true for all PWAs and pinned web pages
@@ -351,7 +350,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.IsFalse(_dummyProxyApp.IsWebApplication());
}
- [TestCase("ignore")]
+ [DataTestMethod]
+ [DataRow("ignore")]
public void FunctionFilterWebApplicationShouldReturnFalseWhenSearchingForTheMainApp(string query)
{
// Irrespective of the query, the FilterWebApplication() Function must not filter main apps such as edge and chrome
@@ -359,37 +359,40 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.IsFalse(_chrome.FilterWebApplication(query));
}
- [TestCase("edge", ExpectedResult = true)]
- [TestCase("EDGE", ExpectedResult = true)]
- [TestCase("msedge", ExpectedResult = true)]
- [TestCase("Microsoft", ExpectedResult = true)]
- [TestCase("edg", ExpectedResult = true)]
- [TestCase("Edge page", ExpectedResult = false)]
- [TestCase("Edge Web page", ExpectedResult = false)]
- public bool EdgeWebSitesShouldBeFilteredWhenSearchingForEdge(string query)
+ [DataTestMethod]
+ [DataRow("edge", true)]
+ [DataRow("EDGE", true)]
+ [DataRow("msedge", true)]
+ [DataRow("Microsoft", true)]
+ [DataRow("edg", true)]
+ [DataRow("Edge page", false)]
+ [DataRow("Edge Web page", false)]
+ public void EdgeWebSitesShouldBeFilteredWhenSearchingForEdge(string query, bool result)
{
- return _pinnedWebpage.FilterWebApplication(query);
+ Assert.AreEqual(_pinnedWebpage.FilterWebApplication(query), result);
}
- [TestCase("chrome", ExpectedResult = true)]
- [TestCase("CHROME", ExpectedResult = true)]
- [TestCase("Google", ExpectedResult = true)]
- [TestCase("Google Chrome", ExpectedResult = true)]
- [TestCase("Google Chrome twitter", ExpectedResult = false)]
- public bool ChromeWebSitesShouldBeFilteredWhenSearchingForChrome(string query)
+ [DataTestMethod]
+ [DataRow("chrome", true)]
+ [DataRow("CHROME", true)]
+ [DataRow("Google", true)]
+ [DataRow("Google Chrome", true)]
+ [DataRow("Google Chrome twitter", false)]
+ public void ChromeWebSitesShouldBeFilteredWhenSearchingForChrome(string query, bool result)
{
- return _twitterChromePwa.FilterWebApplication(query);
+ Assert.AreEqual(_twitterChromePwa.FilterWebApplication(query), result);
}
- [TestCase("twitter", 0, ExpectedResult = false)]
- [TestCase("Twit", 0, ExpectedResult = false)]
- [TestCase("TWITTER", 0, ExpectedResult = false)]
- [TestCase("web", 1, ExpectedResult = false)]
- [TestCase("Page", 1, ExpectedResult = false)]
- [TestCase("WEB PAGE", 1, ExpectedResult = false)]
- [TestCase("edge", 2, ExpectedResult = false)]
- [TestCase("EDGE", 2, ExpectedResult = false)]
- public bool PinnedWebPagesShouldNotBeFilteredWhenSearchingForThem(string query, int scenario)
+ [DataTestMethod]
+ [DataRow("twitter", 0, false)]
+ [DataRow("Twit", 0, false)]
+ [DataRow("TWITTER", 0, false)]
+ [DataRow("web", 1, false)]
+ [DataRow("Page", 1, false)]
+ [DataRow("WEB PAGE", 1, false)]
+ [DataRow("edge", 2, false)]
+ [DataRow("EDGE", 2, false)]
+ public void PinnedWebPagesShouldNotBeFilteredWhenSearchingForThem(string query, int scenario, bool result)
{
const int CASE_TWITTER = 0;
const int CASE_WEB_PAGE = 1;
@@ -400,40 +403,43 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
switch (scenario)
{
case CASE_TWITTER:
- return _twitterChromePwa.FilterWebApplication(query);
+ Assert.AreEqual(_twitterChromePwa.FilterWebApplication(query), result);
+ return;
case CASE_WEB_PAGE:
- return _pinnedWebpage.FilterWebApplication(query);
+ Assert.AreEqual(_pinnedWebpage.FilterWebApplication(query), result);
+ return;
case CASE_EDGE_NAMED_WEBPAGE:
- return _edgeNamedPinnedWebpage.FilterWebApplication(query);
+ Assert.AreEqual(_edgeNamedPinnedWebpage.FilterWebApplication(query), result);
+ return;
default:
break;
}
-
- // unreachable code
- return true;
}
- [TestCase("Command Prompt")]
- [TestCase("cmd")]
- [TestCase("cmd.exe")]
- [TestCase("ignoreQueryText")]
+ [DataTestMethod]
+ [DataRow("Command Prompt")]
+ [DataRow("cmd")]
+ [DataRow("cmd.exe")]
+ [DataRow("ignoreQueryText")]
public void Win32ApplicationsShouldNotBeFilteredWhenFilteringRunCommands(string query)
{
// Even if there is an exact match in the name or exe name, win32 applications should never be filtered
Assert.IsTrue(_commandPrompt.QueryEqualsNameForRunCommands(query));
}
- [TestCase("explorer")]
- [TestCase("explorer.exe")]
+ [DataTestMethod]
+ [DataRow("explorer")]
+ [DataRow("explorer.exe")]
public void Win32ApplicationsShouldNotFilterWhenExecutingNameOrNameIsUsed(string query)
{
// Even if there is an exact match in the name or exe name, win32 applications should never be filtered
Assert.IsTrue(_fileExplorer.QueryEqualsNameForRunCommands(query));
}
- [TestCase("cmd")]
- [TestCase("Cmd")]
- [TestCase("CMD")]
+ [DataTestMethod]
+ [DataRow("cmd")]
+ [DataRow("Cmd")]
+ [DataRow("CMD")]
public void RunCommandsShouldNotBeFilteredOnExactMatch(string query)
{
// Partial matches should be filtered as cmd is not equal to cmder
@@ -443,13 +449,14 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.IsTrue(_cmdRunCommand.QueryEqualsNameForRunCommands(query));
}
- [TestCase("ımaging")]
+ [DataTestMethod]
+ [DataRow("ımaging")]
public void Win32ApplicationsShouldNotHaveIncorrectPathWhenExecuting(string query)
{
Assert.IsFalse(_imagingDevices.FullPath.Contains(query, StringComparison.Ordinal));
}
- [Test]
+ [TestMethod]
public void WebApplicationShouldReturnContextMenuWithOpenInConsoleWhenContextMenusIsCalled()
{
// Arrange
@@ -465,7 +472,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.AreEqual(Properties.Resources.wox_plugin_program_open_in_console, contextMenuResults[2].Title);
}
- [Test]
+ [TestMethod]
public void InternetShortcutApplicationShouldReturnContextMenuWithOpenInConsoleWhenContextMenusIsCalled()
{
// Arrange
@@ -480,7 +487,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.AreEqual(Properties.Resources.wox_plugin_program_open_in_console, contextMenuResults[1].Title);
}
- [Test]
+ [TestMethod]
public void Win32ApplicationShouldReturnContextMenuWithOpenInConsoleWhenContextMenusIsCalled()
{
// Arrange
@@ -496,7 +503,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.AreEqual(Properties.Resources.wox_plugin_program_open_in_console, contextMenuResults[2].Title);
}
- [Test]
+ [TestMethod]
public void RunCommandShouldReturnContextMenuWithOpenInConsoleWhenContextMenusIsCalled()
{
// Arrange
@@ -512,7 +519,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.AreEqual(Properties.Resources.wox_plugin_program_open_in_console, contextMenuResults[2].Title);
}
- [Test]
+ [TestMethod]
public void AppRefApplicationShouldReturnContextMenuWithOpenInConsoleWhenContextMenusIsCalled()
{
// Arrange
@@ -528,7 +535,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.AreEqual(Properties.Resources.wox_plugin_program_open_in_console, contextMenuResults[2].Title);
}
- [Test]
+ [TestMethod]
public void ShortcutApplicationShouldReturnContextMenuWithOpenInConsoleWhenContextMenusIsCalled()
{
// Arrange
@@ -544,7 +551,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.AreEqual(Properties.Resources.wox_plugin_program_open_in_console, contextMenuResults[2].Title);
}
- [Test]
+ [TestMethod]
public void FolderApplicationShouldReturnContextMenuWithOpenInConsoleWhenContextMenusIsCalled()
{
// Arrange
@@ -559,7 +566,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.AreEqual(Properties.Resources.wox_plugin_program_open_in_console, contextMenuResults[1].Title);
}
- [Test]
+ [TestMethod]
public void GenericFileApplicationShouldReturnContextMenuWithOpenInConsoleWhenContextMenusIsCalled()
{
// Arrange
@@ -574,7 +581,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.AreEqual(Properties.Resources.wox_plugin_program_open_in_console, contextMenuResults[1].Title);
}
- [Test]
+ [TestMethod]
public void Win32AppsShouldSetNameAsTitleWhileCreatingResult()
{
var mock = new Mock();
@@ -589,25 +596,27 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.IsFalse(result.Title.Equals(_cmderRunCommand.Description, StringComparison.Ordinal));
}
- [TestCase("C:\\Program Files\\dummy.exe", ExpectedResult = Win32Program.ApplicationType.Win32Application)]
- [TestCase("C:\\Program Files\\dummy.msc", ExpectedResult = Win32Program.ApplicationType.Win32Application)]
- [TestCase("C:\\Program Files\\dummy.lnk", ExpectedResult = Win32Program.ApplicationType.ShortcutApplication)]
- [TestCase("C:\\Program Files\\dummy.appref-ms", ExpectedResult = Win32Program.ApplicationType.ApprefApplication)]
- [TestCase("C:\\Program Files\\dummy.url", ExpectedResult = Win32Program.ApplicationType.InternetShortcutApplication)]
- [TestCase("C:\\Program Files\\dummy", ExpectedResult = Win32Program.ApplicationType.Folder)]
- [TestCase("C:\\Program Files\\dummy.txt", ExpectedResult = Win32Program.ApplicationType.GenericFile)]
- public Win32Program.ApplicationType GetAppTypeFromPathShouldReturnCorrectAppTypeWhenAppPathIsPassedAsArgument(string path)
+ [DataTestMethod]
+ [DataRow("C:\\Program Files\\dummy.exe", Win32Program.ApplicationType.Win32Application)]
+ [DataRow("C:\\Program Files\\dummy.msc", Win32Program.ApplicationType.Win32Application)]
+ [DataRow("C:\\Program Files\\dummy.lnk", Win32Program.ApplicationType.ShortcutApplication)]
+ [DataRow("C:\\Program Files\\dummy.appref-ms", Win32Program.ApplicationType.ApprefApplication)]
+ [DataRow("C:\\Program Files\\dummy.url", Win32Program.ApplicationType.InternetShortcutApplication)]
+ [DataRow("C:\\Program Files\\dummy", Win32Program.ApplicationType.Folder)]
+ [DataRow("C:\\Program Files\\dummy.txt", Win32Program.ApplicationType.GenericFile)]
+ public void GetAppTypeFromPathShouldReturnCorrectAppTypeWhenAppPathIsPassedAsArgument(string path, Win32Program.ApplicationType result)
{
// Directory.Exists must be mocked
Win32Program.DirectoryWrapper = GetMockedDirectoryWrapper();
// Act
- return Win32Program.GetAppTypeFromPath(path);
+ Assert.AreEqual(Win32Program.GetAppTypeFromPath(path), result);
}
- [TestCase(null)]
- [TestCase("")]
- [TestCase("ping 1.1.1.1")]
+ [DataTestMethod]
+ [DataRow(null)]
+ [DataRow("")]
+ [DataRow("ping 1.1.1.1")]
public void EmptyArgumentsShouldNotThrow(string argument)
{
// Arrange
@@ -617,7 +626,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
List contextMenuResults = _dummyInternetShortcutApp.ContextMenus(argument, mock.Object);
// Assert (Should always return if the above does not throw any exception)
- Assert.True(true);
+ Assert.IsTrue(true);
}
}
}
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/ConcurrentQueueEventHandlerTest.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/ConcurrentQueueEventHandlerTest.cs
index fd0e10e05f..093ac5c1e0 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/ConcurrentQueueEventHandlerTest.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/ConcurrentQueueEventHandlerTest.cs
@@ -5,14 +5,15 @@
using System.Collections.Concurrent;
using System.Threading.Tasks;
using Microsoft.Plugin.Program.Storage;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Microsoft.Plugin.Program.UnitTests.Storage
{
- [TestFixture]
+ [TestClass]
public class ConcurrentQueueEventHandlerTest
{
- [TestCase]
+ [DataTestMethod]
+ [DataRow]
public async Task EventHandlerMustReturnEmptyPathForEmptyQueueAsync()
{
// Arrange
@@ -23,11 +24,12 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
string appPath = await EventHandler.GetAppPathFromQueueAsync(eventHandlingQueue, dequeueDelay).ConfigureAwait(false);
// Assert
- Assert.IsEmpty(appPath);
+ Assert.IsTrue(string.IsNullOrEmpty(appPath));
}
- [TestCase(1)]
- [TestCase(10)]
+ [DataTestMethod]
+ [DataRow(1)]
+ [DataRow(10)]
public async Task EventHandlerMustReturnPathForConcurrentQueueWithSameFilePathsAsync(int itemCount)
{
// Arrange
@@ -47,7 +49,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.AreEqual(0, eventHandlingQueue.Count);
}
- [TestCase(5)]
+ [DataTestMethod]
+ [DataRow(5)]
public async Task EventHandlerMustReturnPathAndRetainDifferentFilePathsInQueueAsync(int itemCount)
{
// Arrange
@@ -73,7 +76,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.AreEqual(itemCount, eventHandlingQueue.Count);
}
- [TestCase(5)]
+ [DataTestMethod]
+ [DataRow(5)]
public async Task EventHandlerMustReturnPathAndRetainAllPathsAfterEncounteringADifferentPathAsync(int itemCount)
{
// Arrange
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/ListRepositoryTests.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/ListRepositoryTests.cs
index cbaaae7e7f..12c36c79c8 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/ListRepositoryTests.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/ListRepositoryTests.cs
@@ -3,15 +3,15 @@
// See the LICENSE file in the project root for more information.
using System.Threading.Tasks;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wox.Infrastructure.Storage;
namespace Microsoft.Plugin.Program.UnitTests.Storage
{
- [TestFixture]
+ [TestClass]
public class ListRepositoryTests
{
- [Test]
+ [TestMethod]
public void ContainsShouldReturnTrueWhenListIsInitializedWithItem()
{
// Arrange
@@ -25,7 +25,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.IsTrue(result);
}
- [Test]
+ [TestMethod]
public void ContainsShouldReturnTrueWhenListIsUpdatedWithAdd()
{
// Arrange
@@ -40,7 +40,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.IsTrue(result);
}
- [Test]
+ [TestMethod]
public void ContainsShouldReturnFalseWhenListIsUpdatedWithRemove()
{
// Arrange
@@ -55,7 +55,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.IsFalse(result);
}
- [Test]
+ [TestMethod]
public async Task AddShouldNotThrowWhenBeingIterated()
{
// Arrange
@@ -94,7 +94,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
await Task.WhenAll(new Task[] { iterationTask, addTask }).ConfigureAwait(false);
}
- [Test]
+ [TestMethod]
public async Task RemoveShouldNotThrowWhenBeingIterated()
{
// Arrange
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/Win32ProgramRepositoryTest.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/Win32ProgramRepositoryTest.cs
index c05955fd5a..ed7135d098 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/Win32ProgramRepositoryTest.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/Win32ProgramRepositoryTest.cs
@@ -9,15 +9,15 @@ using System.IO.Abstractions;
using System.Linq;
using Microsoft.Plugin.Program.Programs;
using Microsoft.Plugin.Program.Storage;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
-using NUnit.Framework;
using Wox.Infrastructure.FileSystemHelper;
using Wox.Infrastructure.Storage;
using Win32Program = Microsoft.Plugin.Program.Programs.Win32Program;
namespace Microsoft.Plugin.Program.UnitTests.Storage
{
- [TestFixture]
+ [TestClass]
public class Win32ProgramRepositoryTest
{
private readonly ProgramPluginSettings _settings = new ProgramPluginSettings();
@@ -26,7 +26,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
private List _fileSystemWatchers;
private List> _fileSystemMocks;
- [SetUp]
+ [TestInitialize]
public void SetFileSystemWatchers()
{
_fileSystemWatchers = new List();
@@ -39,7 +39,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
}
}
- [TestCase("Name", "ExecutableName", "FullPath", "description1", "description2")]
+ [DataTestMethod]
+ [DataRow("Name", "ExecutableName", "FullPath", "description1", "description2")]
public void Win32RepositoryMustNotStoreDuplicatesWhileAddingItemsWithSameHashCode(string name, string exename, string fullPath, string description1, string description2)
{
// Arrange
@@ -73,7 +74,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.AreEqual(1, win32ProgramRepository.Count());
}
- [TestCase("path.appref-ms")]
+ [DataTestMethod]
+ [DataRow("path.appref-ms")]
public void Win32ProgramRepositoryMustCallOnAppCreatedForApprefAppsWhenCreatedEventIsRaised(string path)
{
// Arrange
@@ -88,7 +90,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.AreEqual(Win32Program.ApplicationType.ApprefApplication, win32ProgramRepository.ElementAt(0).AppType);
}
- [TestCase("directory", "path.appref-ms")]
+ [DataTestMethod]
+ [DataRow("directory", "path.appref-ms")]
public void Win32ProgramRepositoryMustCallOnAppDeletedForApprefAppsWhenDeletedEventIsRaised(string directory, string path)
{
// Arrange
@@ -106,7 +109,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.AreEqual(0, win32ProgramRepository.Count());
}
- [TestCase("directory", "oldpath.appref-ms", "newpath.appref-ms")]
+ [DataTestMethod]
+ [DataRow("directory", "oldpath.appref-ms", "newpath.appref-ms")]
public void Win32ProgramRepositoryMustCallOnAppRenamedForApprefAppsWhenRenamedEventIsRaised(string directory, string oldpath, string newpath)
{
// Arrange
@@ -129,7 +133,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.IsFalse(win32ProgramRepository.Contains(olditem));
}
- [TestCase("path.exe")]
+ [DataTestMethod]
+ [DataRow("path.exe")]
public void Win32ProgramRepositoryMustCallOnAppCreatedForExeAppsWhenCreatedEventIsRaised(string path)
{
// Arrange
@@ -149,7 +154,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.AreEqual(Win32Program.ApplicationType.Win32Application, win32ProgramRepository.ElementAt(0).AppType);
}
- [TestCase("directory", "path.exe")]
+ [DataTestMethod]
+ [DataRow("directory", "path.exe")]
public void Win32ProgramRepositoryMustCallOnAppDeletedForExeAppsWhenDeletedEventIsRaised(string directory, string path)
{
// Arrange
@@ -172,7 +178,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.AreEqual(0, win32ProgramRepository.Count());
}
- [TestCase("directory", "oldpath.appref-ms", "newpath.appref-ms")]
+ [DataTestMethod]
+ [DataRow("directory", "oldpath.appref-ms", "newpath.appref-ms")]
public void Win32ProgramRepositoryMustCallOnAppRenamedForExeAppsWhenRenamedEventIsRaised(string directory, string oldpath, string newpath)
{
// Arrange
@@ -200,7 +207,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.IsFalse(win32ProgramRepository.Contains(olditem));
}
- [TestCase("path.url")]
+ [DataTestMethod]
+ [DataRow("path.url")]
public void Win32ProgramRepositoryMustNotCreateUrlAppWhenCreatedEventIsRaised(string path)
{
// We are handing internet shortcut apps using the Changed event instead
@@ -221,9 +229,10 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.AreEqual(0, win32ProgramRepository.Count());
}
- [TestCase("path.exe")]
- [TestCase("path.lnk")]
- [TestCase("path.appref-ms")]
+ [DataTestMethod]
+ [DataRow("path.exe")]
+ [DataRow("path.lnk")]
+ [DataRow("path.appref-ms")]
public void Win32ProgramRepositoryMustNotCreateAnyAppOtherThanUrlAppWhenChangedEventIsRaised(string path)
{
// We are handing internet shortcut apps using the Changed event instead
@@ -249,7 +258,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.AreEqual(0, win32ProgramRepository.Count());
}
- [TestCase("directory", "path.url")]
+ [DataTestMethod]
+ [DataRow("directory", "path.url")]
public void Win32ProgramRepositoryMustCallOnAppDeletedForUrlAppsWhenDeletedEventIsRaised(string directory, string path)
{
// Arrange
@@ -272,7 +282,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.AreEqual(0, win32ProgramRepository.Count());
}
- [TestCase("directory", "oldpath.url", "newpath.url")]
+ [DataTestMethod]
+ [DataRow("directory", "oldpath.url", "newpath.url")]
public void Win32ProgramRepositoryMustCallOnAppRenamedForUrlAppsWhenRenamedEventIsRaised(string directory, string oldpath, string newpath)
{
// Arrange
@@ -300,7 +311,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.IsFalse(win32ProgramRepository.Contains(olditem));
}
- [TestCase("directory", "path.lnk")]
+ [DataTestMethod]
+ [DataRow("directory", "path.lnk")]
public void Win32ProgramRepositoryMustCallOnAppDeletedForLnkAppsWhenDeletedEventIsRaised(string directory, string path)
{
// Arrange
@@ -330,7 +342,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
Assert.AreEqual(0, win32ProgramRepository.Count());
}
- [TestCase("directory", "oldpath.lnk", "path.lnk")]
+ [DataTestMethod]
+ [DataRow("directory", "oldpath.lnk", "path.lnk")]
public void Win32ProgramRepositoryMustCallOnAppRenamedForLnkAppsWhenRenamedEventIsRaised(string directory, string oldpath, string path)
{
// Arrange
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Uri.UnitTests/Microsoft.Plugin.Uri.UnitTests.csproj b/src/modules/launcher/Plugins/Microsoft.Plugin.Uri.UnitTests/Microsoft.Plugin.Uri.UnitTests.csproj
index 3f4ee12d6e..b781f88ec5 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Uri.UnitTests/Microsoft.Plugin.Uri.UnitTests.csproj
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Uri.UnitTests/Microsoft.Plugin.Uri.UnitTests.csproj
@@ -10,9 +10,9 @@
-
-
-
+
+
+
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Uri.UnitTests/UriHelper/ExtendedUriParserTests.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Uri.UnitTests/UriHelper/ExtendedUriParserTests.cs
index 2843634bc0..7d67a9572b 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Uri.UnitTests/UriHelper/ExtendedUriParserTests.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Uri.UnitTests/UriHelper/ExtendedUriParserTests.cs
@@ -3,55 +3,55 @@
// See the LICENSE file in the project root for more information.
using Microsoft.Plugin.Uri.UriHelper;
-using Microsoft.VisualStudio.TestPlatform.ObjectModel;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Microsoft.Plugin.Uri.UnitTests.UriHelper
{
- [TestFixture]
+ [TestClass]
public class ExtendedUriParserTests
{
- [TestCase("google.com", true, "https://google.com/")]
- [TestCase("http://google.com", true, "http://google.com/")]
- [TestCase("localhost", true, "https://localhost/")]
- [TestCase("http://localhost", true, "http://localhost/")]
- [TestCase("127.0.0.1", true, "https://127.0.0.1/")]
- [TestCase("http://127.0.0.1", true, "http://127.0.0.1/")]
- [TestCase("http://127.0.0.1:80", true, "http://127.0.0.1/")]
- [TestCase("127", false, null)]
- [TestCase("", false, null)]
- [TestCase("https://google.com", true, "https://google.com/")]
- [TestCase("ftps://google.com", true, "ftps://google.com/")]
- [TestCase(null, false, null)]
- [TestCase("bing.com/search?q=gmx", true, "https://bing.com/search?q=gmx")]
- [TestCase("http://bing.com/search?q=gmx", true, "http://bing.com/search?q=gmx")]
- [TestCase("h", true, "https://h/")]
- [TestCase("http://h", true, "http://h/")]
- [TestCase("ht", true, "https://ht/")]
- [TestCase("http://ht", true, "http://ht/")]
- [TestCase("htt", true, "https://htt/")]
- [TestCase("http://htt", true, "http://htt/")]
- [TestCase("http", true, "https://http/")]
- [TestCase("http://http", true, "http://http/")]
- [TestCase("http:", false, null)]
- [TestCase("http:/", false, null)]
- [TestCase("http://", false, null)]
- [TestCase("http://t", true, "http://t/")]
- [TestCase("http://te", true, "http://te/")]
- [TestCase("http://tes", true, "http://tes/")]
- [TestCase("http://test", true, "http://test/")]
- [TestCase("http://test.", false, null)]
- [TestCase("http://test.c", true, "http://test.c/")]
- [TestCase("http://test.co", true, "http://test.co/")]
- [TestCase("http://test.com", true, "http://test.com/")]
- [TestCase("http:3", true, "https://http:3/")]
- [TestCase("http://http:3", true, "http://http:3/")]
- [TestCase("[::]", true, "https://[::]/")]
- [TestCase("http://[::]", true, "http://[::]/")]
- [TestCase("[2001:0DB8::1]", true, "https://[2001:db8::1]/")]
- [TestCase("http://[2001:0DB8::1]", true, "http://[2001:db8::1]/")]
- [TestCase("[2001:0DB8::1]:80", true, "https://[2001:db8::1]/")]
- [TestCase("http://[2001:0DB8::1]:80", true, "http://[2001:db8::1]/")]
+ [DataTestMethod]
+ [DataRow("google.com", true, "https://google.com/")]
+ [DataRow("http://google.com", true, "http://google.com/")]
+ [DataRow("localhost", true, "https://localhost/")]
+ [DataRow("http://localhost", true, "http://localhost/")]
+ [DataRow("127.0.0.1", true, "https://127.0.0.1/")]
+ [DataRow("http://127.0.0.1", true, "http://127.0.0.1/")]
+ [DataRow("http://127.0.0.1:80", true, "http://127.0.0.1/")]
+ [DataRow("127", false, null)]
+ [DataRow("", false, null)]
+ [DataRow("https://google.com", true, "https://google.com/")]
+ [DataRow("ftps://google.com", true, "ftps://google.com/")]
+ [DataRow(null, false, null)]
+ [DataRow("bing.com/search?q=gmx", true, "https://bing.com/search?q=gmx")]
+ [DataRow("http://bing.com/search?q=gmx", true, "http://bing.com/search?q=gmx")]
+ [DataRow("h", true, "https://h/")]
+ [DataRow("http://h", true, "http://h/")]
+ [DataRow("ht", true, "https://ht/")]
+ [DataRow("http://ht", true, "http://ht/")]
+ [DataRow("htt", true, "https://htt/")]
+ [DataRow("http://htt", true, "http://htt/")]
+ [DataRow("http", true, "https://http/")]
+ [DataRow("http://http", true, "http://http/")]
+ [DataRow("http:", false, null)]
+ [DataRow("http:/", false, null)]
+ [DataRow("http://", false, null)]
+ [DataRow("http://t", true, "http://t/")]
+ [DataRow("http://te", true, "http://te/")]
+ [DataRow("http://tes", true, "http://tes/")]
+ [DataRow("http://test", true, "http://test/")]
+ [DataRow("http://test.", false, null)]
+ [DataRow("http://test.c", true, "http://test.c/")]
+ [DataRow("http://test.co", true, "http://test.co/")]
+ [DataRow("http://test.com", true, "http://test.com/")]
+ [DataRow("http:3", true, "https://http:3/")]
+ [DataRow("http://http:3", true, "http://http:3/")]
+ [DataRow("[::]", true, "https://[::]/")]
+ [DataRow("http://[::]", true, "http://[::]/")]
+ [DataRow("[2001:0DB8::1]", true, "https://[2001:db8::1]/")]
+ [DataRow("http://[2001:0DB8::1]", true, "http://[2001:db8::1]/")]
+ [DataRow("[2001:0DB8::1]:80", true, "https://[2001:db8::1]/")]
+ [DataRow("http://[2001:0DB8::1]:80", true, "http://[2001:db8::1]/")]
public void TryParseCanParseHostName(string query, bool expectedSuccess, string expectedResult)
{
// Arrange
diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/BracketHelperTests.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/BracketHelperTests.cs
index 7338444f85..4ceaee5f1c 100644
--- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/BracketHelperTests.cs
+++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/BracketHelperTests.cs
@@ -2,23 +2,24 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests
{
- [TestFixture]
+ [TestClass]
public class BracketHelperTests
{
- [TestCase(null)]
- [TestCase("")]
- [TestCase("\t \r\n")]
- [TestCase("none")]
- [TestCase("()")]
- [TestCase("(())")]
- [TestCase("()()")]
- [TestCase("(()())")]
- [TestCase("([][])")]
- [TestCase("([(()[])[](([]()))])")]
+ [DataTestMethod]
+ [DataRow(null)]
+ [DataRow("")]
+ [DataRow("\t \r\n")]
+ [DataRow("none")]
+ [DataRow("()")]
+ [DataRow("(())")]
+ [DataRow("()()")]
+ [DataRow("(()())")]
+ [DataRow("([][])")]
+ [DataRow("([(()[])[](([]()))])")]
public void IsBracketComplete_TestValid_WhenCalled(string input)
{
// Arrange
@@ -30,11 +31,12 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests
Assert.IsTrue(result);
}
- [TestCase("((((", "only opening brackets")]
- [TestCase("]]]", "only closing brackets")]
- [TestCase("([)(])", "inner bracket mismatch")]
- [TestCase(")(", "opening and closing reversed")]
- [TestCase("(]", "mismatch in bracket type")]
+ [DataTestMethod]
+ [DataRow("((((", "only opening brackets")]
+ [DataRow("]]]", "only closing brackets")]
+ [DataRow("([)(])", "inner bracket mismatch")]
+ [DataRow(")(", "opening and closing reversed")]
+ [DataRow("(]", "mismatch in bracket type")]
public void IsBracketComplete_TestInvalid_WhenCalled(string input, string invalidReason)
{
// Arrange
diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs
index cbb2740a7b..0336afe638 100644
--- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs
+++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs
@@ -3,39 +3,43 @@
// See the LICENSE file in the project root for more information.
using System;
+using System.Collections.Generic;
using System.Globalization;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests
{
- [TestFixture]
+ [TestClass]
public class ExtendedCalculatorParserTests
{
- [TestCase(null)]
- [TestCase("")]
- [TestCase(" ")]
+ [DataTestMethod]
+ [DataRow(null)]
+ [DataRow("")]
+ [DataRow(" ")]
public void InputValid_ThrowError_WhenCalledNullOrEmpty(string input)
{
// Act
- Assert.Catch(() => CalculateHelper.InputValid(input));
+ Assert.ThrowsException(() => CalculateHelper.InputValid(input));
}
- [TestCase(null)]
- [TestCase("")]
- [TestCase(" ")]
+ [DataTestMethod]
+ [DataRow(null)]
+ [DataRow("")]
+ [DataRow(" ")]
public void Interpret_ThrowError_WhenCalledNullOrEmpty(string input)
{
// Arrange
var engine = new CalculateEngine();
// Act
- Assert.Catch(() => engine.Interpret(input));
+ Assert.ThrowsException(() => engine.Interpret(input));
}
- [TestCase("42")]
- [TestCase("test")]
- [TestCase("pi(2)")] // Incorrect input, constant is being treated as a function.
- [TestCase("e(2)")]
+ [DataTestMethod]
+ [DataRow("42")]
+ [DataRow("test")]
+ [DataRow("pi(2)")] // Incorrect input, constant is being treated as a function.
+ [DataRow("e(2)")]
public void Interpret_NoResult_WhenCalled(string input)
{
// Arrange
@@ -48,25 +52,32 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests
Assert.AreEqual(default(CalculateResult), result);
}
- [TestCase("2 * 2", 4D)]
- [TestCase("-2 ^ 2", 4D)]
- [TestCase("-(2 ^ 2)", -4D)]
- [TestCase("2 * pi", 6.28318530717959D)]
- [TestCase("round(2 * pi)", 6D)]
- [TestCase("1 == 2", default(double))]
- [TestCase("pi * ( sin ( cos ( 2)))", -1.26995475603563D)]
- [TestCase("5.6/2", 2.8D)]
- [TestCase("123 * 4.56", 560.88D)]
- [TestCase("1 - 9.0 / 10", 0.1D)]
- [TestCase("0.5 * ((2*-395.2)+198.2)", -296.1D)]
- [TestCase("2+2.11", 4.11D)]
- [TestCase("8.43 + 4.43 - 12.86", 0D)]
- [TestCase("8.43 + 4.43 - 12.8", 0.06D)]
- [TestCase("exp(5)", 148.413159102577D)]
- [TestCase("e^5", 148.413159102577D)]
- [TestCase("e*2", 5.43656365691809D)]
- [TestCase("log(e)", 1D)]
- [TestCase("cosh(0)", 1D)]
+ private static IEnumerable