diff --git a/StabilityMatrix.Tests/Avalonia/UpdateViewModelTests.cs b/StabilityMatrix.Tests/Avalonia/UpdateViewModelTests.cs new file mode 100644 index 00000000..93a05de3 --- /dev/null +++ b/StabilityMatrix.Tests/Avalonia/UpdateViewModelTests.cs @@ -0,0 +1,55 @@ +using Semver; +using StabilityMatrix.Avalonia.ViewModels.Dialogs; + +namespace StabilityMatrix.Tests.Avalonia; + +[TestClass] +public class UpdateViewModelTests +{ + [TestMethod] + public void FormatChangelogTest() + { + // Arrange + const string markdown = """ + # Changelog + + All notable changes to Stability Matrix will be documented in this file. + + The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), + and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2.0.0.html). + + ## v2.4.6 + ### Added + - Stuff + ### Changed + - Things + + ## v2.4.5 + ### Fixed + - Fixed bug + + ## v2.4.4 + ### Changed + - Changed stuff + """; + + // Act + var result = UpdateViewModel.FormatChangelog(markdown, SemVersion.Parse("2.4.5")); + var resultPre = UpdateViewModel.FormatChangelog( + markdown, + SemVersion.Parse("2.4.5-pre.1+1a7b4e4") + ); + + // Assert + const string expected = """ + ## v2.4.6 + ### Added + - Stuff + ### Changed + - Things + """; + + Assert.AreEqual(expected, result); + Assert.AreEqual(expected, resultPre); + } +} diff --git a/StabilityMatrix.Tests/ReparsePoints/JunctionTests.cs b/StabilityMatrix.Tests/ReparsePoints/JunctionTests.cs index 46c96559..f1b67ba0 100644 --- a/StabilityMatrix.Tests/ReparsePoints/JunctionTests.cs +++ b/StabilityMatrix.Tests/ReparsePoints/JunctionTests.cs @@ -1,12 +1,13 @@ using System.Runtime.InteropServices; +using System.Runtime.Versioning; using StabilityMatrix.Core.ReparsePoints; namespace StabilityMatrix.Tests.ReparsePoints; using System.IO; - [TestClass] +[SupportedOSPlatform("windows")] public class JunctionTest { private string tempFolder = string.Empty; @@ -19,7 +20,7 @@ public class JunctionTest Assert.Inconclusive("Test cannot be run on anything but Windows currently."); return; } - + tempFolder = Path.GetTempFileName(); File.Delete(tempFolder); Directory.CreateDirectory(tempFolder); @@ -28,7 +29,8 @@ public class JunctionTest [TestCleanup] public void Cleanup() { - if (string.IsNullOrEmpty(tempFolder)) return; + if (string.IsNullOrEmpty(tempFolder)) + return; TempFiles.DeleteDirectory(tempFolder); } @@ -56,28 +58,38 @@ public class JunctionTest File.Create(Path.Combine(targetFolder, "AFile")).Close(); // Verify behavior before junction point created. - Assert.IsFalse(File.Exists(Path.Combine(junctionPoint, "AFile")), - "File should not be located until junction point created."); + Assert.IsFalse( + File.Exists(Path.Combine(junctionPoint, "AFile")), + "File should not be located until junction point created." + ); Assert.IsFalse(Junction.Exists(junctionPoint), "Junction point not created yet."); // Create junction point and confirm its properties. - Junction.Create(junctionPoint, targetFolder, false /*don't overwrite*/); + Junction.Create( + junctionPoint, + targetFolder, + false /*don't overwrite*/ + ); Assert.IsTrue(Junction.Exists(junctionPoint), "Junction point exists now."); Assert.AreEqual(targetFolder, Junction.GetTarget(junctionPoint)); - Assert.IsTrue(File.Exists(Path.Combine(junctionPoint, "AFile")), - "File should be accessible via the junction point."); + Assert.IsTrue( + File.Exists(Path.Combine(junctionPoint, "AFile")), + "File should be accessible via the junction point." + ); // Delete junction point. Junction.Delete(junctionPoint); Assert.IsFalse(Junction.Exists(junctionPoint), "Junction point should not exist now."); - Assert.IsFalse(File.Exists(Path.Combine(junctionPoint, "AFile")), - "File should not be located after junction point deleted."); + Assert.IsFalse( + File.Exists(Path.Combine(junctionPoint, "AFile")), + "File should not be located after junction point deleted." + ); Assert.IsFalse(Directory.Exists(junctionPoint), "Ensure directory was deleted too."); @@ -86,7 +98,10 @@ public class JunctionTest } [TestMethod] - [ExpectedException(typeof(IOException), "Directory already exists and overwrite parameter is false.")] + [ExpectedException( + typeof(IOException), + "Directory already exists and overwrite parameter is false." + )] public void Create_ThrowsIfOverwriteNotSpecifiedAndDirectoryExists() { var targetFolder = Path.Combine(tempFolder, "ADirectory");