Skip to content

Commit

Permalink
Rebaseline tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MattKotsenas committed Jun 1, 2024
1 parent 9ccb0cb commit f2ba570
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 87 deletions.
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
Diagnostic 1
Id: Moq1002
Location: SourceFile(Test1.cs[247..253))
Location: SourceFile(Test1.cs[223..229))
Highlight: ("42")
Lines: var mock = new Mock<AbstractClassWithCtor>("42");
Severity: Warning
Message: Parameters provided into mock do not match any existing constructors.

Diagnostic 2
Id: Moq1002
Location: SourceFile(Test1.cs[420..430))
Location: SourceFile(Test1.cs[388..398))
Highlight: ("42", 42)
Lines: var mock1 = new Mock<AbstractClassWithCtor>("42", 42);
Severity: Warning
Message: Parameters provided into mock do not match any existing constructors.

Diagnostic 3
Id: Moq1002
Location: SourceFile(Test1.cs[559..563))
Location: SourceFile(Test1.cs[519..523))
Highlight: (42)
Lines: var mock2 = new Mock<AbstractClassDefaultCtor>(42);
Severity: Warning
Message: Parameters provided into mock do not match any existing constructors.

Diagnostic 4
Id: Moq1002
Location: SourceFile(Test1.cs[780..786))
Location: SourceFile(Test1.cs[720..726))
Highlight: ("42")
Lines: var mock = new Mock<AbstractGenericClassWithCtor<object>>("42");
Severity: Warning
Message: Parameters provided into mock do not match any existing constructors.

Diagnostic 5
Id: Moq1002
Location: SourceFile(Test1.cs[968..978))
Location: SourceFile(Test1.cs[900..910))
Highlight: ("42", 42)
Lines: var mock1 = new Mock<AbstractGenericClassWithCtor<object>>("42", 42);
Severity: Warning
Message: Parameters provided into mock do not match any existing constructors.

Diagnostic 6
Id: Moq1002
Location: SourceFile(Test1.cs[1122..1126))
Location: SourceFile(Test1.cs[1046..1050))
Highlight: (42)
Lines: var mock2 = new Mock<AbstractGenericClassDefaultCtor<object>>(42);
Severity: Warning
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Diagnostic 1
Id: Moq1300
Location: SourceFile(Test0.cs[1366..1381))
Location: SourceFile(Test0.cs[1212..1227))
Highlight: BaseSampleClass
Lines: mock.As<BaseSampleClass>();
Severity: Error
Message: Mock.As() should take interfaces only

Diagnostic 2
Id: Moq1300
Location: SourceFile(Test0.cs[1531..1541))
Location: SourceFile(Test0.cs[1357..1367))
Highlight: OtherClass
Lines: mock.As<OtherClass>();
Severity: Error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
Diagnostic 1
Id: Moq1100
Location: SourceFile(Test0.cs[1079..1086))
Location: SourceFile(Test0.cs[1030..1037))
Highlight: (int i)
Lines: mock.Setup(x => x.Do(It.IsAny<string>())).Callback((int i) => { });
Severity: Warning
Message: Callback signature must match the signature of the mocked method.

Diagnostic 2
Id: Moq1100
Location: SourceFile(Test0.cs[1159..1181))
Location: SourceFile(Test0.cs[1106..1128))
Highlight: (string s1, string s2)
Lines: mock.Setup(x => x.Do(It.IsAny<string>())).Callback((string s1, string s2) => { });
Severity: Warning
Message: Callback signature must match the signature of the mocked method.

Diagnostic 3
Id: Moq1100
Location: SourceFile(Test0.cs[1293..1312))
Location: SourceFile(Test0.cs[1236..1255))
Highlight: (string s1, int i1)
Lines: mock.Setup(x => x.Do(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<DateTime>())).Callback((string s1, int i1) => { });
Severity: Warning
Message: Callback signature must match the signature of the mocked method.

Diagnostic 4
Id: Moq1100
Location: SourceFile(Test0.cs[1391..1398))
Location: SourceFile(Test0.cs[1330..1337))
Highlight: (int i)
Lines: mock.Setup(x => x.Do(It.IsAny<List<string>>())).Callback((int i) => { });
Severity: Warning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,57 @@ using Moq;
#pragma warning disable IDE0051 // Unused private member
#pragma warning disable IDE0059 // Unnecessary value assignment
#pragma warning disable IDE0060 // Unused parameter
namespace CallbackSignatureShouldMatchMockedMethod
namespace CallbackSignatureShouldMatchMockedMethod;

