-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move tests to use NativeAOT compatible MSTest (#23)
* Move tests to use NativeAOT compatible MSTest * Run from working dir * Fix path * The dots
- Loading branch information
Showing
16 changed files
with
254 additions
and
158 deletions.
There are no files selected for viewing
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) David Pine. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using Microsoft.Testing.Framework; | ||
using Microsoft.Testing.Platform.Builder; | ||
|
||
namespace ProfanityFilter.Action.Tests; | ||
|
||
internal static class Program | ||
{ | ||
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()); | ||
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
30 changes: 30 additions & 0 deletions
30
tests/ProfanityFilter.Services.Tests/CollectionAssertionExtensions.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) David Pine. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
namespace ProfanityFilter.Services.Tests; | ||
|
||
internal static class CollectionAssertionExtensions | ||
{ | ||
public static void Contains<T>(this CollectionAssert _, IEnumerable<T> collection, Func<T, bool> predicate) | ||
{ | ||
foreach (var item in collection) | ||
{ | ||
if (predicate(item)) | ||
{ | ||
return; | ||
} | ||
} | ||
|
||
|
||
throw new Exception("Expected collection to contain item, but it did not."); | ||
} | ||
|
||
public static void Single<T>(this CollectionAssert _, IEnumerable<T> collection) | ||
{ | ||
var count = collection.Count(); | ||
if (count != 1) | ||
{ | ||
throw new Exception($"Expected collection to contain single item, but it contained {count} items."); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.