Skip to content

Commit

Permalink
Merge pull request #6 from inyutin-maxim/master
Browse files Browse the repository at this point in the history
Implement Moq.Automock support
  • Loading branch information
lconstan authored Apr 6, 2020
2 parents c901183 + 4b86c96 commit 5d5c11e
Show file tree
Hide file tree
Showing 69 changed files with 1,974 additions and 424 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
<PackageReference Include="JetBrains.ReSharper.SDK.Tests" Version="$(SdkVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Moq">
<Version>4.10.1</Version>
<Version>4.13.1</Version>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="3.14.0" />
<PackageReference Include="Moq.AutoMock" Version="1.2.0.120" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
</ItemGroup>
<ItemGroup>
<Compile Remove="data\**\*" />
<Content Include="data\**\*" />
</ItemGroup>
<ItemGroup>
<Folder Include="data\AutoMockerSuspiciousCallback" />
<Folder Include="data\MockVariableNameCompletion\" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using JetBrains.ReSharper.FeaturesTestFramework.Daemon;
using JetBrains.ReSharper.TestFramework;
using NUnit.Framework;

namespace Abc.MoqComplete.Tests.CodeAnalysis
{
[TestNetCore21("Moq.AutoMock/1.2.0.120")]
public class AutoMockerSuspiciousCallbackAnalyzerTests : CSharpHighlightingTestBase
{
protected override string RelativeTestDataPath => "AutoMockerSuspiciousCallback";

[TestCase("typeMismatch_return_before")]
[TestCase("typeCountMismatch_return_before")]
[TestCase("typeMismatch_return_after")]
[TestCase("typeCountMismatch_return_after")]
[TestCase("typeMismatch_generic")]
public void should_detect_suspicious_callback(string testSrc) => DoOneTest(testSrc);

[TestCase("no_types")]
[TestCase("generic_types")]
[TestCase("implementation_types")]
public void should_not_detect_suspicious_callback(string testSrc) => DoOneTest(testSrc);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using JetBrains.ReSharper.FeaturesTestFramework.Completion;
using JetBrains.ReSharper.TestFramework;
using NUnit.Framework;

namespace Abc.MoqComplete.Tests.Completion
{
[TestNetCore21("Moq.AutoMock/1.2.0.120")]
public class AutoMockerCallbackMethodProviderTests: CodeCompletionTestBase
{
protected override CodeCompletionTestType TestType => CodeCompletionTestType.Action;
protected override string RelativeTestDataPath => "AutoMockerCallbackCompletion";

[TestCase("callbackCompletion")]
[TestCase("callbackCompletion_afterReturn")]
[TestCase("callbackCompletion_generic")]
public void should_fill_with_callback(string testSrc) => DoOneTest(testSrc);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using JetBrains.ReSharper.FeaturesTestFramework.Completion;
using JetBrains.ReSharper.TestFramework;
using NUnit.Framework;

namespace Abc.MoqComplete.Tests.Completion
{
[TestNetCore21("Moq.AutoMock/1.2.0.120")]
public class AutoMockerItIsAnyProviderActionTests : CodeCompletionTestBase
{
protected override CodeCompletionTestType TestType => CodeCompletionTestType.Action;

protected override string RelativeTestDataPath => "AutoMockerItIsAnyCompletion";

[TestCase("itIsAnyCompletionFull")]
[TestCase("itIsAnyCompletionParam")]
[TestCase("itIsAnyCompletionGeneric")]
[TestCase("itIsAnyVerifyCompletionFull")]
public void should_fill_with_it_isAny(string testSrc)
{
DoOneTest(testSrc);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using JetBrains.ReSharper.FeaturesTestFramework.Completion;
using JetBrains.ReSharper.TestFramework;
using NUnit.Framework;

namespace Abc.MoqComplete.Tests.Completion
{
[TestNetCore21("Moq.AutoMock/1.2.0.120")]
public class AutoMockerItIsAnyProviderListTests : CodeCompletionTestBase
{
protected override CodeCompletionTestType TestType => CodeCompletionTestType.List;

protected override string RelativeTestDataPath => "AutoMockerItIsAnyCompletion";

[TestCase("itIsAnyCompletionList")]
public void should_fill_with_overloads(string src)
{
DoOneTest(src);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using JetBrains.ReSharper.FeaturesTestFramework.Completion;
using JetBrains.ReSharper.TestFramework;
using NUnit.Framework;

namespace Abc.MoqComplete.Tests.Completion
{
[TestNetCore21("Moq.AutoMock/1.2.0.120")]
public class AutoMockerReturnsMethodProviderTests : CodeCompletionTestBase
{
protected override CodeCompletionTestType TestType => CodeCompletionTestType.Action;

protected override string RelativeTestDataPath => "AutoMockerReturnsCompletion";

[TestCase("returnsCompletion")]
[TestCase("returnsCompletion_afterCallback")]
[TestCase("returnsCompletion_generic")]
public void should_fill_with_callback(string testSrc)
{
DoOneTest(testSrc);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Abc.MoqComplete.CompletionProvider;
using JetBrains.ReSharper.FeaturesTestFramework.Completion;
using JetBrains.ReSharper.FeaturesTestFramework.Completion;
using JetBrains.ReSharper.TestFramework;
using NUnit.Framework;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// ${COMPLETE_ITEM:Callback<int,string,bool>((i,toto,ok) => {\})}
using Moq;
using Moq.AutoMock;
using NUnit.Framework;

namespace ConsoleApp1.Tests
{
public interface ITestInterface
{
void BuildSomething(int i, string toto, bool ok);
}

[TestFixture]
public class Test1
{
[Test]
public void METHOD()
{
var _mocker = new AutoMocker();
_mocker.Setup<ITestInterface>(x => x.BuildSomething(It.IsAny<int>(),It.IsAny<string>(), It.IsAny<bool>()))
.c{caret}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// ${COMPLETE_ITEM:Callback<int,string,bool>((i,toto,ok) => {\})}
using Moq;
using Moq.AutoMock;
using NUnit.Framework;

namespace ConsoleApp1.Tests
{
public interface ITestInterface
{
void BuildSomething(int i, string toto, bool ok);
}

[TestFixture]
public class Test1
{
[Test]
public void METHOD()
{
var _mocker = new AutoMocker();
_mocker.Setup<ITestInterface>(x => x.BuildSomething(It.IsAny<int>(),It.IsAny<string>(), It.IsAny<bool>()))
.Callback<int,string,bool>((i,toto,ok) => {{caret}})
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ${COMPLETE_ITEM:Callback<int,string,bool>((i,toto,ok) => {\})}
using Moq;
using Moq.AutoMock;
using NUnit.Framework;

namespace ConsoleApp1.Tests
{
public interface ITestInterface
{
int BuildSomething(int i, string toto, bool ok);
}

[TestFixture]
public class Test1
{
[Test]
public void METHOD()
{
var _mocker = new AutoMocker();
_mocker.Setup<ITestInterface>(x => x.BuildSomething(It.IsAny<int>(),It.IsAny<string>(), It.IsAny<bool>()))
.Returns(0)
.c{caret}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ${COMPLETE_ITEM:Callback<int,string,bool>((i,toto,ok) => {\})}
using Moq;
using Moq.AutoMock;
using NUnit.Framework;

namespace ConsoleApp1.Tests
{
public interface ITestInterface
{
int BuildSomething(int i, string toto, bool ok);
}

[TestFixture]
public class Test1
{
[Test]
public void METHOD()
{
var _mocker = new AutoMocker();
_mocker.Setup<ITestInterface>(x => x.BuildSomething(It.IsAny<int>(),It.IsAny<string>(), It.IsAny<bool>()))
.Returns(0)
.Callback<int,string,bool>((i,toto,ok) => {{caret}})
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// ${COMPLETE_ITEM:Callback<ITest2,double,string>((test,test2,test3) => {\})}
using NUnit.Framework;
using Moq;
using Moq.AutoMock;

namespace ConsoleApp1.Tests
{
public interface ITest<T, U>
{
int Coco(ITest2 test, T test2, U test3);

}
public interface ITest2 : ITest<double, string>
{

}

[TestFixture]
public class TestClass
{

[Test]
public void METHOD()
{
var _mocker = new AutoMocker();
_mocker.Setup<ITest2>(x=>x.Coco(It.IsAny<ITest2>(), It.IsAny<double>(), It.IsAny<string>()))
.{caret}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// ${COMPLETE_ITEM:Callback<ITest2,double,string>((test,test2,test3) => {\})}
using NUnit.Framework;
using Moq;
using Moq.AutoMock;

namespace ConsoleApp1.Tests
{
public interface ITest<T, U>
{
int Coco(ITest2 test, T test2, U test3);

}
public interface ITest2 : ITest<double, string>
{

}

[TestFixture]
public class TestClass
{

[Test]
public void METHOD()
{
var _mocker = new AutoMocker();
_mocker.Setup<ITest2>(x=>x.Coco(It.IsAny<ITest2>(), It.IsAny<double>(), It.IsAny<string>()))
.Callback<ITest2,double,string>((test,test2,test3) => {{caret}})
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// ${COMPLETE_ITEM:It.IsAny<int>(), It.IsAny<string>(), It.IsAny<bool>()}
using Moq;
using Moq.AutoMock;
using NUnit.Framework;

namespace ConsoleApp1.Tests
{
public interface ITestInterface
{
void BuildSomething(int i, string toto, bool ok);
}

[TestFixture]
public class Test1
{
[Test]
public void METHOD()
{
var _mocker = new AutoMocker();
_mocker.Setup<ITestInterface>(x => x.BuildSomething(It{caret}))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// ${COMPLETE_ITEM:It.IsAny<int>(), It.IsAny<string>(), It.IsAny<bool>()}
using Moq;
using Moq.AutoMock;
using NUnit.Framework;

namespace ConsoleApp1.Tests
{
public interface ITestInterface
{
void BuildSomething(int i, string toto, bool ok);
}

[TestFixture]
public class Test1
{
[Test]
public void METHOD()
{
var _mocker = new AutoMocker();
_mocker.Setup<ITestInterface>(x => x.BuildSomething(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<bool>())){caret}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ${COMPLETE_ITEM:It.IsAny<ITest2>(), It.IsAny<double>(), It.IsAny<string>()}
using NUnit.Framework;
using System;
using Moq;
using Moq.AutoMock;

namespace ConsoleApp1.Tests
{
public class Test1
{
public interface ITest<T>
{
void Coco(ITest2 test, T test2, string test3);

}
public interface ITest2 : ITest<double>
{

}
}

[TestFixture]
public class TestClass
{

[Test]
public void METHOD()
{
var _mocker = new AutoMocker();
_mocker.Setup<Test1.ITest2>(x=>x.Coco(It{caret}));
}
}
}
Loading

0 comments on commit 5d5c11e

Please sign in to comment.