internal interface IFoo
{
internal interface IFoo
{
int Do(string s);
int Do(string s);

int Do(int i, string s, DateTime dt);
int Do(int i, string s, DateTime dt);

int Do(List<string> l);
}
int Do(List<string> l);
}

internal class MyUnitTests
internal class MyUnitTests
{
private void TestBadCallbacks()
{
private void TestBadCallbacks()
{
var mock = new Mock<IFoo>();
mock.Setup(x => x.Do(It.IsAny<string>())).Callback((string s) => { });
mock.Setup(x => x.Do(It.IsAny<string>())).Callback((string s) => { });
mock.Setup(x => x.Do(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<DateTime>())).Callback((int i, string s, DateTime dt) => { });
mock.Setup(x => x.Do(It.IsAny<List<string>>())).Callback((List<string> l) => { });
}
var mock = new Mock<IFoo>();
mock.Setup(x => x.Do(It.IsAny<string>())).Callback((string s) => { });
mock.Setup(x => x.Do(It.IsAny<string>())).Callback((string s) => { });
mock.Setup(x => x.Do(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<DateTime>())).Callback((int i, string s, DateTime dt) => { });
mock.Setup(x => x.Do(It.IsAny<List<string>>())).Callback((List<string> l) => { });
}

private void TestGoodSetupAndParameterlessCallback()
{
var mock = new Mock<IFoo>();
mock.Setup(x => x.Do(It.IsAny<string>())).Callback(() => { });
mock.Setup(x => x.Do(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<DateTime>())).Callback(() => { });
mock.Setup(x => x.Do(It.IsAny<List<string>>())).Callback(() => { });
}
private void TestGoodSetupAndParameterlessCallback()
{
var mock = new Mock<IFoo>();
mock.Setup(x => x.Do(It.IsAny<string>())).Callback(() => { });
mock.Setup(x => x.Do(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<DateTime>())).Callback(() => { });
mock.Setup(x => x.Do(It.IsAny<List<string>>())).Callback(() => { });
}

private void TestGoodSetupAndCallback()
{
var mock = new Mock<IFoo>();
mock.Setup(x => x.Do(It.IsAny<string>())).Callback((string s) => { });
mock.Setup(x => x.Do(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<DateTime>())).Callback((int i, string s, DateTime dt) => { });
mock.Setup(x => x.Do(It.IsAny<List<string>>())).Callback((List<string> l) => { });
}
private void TestGoodSetupAndCallback()
{
var mock = new Mock<IFoo>();
mock.Setup(x => x.Do(It.IsAny<string>())).Callback((string s) => { });
mock.Setup(x => x.Do(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<DateTime>())).Callback((int i, string s, DateTime dt) => { });
mock.Setup(x => x.Do(It.IsAny<List<string>>())).Callback((List<string> l) => { });
}

private void TestGoodSetupAndReturnsAndCallback()
{
var mock = new Mock<IFoo>();
mock.Setup(x => x.Do(It.IsAny<string>())).Returns(0).Callback((string s) => { });
mock.Setup(x => x.Do(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<DateTime>())).Returns(0).Callback((int i, string s, DateTime dt) => { });
mock.Setup(x => x.Do(It.IsAny<List<string>>())).Returns(0).Callback((List<string> l) => { });
}
private void TestGoodSetupAndReturnsAndCallback()
{
var mock = new Mock<IFoo>();
mock.Setup(x => x.Do(It.IsAny<string>())).Returns(0).Callback((string s) => { });
mock.Setup(x => x.Do(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<DateTime>())).Returns(0).Callback((int i, string s, DateTime dt) => { });
mock.Setup(x => x.Do(It.IsAny<List<string>>())).Returns(0).Callback((List<string> l) => { });
}

private void MyGoodSetupAndReturns()
{
var mock = new Mock<IFoo>();
mock.Setup(x => x.Do(It.IsAny<string>())).Returns((string s) => { return 0; });
mock.Setup(x => x.Do(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<DateTime>())).Returns((int i, string s, DateTime dt) => { return 0; });
mock.Setup(x => x.Do(It.IsAny<List<string>>())).Returns((List<string> l) => { return 0; });
}
private void MyGoodSetupAndReturns()
{
var mock = new Mock<IFoo>();
mock.Setup(x => x.Do(It.IsAny<string>())).Returns((string s) => { return 0; });
mock.Setup(x => x.Do(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<DateTime>())).Returns((int i, string s, DateTime dt) => { return 0; });
mock.Setup(x => x.Do(It.IsAny<List<string>>())).Returns((List<string> l) => { return 0; });
}
}
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
Diagnostic 1
Id: Moq1002
Location: SourceFile(Test0.cs[1216..1225))
Location: SourceFile(Test0.cs[1167..1176))
Highlight: (1, true)
Lines: var mock1 = new Moq.Mock<Foo>(1, true);
Severity: Warning
Message: Parameters provided into mock do not match any existing constructors.

