-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve the overall unit test rate (#22)
- Loading branch information
Showing
44 changed files
with
1,203 additions
and
106 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
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,24 @@ | ||
namespace BB84.SAU.Application.Tests; | ||
|
||
[TestClass] | ||
public abstract class ApplicationTestBase | ||
{ | ||
public sealed class ViewModelTestAttribute : TestMethodAttribute | ||
{ | ||
public override TestResult[] Execute(ITestMethod testMethod) | ||
{ | ||
if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA) | ||
return Invoke(testMethod); | ||
|
||
TestResult[] result = []; | ||
Thread thread = new(() => result = Invoke(testMethod)); | ||
thread.SetApartmentState(ApartmentState.STA); | ||
thread.Start(); | ||
thread.Join(); | ||
return result; | ||
} | ||
|
||
private static TestResult[] Invoke(ITestMethod testMethod) | ||
=> [testMethod.Invoke(null)]; | ||
} | ||
} |
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
5 changes: 1 addition & 4 deletions
5
tests/BB84.SAU.Application.Tests/Installer/DependencyInjectionTests.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
4 changes: 1 addition & 3 deletions
4
tests/BB84.SAU.Application.Tests/Services/NavigationServiceTests.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
34 changes: 34 additions & 0 deletions
34
tests/BB84.SAU.Application.Tests/Services/NotificationServiceTests.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,34 @@ | ||
using BB84.SAU.Application.Services; | ||
|
||
namespace BB84.SAU.Application.Tests.Services; | ||
|
||
[TestClass] | ||
public sealed class NotificationServiceTests | ||
{ | ||
[TestMethod] | ||
[TestCategory("Methods")] | ||
public void SendShouldRaiseNotificationReceivedEventHandler() | ||
{ | ||
bool notificationReceived = false; | ||
NotificationService service = new(); | ||
service.NotificationReceived += (s, e) => notificationReceived = true; | ||
|
||
service.Send(string.Empty); | ||
|
||
Assert.IsTrue(notificationReceived); | ||
} | ||
|
||
[TestMethod] | ||
[TestCategory("Methods")] | ||
public async Task SendAsyncShouldNotRaiseAsyncNotificationReceivedEventHandler() | ||
{ | ||
bool notificationReceived = false; | ||
NotificationService service = new(); | ||
service.AsyncNotificationReceived += (s, e) => Task.Run(() => notificationReceived = true); | ||
|
||
await service.SendAsync(string.Empty) | ||
.ConfigureAwait(true); | ||
|
||
Assert.IsTrue(notificationReceived); | ||
} | ||
} |
Oops, something went wrong.