-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: improve mutation score (#547)
Refactor some implementation details, to catch uncaught errors (see Stryker.NET): - Allow `null` in `IStorage.GetOrAddDrive` to simplify the implementation - Add tests for `Notification.ExecuteWhileWaiting` - Extract getting the name for an `AssemblyName` to an extension method to allow testing it - Avoid including the default value for `int` in the choices in the random tests - Extract getting a shared `IRandom` instance from the `IFileSystem` to an extension method to allow testing it - Fix the test for changing a disposed timer in .NET 8 or greater (it returns false instead of throwing an `ObjectDisposedException`)
- Loading branch information
Showing
15 changed files
with
194 additions
and
44 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
15 changes: 15 additions & 0 deletions
15
Source/Testably.Abstractions.Testing/Helpers/AssemblyNameExtensions.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,15 @@ | ||
using System.Reflection; | ||
|
||
namespace Testably.Abstractions.Testing.Helpers; | ||
|
||
internal static class AssemblyNameExtensions | ||
{ | ||
/// <summary> | ||
/// Returns the name of the <paramref name="assemblyName" /> or the <paramref name="defaultName" />, if it is | ||
/// <see langword="null" />. | ||
/// </summary> | ||
internal static string GetNameOrDefault(this AssemblyName assemblyName, string defaultName = "") | ||
{ | ||
return assemblyName.Name ?? defaultName; | ||
} | ||
} |
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
28 changes: 28 additions & 0 deletions
28
Tests/Testably.Abstractions.Testing.Tests/Helpers/AssemblyNameExtensionsTests.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,28 @@ | ||
using System.Reflection; | ||
using Testably.Abstractions.Testing.Helpers; | ||
|
||
namespace Testably.Abstractions.Testing.Tests.Helpers; | ||
|
||
public class AssemblyNameExtensionsTests | ||
{ | ||
[Fact] | ||
public void GetNameOrDefault_ExecutingAssembly_ShouldReturnCorrectString() | ||
{ | ||
AssemblyName assemblyName = Assembly.GetExecutingAssembly().GetName(); | ||
|
||
string result = assemblyName.GetNameOrDefault(); | ||
|
||
result.Should().Be("Testably.Abstractions.Testing.Tests"); | ||
} | ||
|
||
[Fact] | ||
public void GetNameOrDefault_NullName_ShouldReturnEmptyString() | ||
{ | ||
AssemblyName assemblyName = Assembly.GetExecutingAssembly().GetName(); | ||
assemblyName.Name = null; | ||
|
||
string result = assemblyName.GetNameOrDefault(); | ||
|
||
result.Should().Be(""); | ||
} | ||
} |
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
Oops, something went wrong.