diff --git a/Octokit.Tests.Conventions/Exception/ReturnValueMismatchException.cs b/Octokit.Tests.Conventions/Exception/ReturnValueMismatchException.cs new file mode 100644 index 00000000..121751d7 --- /dev/null +++ b/Octokit.Tests.Conventions/Exception/ReturnValueMismatchException.cs @@ -0,0 +1,23 @@ +using System; +using System.Reflection; +using System.Runtime.Serialization; + +namespace Octokit.Tests.Conventions +{ + public class ReturnValueMismatchException : Exception + { + public ReturnValueMismatchException(MethodInfo method, Type expected, Type actual) + : base(CreateMessage(method, expected, actual)) { } + + public ReturnValueMismatchException(MethodInfo method, Type expected, Type actual, Exception innerException) + : base(CreateMessage(method, expected, actual), innerException) { } + + protected ReturnValueMismatchException(SerializationInfo info, StreamingContext context) + : base(info, context) { } + + static string CreateMessage(MethodInfo method, Type expected, Type actual) + { + return String.Format("Return value for {0}.{1} must be {2} but is {3}", method.DeclaringType.Name, method.Name, expected, actual); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 8979df85..8caa28f7 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -53,6 +53,7 @@ + diff --git a/Octokit.Tests.Conventions/SyncObservableClients.cs b/Octokit.Tests.Conventions/SyncObservableClients.cs index c78e5a47..c78eb4cd 100644 --- a/Octokit.Tests.Conventions/SyncObservableClients.cs +++ b/Octokit.Tests.Conventions/SyncObservableClients.cs @@ -59,7 +59,11 @@ namespace Octokit.Tests.Conventions var mainReturnType = mainMethod.ReturnType; var observableReturnType = observableMethod.ReturnType; var expectedType = GetObservableExpectedType(mainReturnType); - Assert.Equal(expectedType, observableReturnType); + + if (expectedType != observableReturnType) + { + throw new ReturnValueMismatchException(observableMethod, expectedType, observableReturnType); + } } private static Type GetObservableExpectedType(Type mainType)