-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate from ApprovalTests to Verify (#25)
* Do the minimal, mechanical conversion from ApprovalTests to Verify * Enable ImplicitUsings, C# 12, and Nullable
- Loading branch information
1 parent
edfc0e3
commit 9d37487
Showing
31 changed files
with
412 additions
and
729 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<Project> | ||
<Import Project="build/targets/artifacts/Artifacts.targets" /> | ||
<Import Project="build/targets/compiler/Compiler.targets" /> | ||
<Import Project="build/targets/tests/Tests.targets" /> | ||
</Project> |
32 changes: 16 additions & 16 deletions
32
...s.ShouldPassIfGoodParameters.approved.txt → ...s.ShouldPassIfGoodParameters.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
Diagnostic 1 | ||
Id: Moq1300 | ||
Location: SourceFile(Test0.cs[1376..1391)) | ||
Highlight: BaseSampleClass | ||
Lines: mock.As<BaseSampleClass>(); | ||
Severity: Error | ||
Message: Mock.As() should take interfaces only | ||
Diagnostic 2 | ||
Id: Moq1300 | ||
Location: SourceFile(Test0.cs[1541..1551)) | ||
Highlight: OtherClass | ||
Lines: mock.As<OtherClass>(); | ||
Severity: Error | ||
Message: Mock.As() should take interfaces only | ||
Diagnostic 1 | ||
Id: Moq1300 | ||
Location: SourceFile(Test0.cs[1376..1391)) | ||
Highlight: BaseSampleClass | ||
Lines: mock.As<BaseSampleClass>(); | ||
Severity: Error | ||
Message: Mock.As() should take interfaces only | ||
|
||
Diagnostic 2 | ||
Id: Moq1300 | ||
Location: SourceFile(Test0.cs[1541..1551)) | ||
Highlight: OtherClass | ||
Lines: mock.As<OtherClass>(); | ||
Severity: Error | ||
Message: Mock.As() should take interfaces only | ||
|
8 changes: 3 additions & 5 deletions
8
Source/Moq.Analyzers.Test/AsAcceptOnlyInterfaceAnalyzerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
...SignatureShouldMatchMockedMethodAnalyzerTests.ShouldPassIfGoodParameters.approved.txt.bak
This file was deleted.
Oops, something went wrong.
64 changes: 32 additions & 32 deletions
64
...s.ShouldPassIfGoodParameters.approved.txt → ...s.ShouldPassIfGoodParameters.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
Diagnostic 1 | ||
Id: Moq1100 | ||
Location: SourceFile(Test0.cs[1120..1127)) | ||
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[1201..1223)) | ||
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[1336..1355)) | ||
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[1435..1442)) | ||
Highlight: (int i) | ||
Lines: mock.Setup(x => x.Do(It.IsAny<List<string>>())).Callback((int i) => { }); | ||
Severity: Warning | ||
Message: Callback signature must match the signature of the mocked method. | ||
Diagnostic 1 | ||
Id: Moq1100 | ||
Location: SourceFile(Test0.cs[1120..1127)) | ||
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[1201..1223)) | ||
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[1336..1355)) | ||
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[1435..1442)) | ||
Highlight: (int i) | ||
Lines: mock.Setup(x => x.Do(It.IsAny<List<string>>())).Callback((int i) => { }); | ||
Severity: Warning | ||
Message: Callback signature must match the signature of the mocked method. | ||
|
8 changes: 3 additions & 5 deletions
8
Source/Moq.Analyzers.Test/CallbackSignatureShouldMatchMockedMethodAnalyzerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 0 additions & 62 deletions
62
...ShouldMatchMockedMethodCodeFixTests.ShouldSuggestQuickFixIfBadParameters.approved.txt.bak
This file was deleted.
Oops, something went wrong.
136 changes: 68 additions & 68 deletions
136
...ggestQuickFixIfBadParameters.approved.txt → ...ggestQuickFixIfBadParameters.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,69 @@ | ||
#pragma warning disable SA1402 // File may only contain a single class | ||
#pragma warning disable SA1502 // Element must not be on a single line | ||
#pragma warning disable SA1602 // Undocumented enum values | ||
#pragma warning disable SA1649 // File name must match first type name | ||
#pragma warning disable RCS1021 // Simplify lambda expression | ||
#pragma warning disable RCS1163 // Unused parameter | ||
#pragma warning disable RCS1213 // Remove unused member declaration | ||
#pragma warning disable IDE0051 // Unused private member | ||
#pragma warning disable IDE0059 // Unnecessary value assignment | ||
#pragma warning disable IDE0060 // Unused parameter | ||
namespace CallbackSignatureShouldMatchMockedMethod | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Moq; | ||
internal interface IFoo | ||
{ | ||
int Do(string s); | ||
int Do(int i, string s, DateTime dt); | ||
int Do(List<string> l); | ||
} | ||
internal class MyUnitTests | ||
{ | ||
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) => { }); | ||
} | ||
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 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; }); | ||
} | ||
} | ||
#pragma warning disable SA1402 // File may only contain a single class | ||
#pragma warning disable SA1502 // Element must not be on a single line | ||
#pragma warning disable SA1602 // Undocumented enum values | ||
#pragma warning disable SA1649 // File name must match first type name | ||
#pragma warning disable RCS1021 // Simplify lambda expression | ||
#pragma warning disable RCS1163 // Unused parameter | ||
#pragma warning disable RCS1213 // Remove unused member declaration | ||
#pragma warning disable IDE0051 // Unused private member | ||
#pragma warning disable IDE0059 // Unnecessary value assignment | ||
#pragma warning disable IDE0060 // Unused parameter | ||
namespace CallbackSignatureShouldMatchMockedMethod | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Moq; | ||
|
||
internal interface IFoo | ||
{ | ||
int Do(string s); | ||
|
||
int Do(int i, string s, DateTime dt); | ||
|
||
int Do(List<string> l); | ||
} | ||
|
||
internal class MyUnitTests | ||
{ | ||
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) => { }); | ||
} | ||
|
||
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 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; }); | ||
} | ||
} | ||
} |
Oops, something went wrong.