From 26b250050d61a9abf8d25fd3634f98ab659fb020 Mon Sep 17 00:00:00 2001 From: stakx Date: Wed, 14 Aug 2019 23:19:48 +0200 Subject: [PATCH 1/4] Show that Moq handles event handlers less strictly than the CLI --- .../EventHandlerTypesMustMatchFixture.cs | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/Moq.Tests/EventHandlerTypesMustMatchFixture.cs diff --git a/tests/Moq.Tests/EventHandlerTypesMustMatchFixture.cs b/tests/Moq.Tests/EventHandlerTypesMustMatchFixture.cs new file mode 100644 index 000000000..e618d9949 --- /dev/null +++ b/tests/Moq.Tests/EventHandlerTypesMustMatchFixture.cs @@ -0,0 +1,71 @@ +// Copyright (c) 2007, Clarius Consulting, Manas Technology Solutions, InSTEDD. +// All rights reserved. Licensed under the BSD 3-Clause License; see License.txt. + +using System; + +using Xunit; + +namespace Moq.Tests +{ + public class EventHandlerTypesMustMatchFixture + { + [Fact] + public void CLI_requires_event_handlers_to_have_the_exact_same_type() + { + var mouse = new Mouse(); + var result = 2; + + mouse.LeftButtonClicked += new Action(_ => result += 3); + mouse.LeftButtonClicked += new Action(_ => result *= 4); + mouse.RaiseLeftButtonClicked(new LeftButton()); + + Assert.Equal(20, result); + } + + [Fact] + public void CLI_throws_if_event_handlers_do_not_have_the_exact_same_type() + { + var mouse = new Mouse(); + mouse.LeftButtonClicked += new Action