Skip to content

Commit

Permalink
Merge pull request #37 from messerli-informatik-ag/change-exception-type
Browse files Browse the repository at this point in the history
Change exception type
  • Loading branch information
dngroth authored Apr 6, 2020
2 parents 093a89f + f526031 commit 3a6b457
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void FindsAssemblyWhenCodeHasNoExplicitReferenceToAssembly()
[Fact]
public void ThrowsWhenAssemblyIsNotFound()
{
Assert.Throws<ArgumentException>(() =>
Assert.Throws<InvalidOperationException>(() =>
TypesThatNeedToBeImplementedInAssemblyRetriever.GetTypesThatNeedToBeImplementedInAssembly("NonExistingAssembly"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ namespace Messerli.Test.Utility
{
internal static class TypesThatNeedToBeImplementedInAssemblyRetriever
{
/// <exception cref="InvalidOperationException">Thrown when the assembly is not loaded or invalid.</exception>
// Note to future developer: When throwing new exception types make sure that they are displayed by the test explorer.
// Exceptions that don't get displayed properly are: ArgumentException
public static IEnumerable<Type> GetTypesThatNeedToBeImplementedInAssembly(string assemblyName)
=> GetAssemblyFromLoadedAssemblies(assemblyName)
.GetTypes()
Expand All @@ -17,7 +20,7 @@ private static Assembly GetAssemblyFromLoadedAssemblies(string assemblyName)
=> AppDomain.CurrentDomain
.GetAssemblies()
.SingleOrDefault(assembly => assembly.GetName().Name == assemblyName)
?? throw new ArgumentException($"Assembly '{assemblyName}' is not loaded or does not exist", nameof(assemblyName));
?? throw new InvalidOperationException($"Assembly '{assemblyName}' is not loaded or does not exist");

private static bool IsImplementableType(Type type)
=> IsDelegate(type) || IsImplementableInterface(type) || IsAbstractClass(type);
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ Rerelease of 0.6.0 with fixed nuget package.

## 0.7.3
- Allow blacklisting of types on `TypesThatNeedToBeImplementedInAssemblyData` attribute using a new attribute: `ExcludedTypes`.

## Unreleased
- Make sure that the exception thrown by the `TypesThatNeedToBeImplementedInAssemblyData` attribute
when the specified assembly can't be found is displayed in the test explorer.

0 comments on commit 3a6b457

Please sign in to comment.