Skip to content

Commit e27b34d

Browse files
Fix the unit tests previously failed.
1 parent fb59569 commit e27b34d

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/Moq.Analyzers/Analyzers/MockInstanceShouldBeStrictBehaviorAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private static void Analyze(SyntaxNodeAnalysisContext context)
8989

9090
if (!SymbolEqualityComparer.Default.Equals(firstArgumentType.Symbol, mockBehaviorType))
9191
{
92-
var diagnostic = Diagnostic.Create(Rule, objectCreation.GetLocation());
92+
var diagnostic = Diagnostic.Create(Rule, firstArgument.GetLocation());
9393
context.ReportDiagnostic(diagnostic);
9494

9595
return;

tests/Moq.Analyzers.Tests/Analyzers/MockInstanceShouldBeStrictBehaviorAnalyzerTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class TestClass
2424
{
2525
public void TestMethod()
2626
{
27+
var obj = new object();
2728
}
2829
}
2930
@@ -179,7 +180,7 @@ public class TestClass
179180
{
180181
public void TestMethod()
181182
{
182-
var mock1 = new Mock<I>([|default|], 1, 2);
183+
var mock1 = [|new Mock<I>(default, 1, 2)|];
183184
}
184185
}
185186

tests/Moq.Analyzers.Tests/CodeFixes/SetBehaviorToStrictCodeFixProviderTest.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,18 @@ public class TestClass
211211
{
212212
public void TestMethod()
213213
{
214-
var mock = [|new Mock<I>(1, 2, 3)|];
214+
var mock1 = [|new Mock<I>(1, 2, 3)|];
215+
var mock2 = new Mock<I>(MockBehavior.[|Loose|], 1, 2, 3);
216+
var mock3 = new Mock<I>([|OtherEnum.A|], 1, 2, 3);
217+
var mock4 = new Mock<I>([|int.MaxValue|], 1, 2, 3);
215218
}
216219
}
217220
218221
public interface I
219222
{
220223
}
224+
225+
public enum OtherEnum { A }
221226
}
222227
223228
namespace Moq
@@ -254,13 +259,18 @@ public class TestClass
254259
{
255260
public void TestMethod()
256261
{
257-
var mock = new Mock<I>(MockBehavior.Strict, 1, 2, 3);
262+
var mock1 = new Mock<I>(MockBehavior.Strict, 1, 2, 3);
263+
var mock2 = new Mock<I>(MockBehavior.Strict, 1, 2, 3);
264+
var mock3 = new Mock<I>(MockBehavior.Strict, OtherEnum.A, 1, 2, 3);
265+
var mock4 = new Mock<I>(MockBehavior.Strict, int.MaxValue, 1, 2, 3);
258266
}
259267
}
260268
261269
public interface I
262270
{
263271
}
272+
273+
public enum OtherEnum { A }
264274
}
265275
266276
namespace Moq

0 commit comments

Comments
 (0)