Diagnostic 2
Id: Moq1002
Location: SourceFile(Test0.cs[1296..1305))
Location: SourceFile(Test0.cs[1243..1252))
Highlight: (2, true)
Lines: var mock2 = new Mock<ConstructorArgumentsShouldMatch.Foo>(2, true);
Severity: Warning
Message: Parameters provided into mock do not match any existing constructors.

Diagnostic 3
Id: Moq1002
Location: SourceFile(Test0.cs[1376..1384))
Location: SourceFile(Test0.cs[1319..1327))
Highlight: ("1", 3)
Lines: var mock3 = new Mock<ConstructorArgumentsShouldMatch.Foo>("1", 3);
Severity: Warning
Message: Parameters provided into mock do not match any existing constructors.

Diagnostic 4
Id: Moq1002
Location: SourceFile(Test0.cs[1455..1478))
Location: SourceFile(Test0.cs[1394..1417))
Highlight: (new int[] { 1, 2, 3 })
Lines: var mock4 = new Mock<ConstructorArgumentsShouldMatch.Foo>(new int[] { 1, 2, 3 });
Severity: Warning
Message: Parameters provided into mock do not match any existing constructors.

Diagnostic 5
Id: Moq1002
Location: SourceFile(Test0.cs[1570..1600))
Location: SourceFile(Test0.cs[1493..1523))
Highlight: (MockBehavior.Strict, 4, true)
Lines: var mock1 = new Mock<Foo>(MockBehavior.Strict, 4, true);
Severity: Warning
Message: Parameters provided into mock do not match any existing constructors.

Diagnostic 6
Id: Moq1002
Location: SourceFile(Test0.cs[1675..1704))
Location: SourceFile(Test0.cs[1594..1623))
Highlight: (MockBehavior.Loose, 5, true)
Lines: var mock2 = new Moq.Mock<ConstructorArgumentsShouldMatch.Foo>(MockBehavior.Loose, 5, true);
Severity: Warning
Message: Parameters provided into mock do not match any existing constructors.

Diagnostic 7
Id: Moq1002
Location: SourceFile(Test0.cs[1779..1807))
Location: SourceFile(Test0.cs[1694..1722))
Highlight: (MockBehavior.Loose, "2", 6)
Lines: var mock3 = new Moq.Mock<ConstructorArgumentsShouldMatch.Foo>(MockBehavior.Loose, "2", 6);
Severity: Warning
Expand Down
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
Diagnostic 1
Id: Moq1001
Location: SourceFile(Test0.cs[831..841))
Location: SourceFile(Test0.cs[794..804))
Highlight: (25, true)
Lines: var mock1 = new Moq.Mock<IMyService>(25, true);
Severity: Warning
Message: Mocked interfaces cannot have constructor parameters.

Diagnostic 2
Id: Moq1001
Location: SourceFile(Test0.cs[887..894))
Location: SourceFile(Test0.cs[846..853))
Highlight: ("123")
Lines: var mock2 = new Mock<IMyService>("123");
Severity: Warning
Message: Mocked interfaces cannot have constructor parameters.

Diagnostic 3
Id: Moq1001
Location: SourceFile(Test0.cs[981..991))
Location: SourceFile(Test0.cs[936..946))
Highlight: (25, true)
Lines: var mock3 = new Mock<NoConstructorArgumentsForInterfaceMock_1.IMyService>(25, true);
Severity: Warning
Message: Mocked interfaces cannot have constructor parameters.

