Skip to content

Commit

Permalink
test: Update to MSTest dogfooding version
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Jan 18, 2025
1 parent 154cbec commit fd056b8
Show file tree
Hide file tree
Showing 43 changed files with 112 additions and 103 deletions.
10 changes: 7 additions & 3 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<Product Condition="'$(UnoRuntimeIdentifier)' != ''">$(AssemblyName) ($(TargetFramework) $(UnoRuntimeIdentifier))</Product>
<CommunityToolkitMvvmVersion>8.2.2</CommunityToolkitMvvmVersion>
<TestingPlatformDotNetTestSupport Condition="'$(IsTestingPlatformApplication)' == 'true'">true</TestingPlatformDotNetTestSupport>

<!-- Dogfooding feed for MSTest -->
<RestoreAdditionalProjectSources>$(RestoreAdditionalProjectSources);https://dnceng.pkgs.visualstudio.com/public/_packaging/test-tools/nuget/v3/index.json</RestoreAdditionalProjectSources>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -64,12 +67,13 @@
<PropertyGroup>
<!-- IMPORTANT!!! KEEP BOTH MSTest and MTP versions in sync -->
<!-- For a given MSTest version, go to https://www.nuget.org/packages/MSTest.TestAdapter/3.7.1#dependencies-body-tab -->
<!-- (replacing 3.7.1 in the url with the MSTest version in question) -->
<!-- (Or, for dogfooding versions, go to https://dnceng.visualstudio.com/public/_artifacts/feed/test-tools/NuGet/MSTest.TestAdapter/overview/3.8.0-preview.25067.5) -->
<!-- (replacing the version in the url with the MSTest version in question) -->
<!-- And look for MTP version in there, and make sure MicrosoftTestingPlatformVersion is the same -->
<!-- Alternatively, migrate to MSTest.Sdk and let it handle the MTP versioning for you -->
<!-- In case of MSTest.Sdk, the TrxReport package will not be needed. It will be added automatically -->
<MSTestVersion>3.7.1</MSTestVersion>
<MicrosoftTestingPlatformVersion>1.5.1</MicrosoftTestingPlatformVersion>
<MSTestVersion>3.8.0-preview.25067.5</MSTestVersion>
<MicrosoftTestingPlatformVersion>1.6.0-preview.25067.5</MicrosoftTestingPlatformVersion>

<SkiaSharpVersion>2.88.7</SkiaSharpVersion>
<!-- TODO: Uncomment when we're net8.0+ to have SamplesApp serve as a good test for SkiaSharp 3 support -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void Parsed_Geometry_ToString_Should_Format_Value(string pathData, string
[DataRow("j")]
public void Throws_InvalidDataException_On_None_Defined_Command(string pathData)
{
Assert.ThrowsException<InvalidDataException>(() => Parse(pathData));
Assert.ThrowsExactly<InvalidDataException>(() => Parse(pathData));
}

[TestMethod]
Expand Down
4 changes: 2 additions & 2 deletions src/Uno.UI.RuntimeTests/MUX/Utilities/MSTestInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ public static void Fail(string message, params object[] args)

public static void Throws<T>(Action action, string message) where T : Exception
{
Assert.ThrowsException<T>(action, message);
Assert.ThrowsExactly<T>(action, message);
}

public static void Throws<T>(Action action) where T : Exception
{
Assert.ThrowsException<T>(action);
Assert.ThrowsExactly<T>(action);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Given_AppDataUriEvaluator
[TestMethod]
public void When_Uri_Is_Null()
{
Assert.ThrowsException<ArgumentNullException>(
Assert.ThrowsExactly<ArgumentNullException>(
() => AppDataUriEvaluator.ToPath(null));
}

Expand All @@ -27,7 +27,7 @@ public void When_Uri_Has_Different_Scheme()
{
var uri = new Uri("ms-appx:///local/test.txt");

Assert.ThrowsException<ArgumentOutOfRangeException>(
Assert.ThrowsExactly<ArgumentOutOfRangeException>(
() => AppDataUriEvaluator.ToPath(uri));
}

Expand All @@ -36,7 +36,7 @@ public void When_Uri_Is_Not_Absolute()
{
var uri = new Uri("local/test.txt", UriKind.Relative);

Assert.ThrowsException<ArgumentOutOfRangeException>(
Assert.ThrowsExactly<ArgumentOutOfRangeException>(
() => AppDataUriEvaluator.ToPath(uri));
}

Expand All @@ -45,7 +45,7 @@ public void When_Uri_Has_No_Path()
{
var uri = new Uri("ms-appdata:");

Assert.ThrowsException<ArgumentOutOfRangeException>(
Assert.ThrowsExactly<ArgumentOutOfRangeException>(
() => AppDataUriEvaluator.ToPath(uri));
}

Expand All @@ -54,7 +54,7 @@ public void When_Uri_Has_No_Subfolder_Specification()
{
var uri = new Uri("ms-appdata:///");

Assert.ThrowsException<ArgumentOutOfRangeException>(
Assert.ThrowsExactly<ArgumentOutOfRangeException>(
() => AppDataUriEvaluator.ToPath(uri));
}

Expand Down Expand Up @@ -93,7 +93,7 @@ public void When_Uri_Is_RoamingFolder_But_Has_Suffix()
{
var uri = new Uri("ms-appdata:///roamingfolder/");

Assert.ThrowsException<ArgumentOutOfRangeException>(
Assert.ThrowsExactly<ArgumentOutOfRangeException>(
() => AppDataUriEvaluator.ToPath(uri));
}

Expand All @@ -112,7 +112,7 @@ public void When_Uri_Starts_With_Invalid_Folder()
{
var uri = new Uri($"ms-appdata:///space/file.png");

Assert.ThrowsException<ArgumentOutOfRangeException>(
Assert.ThrowsExactly<ArgumentOutOfRangeException>(
() => AppDataUriEvaluator.ToPath(uri));
}

Expand Down Expand Up @@ -147,7 +147,7 @@ public void When_Uri_Contains_Package_Name_But_Has_Suffix()
var packageName = Package.Current.Id.Name;
var uri = new Uri($"ms-appdata://{packageName}abcd/local/file.png");

Assert.ThrowsException<ArgumentOutOfRangeException>(
Assert.ThrowsExactly<ArgumentOutOfRangeException>(
() => AppDataUriEvaluator.ToPath(uri));
}

Expand Down Expand Up @@ -195,7 +195,7 @@ public void When_Double_Dot_Backs_Out_Above_App_Data()
{
var uri = new Uri("ms-appdata:///local/../hello/logo.png");

Assert.ThrowsException<ArgumentOutOfRangeException>(
Assert.ThrowsExactly<ArgumentOutOfRangeException>(
() => AppDataUriEvaluator.ToPath(uri));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Given_EmailManager
[TestMethod]
public async Task When_EmailMessage_Is_Null()
{
await Assert.ThrowsExceptionAsync<ArgumentNullException>(
await Assert.ThrowsExactlyAsync<ArgumentNullException>(
async () => await EmailManager.ShowComposeNewEmailAsync(null));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ public void When_Body_Default()
public void When_Body_Set_Null()
{
var emailMessage = new EmailMessage();
Assert.ThrowsException<ArgumentNullException>(
Assert.ThrowsExactly<ArgumentNullException>(
() => emailMessage.Body = null);
}

[TestMethod]
public void When_Subject_Set_Null()
{
var emailMessage = new EmailMessage();
Assert.ThrowsException<ArgumentNullException>(
Assert.ThrowsExactly<ArgumentNullException>(
() => emailMessage.Subject = null);
}

Expand All @@ -83,23 +83,23 @@ public void When_Sender_Set_Null()
public void When_Null_To_Recipient_Is_Added()
{
var emailMessage = new EmailMessage();
Assert.ThrowsException<ArgumentNullException>(
Assert.ThrowsExactly<ArgumentNullException>(
() => emailMessage.To.Add(null));
}

[TestMethod]
public void When_Null_CC_Recipient_Is_Added()
{
var emailMessage = new EmailMessage();
Assert.ThrowsException<ArgumentNullException>(
Assert.ThrowsExactly<ArgumentNullException>(
() => emailMessage.CC.Add(null));
}

[TestMethod]
public void When_Null_Bcc_Recipient_Is_Added()
{
var emailMessage = new EmailMessage();
Assert.ThrowsException<ArgumentNullException>(
Assert.ThrowsExactly<ArgumentNullException>(
() => emailMessage.Bcc.Add(null));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,30 @@ public class Given_EmailRecipient
[TestMethod]
public void When_Address_Is_Null()
{
Assert.ThrowsException<ArgumentNullException>(
Assert.ThrowsExactly<ArgumentNullException>(
() => new EmailRecipient(null));
}

[TestMethod]
public void When_Name_Is_Null()
{
Assert.ThrowsException<ArgumentNullException>(
Assert.ThrowsExactly<ArgumentNullException>(
() => new EmailRecipient("[email protected]", null));
}

[TestMethod]
public void When_Address_Set_Null()
{
var emailRecipient = new EmailRecipient();
Assert.ThrowsException<ArgumentNullException>(
Assert.ThrowsExactly<ArgumentNullException>(
() => emailRecipient.Address = null);
}

[TestMethod]
public void When_Name_Set_Null()
{
var emailRecipient = new EmailRecipient();
Assert.ThrowsException<ArgumentNullException>(
Assert.ThrowsExactly<ArgumentNullException>(
() => emailRecipient.Name = null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ public void When_RawData()
[TestMethod]
public void When_Channel_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiChannelPressureMessage(16, 10));
}

[TestMethod]
public void When_Pressure_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiChannelPressureMessage(12, 128));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ public void When_RawData()
[TestMethod]
public void When_Channel_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiControlChangeMessage(16, 10, 10));
}

[TestMethod]
public void When_Controller_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiControlChangeMessage(12, 128, 10));
}

[TestMethod]
public void When_ControlChange_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiControlChangeMessage(12, 10, 128));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ public void When_RawData()
[TestMethod]
public void When_Channel_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiNoteOffMessage(16, 10, 10));
}

[TestMethod]
public void When_Note_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiNoteOffMessage(12, 128, 10));
}

[TestMethod]
public void When_Velocity_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiNoteOffMessage(12, 10, 128));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ public void When_RawData()
[TestMethod]
public void When_Channel_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiNoteOnMessage(16, 10, 10));
}

[TestMethod]
public void When_Note_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiNoteOnMessage(12, 128, 10));
}

[TestMethod]
public void When_Velocity_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiNoteOnMessage(12, 10, 128));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ public void When_RawData()
[TestMethod]
public void When_Channel_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiPitchBendChangeMessage(16, 10));
}

[TestMethod]
public void When_Bend_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiPitchBendChangeMessage(12, 16384));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ public void When_RawData()
[TestMethod]
public void When_Channel_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiNoteOnMessage(16, 10, 10));
}

[TestMethod]
public void When_Note_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiNoteOnMessage(12, 128, 10));
}

[TestMethod]
public void When_Pressure_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiNoteOnMessage(12, 10, 128));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ public void When_RawData()
[TestMethod]
public void When_Channel_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiProgramChangeMessage(16, 10));
}

[TestMethod]
public void When_Pressure_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiProgramChangeMessage(12, 128));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void When_RawData()
[TestMethod]
public void When_Beats_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiPitchBendChangeMessage(12, 16384));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void When_RawData()
[TestMethod]
public void When_Song_Out_Of_Bounds()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiSongSelectMessage(128));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Given_MidiSystemExclusiveMessage
[TestMethod]
public void When_RawData_Empty()
{
Assert.ThrowsException<ArgumentException>(
Assert.ThrowsExactly<ArgumentException>(
() => new MidiSystemExclusiveMessage(Array.Empty<byte>().ToBuffer()));
}

Expand Down
Loading

0 comments on commit fd056b8

Please sign in to comment.