Skip to content

Commit

Permalink
Fix Double completion for It.IsAny when using verify method
Browse files Browse the repository at this point in the history
  • Loading branch information
lconstan committed Jun 9, 2020
1 parent b33d80c commit f57ce7b
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class ItIsAnyProviderListTests : CodeCompletionTestBase
protected override string RelativeTestDataPath => "ItIsAnyCompletion";

[TestCase("itIsAnyCompletionList")]
[TestCase("itIsAnyVerifyCompletionList")]
public void should_fill_with_overloads(string src) => DoOneTest(src);
}
}
Expand Down
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 NUnit.Framework;

namespace ConsoleApp1.Tests
{
public interface ITestInterface
{
void Publish(long sequence);
void Publish(long lo, long hi);
}

[TestFixture]
public class Test1
{
[Test]
public void METHOD()
{
Mock<ITestInterface> temp = new Mock<ITestInterface>();
temp.Verify(x => x.Publish(it{caret}))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# 80 ITEMS #

It.IsAny<long>()
It.IsAny<long>(), It.IsAny<long>()
ITestInterface
+ It
---- FULL EVALUATION ----
ClassInterfaceType (in System.Runtime.InteropServices)
ComInterfaceType (in System.Runtime.InteropServices)
CompositionInvocationTypeGenerator (in Castle.DynamicProxy.Generators)
IChangeProxyTarget (in Castle.DynamicProxy)
IChangeTracking (in System.ComponentModel)
IConstructedTypeProvider<> (in System.Reflection.Metadata)
ICryptoTransform (in System.Security.Cryptography)
ICustomAttributeTypeProvider<> (in System.Reflection.Metadata)
ICustomTypeDescriptor (in System.ComponentModel)
IDbTransaction (in System.Data)
IDesignerHostTransactionState (in System.ComponentModel.Design)
IDtcTransaction (in System.Transactions)
IProxyTargetAccessor (in Castle.DynamicProxy)
IRaiseItemChangedEvents (in System.ComponentModel)
IReflectableType (in System.Reflection)
IReturnsThrows<> (in Moq.Language.Flow)
IReturnsThrowsGetter<> (in Moq.Language.Flow)
IRevertibleChangeTracking (in System.ComponentModel)
IRunningObjectTable (in System.Runtime.InteropServices.ComTypes)
ISZArrayTypeProvider<> (in System.Reflection.Metadata)
ISignatureTypeProvider<> (in System.Reflection.Metadata)
ISimpleTransactionSuperior (in System.Transactions)
ISimpleTypeProvider<> (in System.Reflection.Metadata)
ITableMapping (in System.Data)
ITableMappingCollection (in System.Data)
ITargetBlock<> (in System.Threading.Tasks.Dataflow)
IThrows (in Moq.Language)
IThrowsResult (in Moq.Language.Flow)
ITransactionPromoter (in System.Transactions)
ITreeDesigner (in System.ComponentModel.Design)
ITuple (in System.Runtime.CompilerServices)
ITypeComp (in System.Runtime.InteropServices.ComTypes)
ITypeContributor (in Castle.DynamicProxy.Contributors)
ITypeDescriptorContext (in System.ComponentModel)
ITypeDescriptorFilterService (in System.ComponentModel.Design)
ITypeDiscoveryService (in System.ComponentModel.Design)
ITypeInfo (in System.Runtime.InteropServices.ComTypes)
ITypeInfo2 (in System.Runtime.InteropServices.ComTypes)
ITypeLib (in System.Runtime.InteropServices.ComTypes)
ITypeLib2 (in System.Runtime.InteropServices.ComTypes)
ITypeResolutionService (in System.ComponentModel.Design)
ITypedList (in System.ComponentModel)
IValueTaskSource (in System.Threading.Tasks.Sources)
IValueTaskSource<> (in System.Threading.Tasks.Sources)
IVirtualTarget<> (in Castle.Components.DictionaryAdapter)
IXmlTextParser (in System.Xml.Serialization)
IXmlTextReaderInitializer (in System.Xml)
IXmlTextWriterInitializer (in System.Xml)
ImportedFromTypeLibAttribute (in System.Runtime.InteropServices)
IndentedTextWriter (in System.CodeDom.Compiler)
InheritanceInvocationTypeGenerator (in Castle.DynamicProxy.Generators)
InstallerTypeAttribute (in System.ComponentModel)
InterfaceProxyTargetContributor (in Castle.DynamicProxy.Contributors)
InterfaceProxyWithOptionalTargetContributor (in Castle.DynamicProxy.Contributors)
InterfaceProxyWithTargetGenerator (in Castle.DynamicProxy.Generators)
InterfaceProxyWithTargetInterfaceGenerator (in Castle.DynamicProxy.Generators)
InterfaceProxyWithTargetInterfaceTargetContributor (in Castle.DynamicProxy.Contributors)
InterfaceProxyWithoutTargetContributor (in Castle.DynamicProxy.Contributors)
InterfaceProxyWithoutTargetGenerator (in Castle.DynamicProxy.Generators)
InterfaceTypeAttribute (in System.Runtime.InteropServices)
InternalsVisibleToAttribute (in System.Runtime.CompilerServices)
InvalidOleVariantTypeException (in System.Runtime.InteropServices)
InvalidTimeZoneException (in System)
InvocationTypeGenerator (in Castle.DynamicProxy.Generators)
ItExpr (in Moq.Protected)
IteratorStateMachineAttribute (in System.Runtime.CompilerServices)
NetworkInterfaceType (in System.Net.NetworkInformation)
RangeItemHeaderValue (in System.Net.Http.Headers)
RowNotInTableException (in System.Data)
ToolboxItemAttribute (in System.ComponentModel)
ToolboxItemFilterAttribute (in System.ComponentModel)
ToolboxItemFilterType (in System.ComponentModel)
XPathItem (in System.Xml.XPath)
XPathNodeIterator (in System.Xml.XPath)
XmlArrayItemAttribute (in System.Xml.Serialization)
XmlArrayItemAttributes (in System.Xml.Serialization)
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ protected override bool IsSetupMethod(IMoqMethodIdentifier identifier, IInvocati
{
return identifier.IsAutoMockerSetupMethod(methodInvocation);
}
}

protected override bool IsVerifyMethod(IMoqMethodIdentifier identifier, IInvocationExpression methodInvocation)
{
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Abc.MoqComplete.CompletionProvider.ItIsAny
public abstract class BaseItIsAnyParameterProvider : CSharpItemsProviderBase<CSharpCodeCompletionContext>
{
protected abstract bool IsSetupMethod(IMoqMethodIdentifier identifier, IInvocationExpression methodInvocation);
protected abstract bool IsVerifyMethod(IMoqMethodIdentifier identifier, IInvocationExpression methodInvocation);

protected override bool IsAvailable(CSharpCodeCompletionContext context)
{
Expand Down Expand Up @@ -48,7 +49,7 @@ protected override bool AddLookupItems(CSharpCodeCompletionContext context, IIte

var methodIdentifier = context.BasicContext.Solution.GetComponent<IMoqMethodIdentifier>();
var isSetup = IsSetupMethod(methodIdentifier, methodInvocation);
var isVerify = methodIdentifier.IsMoqVerifyMethod(methodInvocation);
var isVerify = IsVerifyMethod(methodIdentifier, methodInvocation);

if (!isSetup && !isVerify)
{
Expand Down Expand Up @@ -91,7 +92,7 @@ protected override bool AddLookupItems(CSharpCodeCompletionContext context, IIte
AddLookup(context, collector, proposedCompletion, isSetup ? 2 : 1);
}

return true;
return false;
}

private static string GetItIsAny(IParameter x, ISubstitution substitution)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ protected override bool IsSetupMethod(IMoqMethodIdentifier identifier, IInvocati
{
return identifier.IsMoqSetupMethod(methodInvocation);
}
}

protected override bool IsVerifyMethod(IMoqMethodIdentifier identifier, IInvocationExpression methodInvocation)
{
return identifier.IsMoqVerifyMethod(methodInvocation);;
}
}
}
2 changes: 1 addition & 1 deletion Abc.MoqComplete/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</PropertyGroup>

<PropertyGroup>
<Version>1.3.3</Version>
<Version>1.3.4</Version>
</PropertyGroup>

</Project>

0 comments on commit f57ce7b

Please sign in to comment.