public static void ExecuteViaReflection_void___Should_throw_ArgumentException___When_protocol_cannot_execute_operation() { // Arrange var operation = new DummyVoidOperation(); var protocol1 = new ProtocolWithNoOperations(); var protocol2 = new SiblingOperationProtocol(); // Act var actual1 = Record.Exception(() => protocol1.ExecuteViaReflection(operation)); var actual2 = Record.Exception(() => protocol2.ExecuteViaReflection(operation)); // Assert actual1.AsTest().Must().BeOfType <ArgumentException>(); actual1.Message.AsTest().Must().ContainString(Invariant($"The specified '{nameof(ProtocolExtensionsTest)}.{nameof(ProtocolWithNoOperations)}' protocol does not have a void Execute method with a single parameter that the specified '{nameof(ProtocolExtensionsTest)}.{nameof(DummyVoidOperation)}' operation is assignable to.")); actual2.AsTest().Must().BeOfType <ArgumentException>(); actual2.Message.AsTest().Must().ContainString(Invariant($"The specified '{nameof(ProtocolExtensionsTest)}.{nameof(SiblingOperationProtocol)}' protocol does not have a void Execute method with a single parameter that the specified '{nameof(ProtocolExtensionsTest)}.{nameof(DummyVoidOperation)}' operation is assignable to.")); }
public static async Task ExecuteViaReflectionAsync_TResult___Should_throw_ArgumentException___When_protocol_cannot_execute_operation() { // Arrange var operation = new DummyReturningOperation(); var protocol1 = new ProtocolWithNoOperations(); var protocol2 = new SiblingOperationProtocol(); // Act var actual1 = await Record.ExceptionAsync(() => protocol1.ExecuteViaReflectionAsync <int>(operation)); var actual2 = await Record.ExceptionAsync(() => protocol2.ExecuteViaReflectionAsync <int>(operation)); // Assert actual1.AsTest().Must().BeOfType <ArgumentException>(); actual1.Message.AsTest().Must().ContainString(Invariant($"The specified '{nameof(ProtocolExtensionsTest)}.{nameof(ProtocolWithNoOperations)}' protocol does not have a returning ExecuteAsync method with a single parameter that the specified '{nameof(ProtocolExtensionsTest)}.{nameof(DummyReturningOperation)}' operation is assignable to AND a return type that is assignable to the specified 'int' return type.")); actual2.AsTest().Must().BeOfType <ArgumentException>(); actual2.Message.AsTest().Must().ContainString(Invariant($"The specified '{nameof(ProtocolExtensionsTest)}.{nameof(SiblingOperationProtocol)}' protocol does not have a returning ExecuteAsync method with a single parameter that the specified '{nameof(ProtocolExtensionsTest)}.{nameof(DummyReturningOperation)}' operation is assignable to AND a return type that is assignable to the specified 'int' return type.")); }