diff --git a/NuGet.Config b/NuGet.Config
index ce878ee..7b4c829 100644
--- a/NuGet.Config
+++ b/NuGet.Config
@@ -3,5 +3,6 @@
+
\ No newline at end of file
diff --git a/VCF.Core/Registry/CommandRegistry.cs b/VCF.Core/Registry/CommandRegistry.cs
index 80acec0..00fb409 100644
--- a/VCF.Core/Registry/CommandRegistry.cs
+++ b/VCF.Core/Registry/CommandRegistry.cs
@@ -276,8 +276,8 @@ public static void UnregisterConverter(Type converter)
}
}
- internal static bool IsGenericConverterContext(Type rootType) => rootType.BaseType.Name == typeof(CommandArgumentConverter<>).Name;
- internal static bool IsSpecificConverterContext(Type rootType) => rootType.BaseType.Name == typeof(CommandArgumentConverter<,>).Name;
+ internal static bool IsGenericConverterContext(Type rootType) => rootType?.BaseType?.Name == typeof(CommandArgumentConverter<>).Name;
+ internal static bool IsSpecificConverterContext(Type rootType) => rootType?.BaseType?.Name == typeof(CommandArgumentConverter<,>).Name;
public static void RegisterConverter(Type converter)
{
diff --git a/VCF.Tests/AssertReplyContext.cs b/VCF.Tests/AssertReplyContext.cs
index 4eb945e..72b0e9c 100644
--- a/VCF.Tests/AssertReplyContext.cs
+++ b/VCF.Tests/AssertReplyContext.cs
@@ -25,16 +25,23 @@ public void Reply(string v)
public void AssertReply(string expected)
{
- Assert.That(_sb.ToString().TrimEnd(Environment.NewLine.ToCharArray()), Is.EqualTo(expected));
+ Assert.That(RepliedTextLfAndTrimmed(), Is.EqualTo(expected));
}
public void AssertReplyContains(string expected)
{
- var repliedText = _sb.ToString().TrimEnd(Environment.NewLine.ToCharArray());
+ var repliedText = RepliedTextLfAndTrimmed();
Assert.That(repliedText.Contains(expected), Is.True, $"Expected {expected} to be contained in replied: {repliedText}");
}
public void AssertInternalError()
{
- Assert.That(_sb.ToString().TrimEnd(Environment.NewLine.ToCharArray()), Is.EqualTo("[vcf] An internal error has occurred."));
+ Assert.That(RepliedTextLfAndTrimmed(), Is.EqualTo("[vcf] An internal error has occurred."));
+ }
+
+ private string RepliedTextLfAndTrimmed()
+ {
+ return _sb.ToString()
+ .Replace("\r\n", "\n") // LF instead of CRLF for line endings
+ .TrimEnd(Environment.NewLine.ToCharArray());
}
}
diff --git a/VCF.Tests/InitializationTests.cs b/VCF.Tests/InitializationTests.cs
new file mode 100644
index 0000000..04716bd
--- /dev/null
+++ b/VCF.Tests/InitializationTests.cs
@@ -0,0 +1,47 @@
+using System.Reflection;
+using FakeItEasy;
+using NUnit.Framework;
+using VampireCommandFramework;
+
+namespace VCF.Tests;
+
+public class InitializationTests
+{
+ [SetUp]
+ public void Setup()
+ {
+ CommandRegistry.Reset();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ CommandRegistry.Reset();
+ }
+
+ [Test]
+ public void ScanningInterfaceDoesNotCauseException()
+ {
+ Assert.DoesNotThrow(ScanAssemblyContainingInterface);
+ }
+
+ private void ScanAssemblyContainingInterface()
+ {
+ CommandRegistry.RegisterAll(AssemblyContainingInterface());
+ }
+
+ private Assembly AssemblyContainingInterface()
+ {
+ var mockAssembly = A.Fake();
+ A.CallTo(() => mockAssembly.GetTypes()).Returns(new Type[]{
+ typeof(ISomeInterface),
+ });
+ return mockAssembly;
+ }
+
+ private interface ISomeInterface
+ {
+
+ }
+
+}
\ No newline at end of file