Skip to content

Commit

Permalink
Merge AbstractClassTests into ConstructorArgumentsShouldMatchAnalyzer…
Browse files Browse the repository at this point in the history
…Tests
  • Loading branch information
MattKotsenas committed Jun 10, 2024
1 parent 0e71e50 commit 37433b5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 159 deletions.
156 changes: 0 additions & 156 deletions Source/Moq.Analyzers.Test/AbstractClassTests.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ public static IEnumerable<object[]> TestData()
yield return [@namespace, """new Mock<Foo>{|Moq1002:(MockBehavior.Strict, 4, true)|};"""];
yield return [@namespace, """new Mock<Foo>{|Moq1002:(MockBehavior.Loose, 5, true)|};"""];
yield return [@namespace, """new Mock<Foo>{|Moq1002:(MockBehavior.Loose, "2", 6)|};"""];
yield return [@namespace, """new Mock<AbstractGenericClassWithCtor<object>>{|Moq1002:("42")|};"""];
yield return [@namespace, """new Mock<AbstractGenericClassWithCtor<object>>{|Moq1002:("42", 42)|};"""];
yield return [@namespace, """new Mock<AbstractGenericClassDefaultCtor<object>>{|Moq1002:(42)|};"""];
// TODO: Review use of `.As<>()` in this test case. It is not clear what purpose it serves.
yield return [@namespace, """new Mock<AbstractGenericClassDefaultCtor<object>>().As<AbstractGenericClassDefaultCtor<object>>();"""];
yield return [@namespace, """new Mock<AbstractGenericClassDefaultCtor<object>>();"""];
yield return [@namespace, """new Mock<AbstractGenericClassDefaultCtor<object>>(MockBehavior.Default);"""];
// TODO: "I think this _should_ fail, but currently passes. Tracked by #55."
// TODO: Review use of `.As<>()` in this test case. It is not clear what purpose it serves.
// yield return [@namespace, """new Mock<AbstractClassWithCtor>().As<AbstractClassWithCtor>();"""];
yield return [@namespace, """new Mock<AbstractClassWithCtor>{|Moq1002:("42")|};"""];
yield return [@namespace, """new Mock<AbstractClassWithCtor>{|Moq1002:("42", 42)|};"""];
yield return [@namespace, """new Mock<AbstractClassDefaultCtor>{|Moq1002:(42)|};"""];
// TODO: Review use of `.As<>()` in this test case. It is not clear what purpose it serves.
yield return [@namespace, """new Mock<AbstractClassDefaultCtor>().As<AbstractClassDefaultCtor>();"""];
yield return [@namespace, """new Mock<AbstractClassWithCtor>(42);"""];
yield return [@namespace, """new Mock<AbstractClassWithCtor>(MockBehavior.Default, 42);"""];
yield return [@namespace, """new Mock<AbstractClassWithCtor>(42, "42");"""];
yield return [@namespace, """new Mock<AbstractClassWithCtor>(MockBehavior.Default, 42, "42");"""];
yield return [@namespace, """new Mock<AbstractGenericClassWithCtor<object>>(42);"""];
yield return [@namespace, """new Mock<AbstractGenericClassWithCtor<object>>(MockBehavior.Default, 42);"""];
}
}

Expand All @@ -45,14 +66,33 @@ await Verifier.VerifyAnalyzerAsync(
internal class Foo
{
public Foo(string s) { }
public Foo(bool b, int i) { }
public Foo(params DateTime[] dates) { }
public Foo(List<string> l, string s = "A") { }
}
internal abstract class AbstractClassDefaultCtor
{
protected AbstractClassDefaultCtor() { }
}
internal abstract class AbstractGenericClassDefaultCtor<T>
{
protected AbstractGenericClassDefaultCtor() { }
}
internal abstract class AbstractClassWithCtor
{
protected AbstractClassWithCtor(int a) { }
protected AbstractClassWithCtor(int a, string b) { }
}
internal abstract class AbstractGenericClassWithCtor<T>
{
protected AbstractGenericClassWithCtor(int a) { }
protected AbstractGenericClassWithCtor(int a, string b) { }
}
internal class UnitTest
{
private void Test()
Expand Down

0 comments on commit 37433b5

Please sign in to comment.