From dcd245d2ab40da10280115d56e769e19ea8f4344 Mon Sep 17 00:00:00 2001 From: Richard Murillo Date: Tue, 27 Aug 2024 10:59:25 -0700 Subject: [PATCH] Add additional repro cases for #172 (thanks @marcovr) --- ...tureShouldMatchMockedMethodCodeFixTests.cs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/Moq.Analyzers.Test/CallbackSignatureShouldMatchMockedMethodCodeFixTests.cs b/tests/Moq.Analyzers.Test/CallbackSignatureShouldMatchMockedMethodCodeFixTests.cs index 7baa2f21..101543dc 100644 --- a/tests/Moq.Analyzers.Test/CallbackSignatureShouldMatchMockedMethodCodeFixTests.cs +++ b/tests/Moq.Analyzers.Test/CallbackSignatureShouldMatchMockedMethodCodeFixTests.cs @@ -81,10 +81,26 @@ public static IEnumerable TestData() """new Mock().Setup(x => x.Do(It.IsAny>())).Returns(0).Callback((List l) => { });""", """new Mock().Setup(x => x.Do(It.IsAny>())).Returns(0).Callback((List l) => { });""", ], - [ // Repro for https://github.com/rjmurillo/moq.analyzers/issues/172 + [ // Repros for https://github.com/rjmurillo/moq.analyzers/issues/172 """new Mock().Setup(m => m.Do(It.IsAny())).Returns((object? bar) => true);""", """new Mock().Setup(m => m.Do(It.IsAny())).Returns((object? bar) => true);""", ], + [ + """new Mock().Setup(m => m.Do(42)).Returns((long bar) => true);""", + """new Mock().Setup(m => m.Do(42)).Returns((long bar) => true);""", + ], + [ + """new Mock().Setup(m => m.Do((long)42)).Returns((long bar) => true);""", + """new Mock().Setup(m => m.Do((long)42)).Returns((long bar) => true);""", + ], + [ + """new Mock().Setup(m => m.Do((long)42)).Returns((long bar) => true);""", + """new Mock().Setup(m => m.Do((long)42)).Returns((long bar) => true);""", + ], + [ // This was also reported as part of 172, but is a different error + """new Mock().Setup(m => m.Do(42)).Returns((int bar) => true);""", + """new Mock().Setup(m => m.Do(42)).Returns((int bar) => true);""", + ], }.WithNamespaces().WithMoqReferenceAssemblyGroups(); } @@ -105,6 +121,8 @@ internal interface IFoo int Do(List l); bool Do(object? bar); + + // bool Do(long bar); } internal class UnitTest