Diagnostic 4
Id: Moq1001
Location: SourceFile(Test0.cs[1082..1089))
Location: SourceFile(Test0.cs[1033..1040))
Highlight: ("123")
Lines: var mock4 = new Moq.Mock<NoConstructorArgumentsForInterfaceMock_1.IMyService>("123");
Severity: Warning
Message: Mocked interfaces cannot have constructor parameters.

Diagnostic 5
Id: Moq1001
Location: SourceFile(Test0.cs[1192..1225))
Location: SourceFile(Test0.cs[1127..1160))
Highlight: (Moq.MockBehavior.Default, "123")
Lines: var mock1 = new Moq.Mock<IMyService>(Moq.MockBehavior.Default, "123");
Severity: Warning
Message: Mocked interfaces cannot have constructor parameters.

Diagnostic 6
Id: Moq1001
Location: SourceFile(Test0.cs[1271..1302))
Location: SourceFile(Test0.cs[1202..1233))
Highlight: (MockBehavior.Strict, 25, true)
Lines: var mock2 = new Mock<IMyService>(MockBehavior.Strict, 25, true);
Severity: Warning
Message: Mocked interfaces cannot have constructor parameters.

Diagnostic 7
Id: Moq1001
Location: SourceFile(Test0.cs[1389..1422))
Location: SourceFile(Test0.cs[1316..1349))
Highlight: (Moq.MockBehavior.Default, "123")
Lines: var mock3 = new Mock<NoConstructorArgumentsForInterfaceMock_1.IMyService>(Moq.MockBehavior.Default, "123");
Severity: Warning
Message: Mocked interfaces cannot have constructor parameters.

Diagnostic 8
Id: Moq1001
Location: SourceFile(Test0.cs[1513..1543))
Location: SourceFile(Test0.cs[1436..1466))
Highlight: (MockBehavior.Loose, 25, true)
Lines: var mock4 = new Moq.Mock<NoConstructorArgumentsForInterfaceMock_1.IMyService>(MockBehavior.Loose, 25, true);
Severity: Warning
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
Diagnostic 1
Id: Moq1001
Location: SourceFile(Test0.cs[1180..1189))
Location: SourceFile(Test0.cs[1088..1097))
Highlight: (1, true)
Lines: var mock1 = new Moq.Mock<IMyService>(1, true);
Severity: Warning
Message: Mocked interfaces cannot have constructor parameters.

Diagnostic 2
Id: Moq1001
Location: SourceFile(Test0.cs[1280..1285))
Location: SourceFile(Test0.cs[1184..1189))
Highlight: ("2")
Lines: var mock2 = new Moq.Mock<NoConstructorArgumentsForInterfaceMock_2.IMyService>("2");
Severity: Warning
Message: Mocked interfaces cannot have constructor parameters.

Diagnostic 3
Id: Moq1001
Location: SourceFile(Test0.cs[1335..1366))
Location: SourceFile(Test0.cs[1235..1266))
Highlight: (Moq.MockBehavior.Default, "3")
Lines: var mock3 = new Moq.Mock<IMyService>(Moq.MockBehavior.Default, "3");
Severity: Warning
Message: Mocked interfaces cannot have constructor parameters.

Diagnostic 4
Id: Moq1001
Location: SourceFile(Test0.cs[1457..1486))
Location: SourceFile(Test0.cs[1353..1382))
Highlight: (MockBehavior.Loose, 4, true)
Lines: var mock4 = new Moq.Mock<NoConstructorArgumentsForInterfaceMock_2.IMyService>(MockBehavior.Loose, 4, true);
Severity: Warning
Message: Mocked interfaces cannot have constructor parameters.

Diagnostic 5
Id: Moq1001
Location: SourceFile(Test0.cs[1536..1558))
Location: SourceFile(Test0.cs[1428..1450))
Highlight: (MockBehavior.Default)
Lines: var mock5 = new Moq.Mock<IMyService>(MockBehavior.Default);
Severity: Warning
Message: Mocked interfaces cannot have constructor parameters.

Diagnostic 6
Id: Moq1001
Location: SourceFile(Test0.cs[1649..1671))
Location: SourceFile(Test0.cs[1537..1559))
Highlight: (MockBehavior.Default)
Lines: var mock6 = new Moq.Mock<NoConstructorArgumentsForInterfaceMock_2.IMyService>(MockBehavior.Default);
Severity: Warning
Expand Down
Loading

0 comments on commit f2ba570

Please sign in to comment.