-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update NativeAOT runner example #2634
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 5 additions & 6 deletions
11
samples/mstest-runner/NativeAotRunner/ClassLibrary1/Class1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
namespace ClassLibrary1 | ||
namespace ClassLibrary1; | ||
|
||
public class Class1 | ||
{ | ||
public class Class1 | ||
public int Add(int left, int right) | ||
{ | ||
public int Add(int left, int right) | ||
{ | ||
return left + right; | ||
} | ||
return left + right; | ||
} | ||
} |
24 changes: 12 additions & 12 deletions
24
samples/mstest-runner/NativeAotRunner/TestProject1/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
using Microsoft.Testing.Extensions; | ||
using Microsoft.Testing.Internal.Framework; | ||
using Microsoft.Testing.Framework; | ||
using Microsoft.Testing.Platform.Builder; | ||
namespace TestProject1 | ||
|
||
namespace TestProject1; | ||
internal static class Program | ||
{ | ||
internal static class Program | ||
public static async Task<int> Main(string[] args) | ||
{ | ||
public static async Task<int> Main(string[] args) | ||
{ | ||
var builder = await TestApplication.CreateBuilderAsync(args); | ||
// Registers TestFramework, with tree of test nodes that are generated into your project by source generator. | ||
builder.AddTestFramework(new SourceGeneratedTestNodesBuilder()); | ||
builder.AddTrxReportProvider(); | ||
var app = await builder.BuildAsync(); | ||
return await app.RunAsync(); | ||
} | ||
var builder = await TestApplication.CreateBuilderAsync(args); | ||
// Registers TestFramework, with tree of test nodes that are generated into your project by source generator. | ||
builder.AddTestFramework(new SourceGeneratedTestNodesBuilder()); | ||
builder.AddTrxReportProvider(); | ||
builder.AddCodeCoverageProvider(); | ||
var app = await builder.BuildAsync(); | ||
return await app.RunAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 44 additions & 45 deletions
89
samples/mstest-runner/NativeAotRunner/TestProject1/UnitTest1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,52 @@ | ||
using ClassLibrary1; | ||
|
||
namespace TestProject1 | ||
namespace TestProject1; | ||
|
||
[TestClass] | ||
public class UnitTest1 | ||
{ | ||
[TestClass] | ||
public class UnitTest1 | ||
[TestMethod] | ||
public void TestMethod1() | ||
{ | ||
Assert.AreEqual(3, new Class1().Add(1, 2)); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(1, 2)] | ||
public void TestMethod2(int left, int right) | ||
{ | ||
[TestMethod] | ||
public void TestMethod1() | ||
{ | ||
Assert.AreEqual(3, new Class1().Add(1, 2)); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(1, 2)] | ||
public void TestMethod2(int left, int right) | ||
{ | ||
Assert.AreEqual(3, new Class1().Add(left, right)); | ||
} | ||
|
||
[TestMethod] | ||
[DynamicData(nameof(Data))] | ||
public void TestMethod3(int left, int right) | ||
{ | ||
Assert.AreEqual(3, new Class1().Add(left, right)); | ||
} | ||
|
||
[TestMethod] | ||
[DynamicData(nameof(Users))] | ||
public void TestMethod4(User u) | ||
{ | ||
Assert.AreEqual(3, new Class1().Add(u.Left, u.Right)); | ||
} | ||
|
||
public static IEnumerable<object[]> Data { get; } = | ||
[ | ||
[1, 2], | ||
[-3, 6], | ||
]; | ||
|
||
public static IEnumerable<object[]> Users { get; } = | ||
[ | ||
[new User { Left = 1, Right = 2 }], | ||
[new User { Left = -3, Right = 6}], | ||
]; | ||
Assert.AreEqual(3, new Class1().Add(left, right)); | ||
} | ||
|
||
public class User | ||
[TestMethod] | ||
[DynamicData(nameof(Data))] | ||
public void TestMethod3(int left, int right) | ||
{ | ||
public required int Left { get; init; } | ||
public required int Right { get; init; } | ||
Assert.AreEqual(3, new Class1().Add(left, right)); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
[DynamicData(nameof(Users))] | ||
public void TestMethod4(User u) | ||
{ | ||
Assert.AreEqual(3, new Class1().Add(u.Left, u.Right)); | ||
} | ||
|
||
public static IEnumerable<object[]> Data { get; } = | ||
[ | ||
[1, 2], | ||
[-3, 6], | ||
]; | ||
|
||
public static IEnumerable<object[]> Users { get; } = | ||
[ | ||
[new User { Left = 1, Right = 2 }], | ||
[new User { Left = -3, Right = 6}], | ||
]; | ||
} | ||
|
||
public class User | ||
{ | ||
public required int Left { get; init; } | ||
public required int Right { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<!-- MSTest early access packages. See: https://aka.ms/mstest/preview uncomment this line --> | ||
<!-- <add key="test-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/test-tools/nuget/v3/index.json" /> --> | ||
<clear /> | ||
<add key="nuget" value="https://api.nuget.org/v3/index.json" /> | ||
</packageSources> | ||
</configuration> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not do that, this is causing security alerts. We should instead use the
dotnet-public
feed. I think just dropping thisnuget.config
to use the one from parent folder would be enough.