C#
MoqMoqNamespaceSendFeedbackRootnamespaceofMoq(pronounced"Mock-you"orjust"Mock"),theonlymockinglibraryfor.NETandSilverlightdevelopedfromscratchtotakefulladvantageof.NET3.5(i.e.Linqexpressiontrees)andC#3.0features(i.e.lambdaexpressions)thatmakeitthemostproductive,simpleandrefactoring-friendlymockinglibraryavailable.
Seetheonlinequickstartsformoreexamplesthanthoseavailableinthiscodedocumentation.
TheMock<T>classisthecoreofthelibrary,soit'sagoodplacetostart.
YoucanalsoreadblogentriesfromaroundtheworldaboutMoq.
Classes Class Description
It
Allowsthespecificationofamatchingconditionforanargumentinamethodinvocation,ratherthanaspecificargumentvalue."It"referstotheargumentbeingmatched.
Mock
Baseclassformocksandstatichelperclasswithmethodsthatapplytomockedobjects,suchasGet<(Of<<'(T>)>>)(T)toretrieveaMock<(Of<(<'T>)>)>fromanobjectinstance.
Mock<(Of<(<'T>)>)> ProvidesamockimplementationofT.
MockException Exceptionthrownbymockswhensetupsarenotmatched,themockisnotproperlysetup,etc.
MockExtensions Providesadditionalmethodsonmocks.
MockFactory
Obsolete.Utilityfactoryclasstousetoconstructmultiplemockswhenconsistentverificationisdesiredforallofthem.
MockRepositoryUtilityrepositoryclasstousetoconstructmultiplemockswhenconsistentverificationisdesiredforallofthem.
MocksAllowsqueryingtheuniverseofmocksforthosethatbehaveaccordingtotheLINQqueryspecification.
MockSequence Helperclasstosetupafulltracebetweenmanymocks
MockSequenceHelper defineniceapi
SequenceExtensions Helperforsequencingreturnvaluesinthesamemethod.
Structures Structure Description
Times Definesthenumberofinvocationsallowedbyamockedmethod.
Enumerations Enumeration Description
DefaultValue Determinesthewaydefaultvaluesaregeneratedcalculatedforloosemocks.
MockBehavior Optionstocustomizethebehaviorofthemock.
RangeKindofrangetouseinafilterspecifiedthroughIsInRange<(Of<<'(TValue>)>>)(TValue,TValue,Range).
C#
MoqDefaultValueEnumerationSeeAlsoSendFeedbackDeterminesthewaydefaultvaluesaregeneratedcalculatedforloosemocks.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicenumDefaultValue
MembersMembername DescriptionEmptyMock
C#
MoqItClassMembersSeeAlsoSendFeedbackAllowsthespecificationofamatchingconditionforanargumentinamethodinvocation,ratherthanaspecificargumentvalue."It"referstotheargumentbeingmatched.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticclassIt
RemarksThisclassallowsthesetuptomatchamethodinvocationwithanarbitraryvalue,withavalueinaspecifiedrange,orevenonethatmatchesagivenpredicate.
InheritanceHierarchySystem..::..ObjectMoq..::..It
C#IncludeProtectedMembersIncludeInheritedMembers
MoqItMembersItClassMethodsSeeAlsoSendFeedback
TheIttypeexposesthefollowingmembers.
Methods Name Description
Is<(Of<<'(TValue>)>>)IsAny<(Of<<'(TValue>)>>) MatchesanyvalueofthegivenTValuetype.
IsInRange<(Of<<'(TValue>)>>) Matchesanyvaluethatisintherangespecified.
IsRegex(String) Matchesastringargumentifitmatchesthegivenregularexpressionpattern.
IsRegex(String,RegexOptions)
Matchesastringargumentifitmatchesthegivenregularexpressionpattern.
C#IncludeProtectedMembersIncludeInheritedMembers
MoqItMethodsItClassSeeAlsoSendFeedback
TheIttypeexposesthefollowingmembers.
Methods Name Description
Is<(Of<<'(TValue>)>>)IsAny<(Of<<'(TValue>)>>) MatchesanyvalueofthegivenTValuetype.
IsInRange<(Of<<'(TValue>)>>) Matchesanyvaluethatisintherangespecified.
IsRegex(String) Matchesastringargumentifitmatchesthegivenregularexpressionpattern.
IsRegex(String,RegexOptions)
Matchesastringargumentifitmatchesthegivenregularexpressionpattern.
C#
MoqIt..::..Is<(Of<(<'TValue>)>)>MethodItClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.It.Is``1(System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticTValueIs<TValue>(
Expression<Func>match
)
Parameters
matchType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersTValue
C#
MoqIt..::..IsAny<(Of<(<'TValue>)>)>MethodItClassExampleSeeAlsoSendFeedbackMatchesanyvalueofthegivenTValuetype.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticTValueIsAny<TValue>()
TypeParametersTValue
Typeofthevalue.
RemarksTypicallyusedwhentheactualargumentvalueforamethodcallisnotrelevant.
Copy
ExamplesC#
//ThrowsanexceptionforacalltoRemovewithanystringvalue.
mock.Setup(x=>x.Remove(It.IsAny<string>())).Throws(newInvalidOperationException());
C#
MoqIt..::..IsInRange<(Of<(<'TValue>)>)>MethodItClassExampleSeeAlsoSendFeedbackMatchesanyvaluethatisintherangespecified.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticTValueIsInRange<TValue>(
TValuefrom,
TValueto,
RangerangeKind
)
whereTValue:IComparable
Parameters
fromType:TValueThelowerboundoftherange.
toType:TValueTheupperboundoftherange.
rangeKindType:Moq..::..RangeThekindofrange.SeeRange.
TypeParametersTValue
Typeoftheargumenttocheck.
Copy
ExamplesThefollowingexampleshowshowtoexpectamethodcallwithanintegerargumentwithinthe0..100range.
C#
mock.Setup(x=>x.HasInventory(
It.IsAny<string>(),
It.IsInRange(0,100,Range.Inclusive)))
.Returns(false);
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIt..::..IsRegexMethodItClassSeeAlsoSendFeedback
OverloadList Name Description
IsRegex(String) Matchesastringargumentifitmatchesthegivenregularexpressionpattern.
IsRegex(String,RegexOptions)
Matchesastringargumentifitmatchesthegivenregularexpressionpattern.
C#
MoqIt..::..IsRegexMethod(String)ItClassExampleSeeAlsoSendFeedbackMatchesastringargumentifitmatchesthegivenregularexpressionpattern.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticstringIsRegex(
stringregex
)
Parameters
regexType:System..::..StringThepatterntousetomatchthestringargumentvalue.
Copy
ExamplesThefollowingexampleshowshowtoexpectacalltoamethodwherethestringargumentmatchesthegivenregularexpression:
C#
mock.Setup(x=>x.Check(It.IsRegex("[a-z]+"))).Returns(1);
SeeAlsoItClassIsRegexOverloadMoqNamespace
C#
MoqIt..::..IsRegexMethod(String,RegexOptions)ItClassExampleSeeAlsoSendFeedbackMatchesastringargumentifitmatchesthegivenregularexpressionpattern.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticstringIsRegex(
stringregex,
RegexOptionsoptions
)
Parameters
regexType:System..::..StringThepatterntousetomatchthestringargumentvalue.
optionsType:System.Text.RegularExpressions..::..RegexOptionsTheoptionsusedtointerpretthepattern.
Copy
ExamplesThefollowingexampleshowshowtoexpectacalltoamethodwherethestringargumentmatchesthegivenregularexpression,inacaseinsensitiveway:
C#
mock.Setup(x=>x.Check(It.IsRegex("[a-z]+",RegexOptions.IgnoreCase))).Returns(
SeeAlsoItClassIsRegexOverloadMoqNamespace
C#
MoqMockClassMembersSeeAlsoSendFeedbackBaseclassformocksandstatichelperclasswithmethodsthatapplytomockedobjects,suchasGet<(Of<<'(T>)>>)(T)toretrieveaMock<(Of<(<'T>)>)>fromanobjectinstance.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicabstractclassMock:IHideObjectMembers
InheritanceHierarchySystem..::..ObjectMoq..::..MockMoq..::..Mock<(Of<(<'T>)>)>
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockMembersMockClassConstructorsMethodsPropertiesSeeAlsoSendFeedback
TheMocktypeexposesthefollowingmembers.
Constructors Name Description
Mock InitializesanewinstanceoftheMockclass.
Methods Name Description
As<(Of<<'(TInterface>)>>)Addsaninterfaceimplementationtothemock,allowingsetupstobespecifiedforit.
Get<(Of<<'(T>)>>) Retrievesthemockobjectforthegivenobjectinstance.
Of<(Of<<'(T>)>>)()()()() Createsanmockobjectoftheindicatedtype.
Of<(Of<<'(T>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))OnGetObject Returnsthemockedobjectvalue.SetReturnsDefault<(Of<<'(TReturn>)>>)
Verify Verifiesthatallverifiableexpectationshavebeenmet.
VerifyAllVerifiesallexpectationsregardlessofwhethertheyhavebeenflaggedasverifiable.
Properties Name Description
Behavior Behaviorofthemock,accordingtothevaluesetintheconstructor.
CallBaseWhetherthebasemembervirtualimplementationwillbecalledformockedclassesifnosetupismatched.DefaultstofalseFalsefalsefalse(FalseinVisualBasic).
DefaultValue Specifiesthebehaviortousewhenreturningdefaultvaluesforunexpectedinvocationsonloosemocks.Object Getsthemockedobjectinstance.
C#
MoqMockConstructorMockClassSeeAlsoSendFeedbackInitializesanewinstanceoftheMockclass.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
protectedMock()
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockMethodsMockClassSeeAlsoSendFeedback
TheMocktypeexposesthefollowingmembers.
Methods Name Description
As<(Of<<'(TInterface>)>>)Addsaninterfaceimplementationtothemock,allowingsetupstobespecifiedforit.
Get<(Of<<'(T>)>>) Retrievesthemockobjectforthegivenobjectinstance.
Of<(Of<<'(T>)>>)()()()() Createsanmockobjectoftheindicatedtype.
Of<(Of<<'(T>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))OnGetObject Returnsthemockedobjectvalue.SetReturnsDefault<(Of<<'(TReturn>)>>)
Verify Verifiesthatallverifiableexpectationshavebeenmet.
VerifyAllVerifiesallexpectationsregardlessofwhethertheyhavebeenflaggedasverifiable.
C#
MoqMock..::..As<(Of<(<'TInterface>)>)>MethodMockClassExampleSeeAlsoSendFeedbackAddsaninterfaceimplementationtothemock,allowingsetupstobespecifiedforit.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvirtualMock<TInterface>As<TInterface>()
whereTInterface:class
TypeParametersTInterface
Typeofinterfacetocastthemockto.
RemarksThismethodcanonlybecalledbeforethefirstuseofthemockObjectproperty,atwhichpointtheruntimetypehasalreadybeengeneratedandnomoreinterfacescanbeaddedtoit.
Also,TInterfacemustbeaninterfaceandnotaclass,whichmustbespecifiedwhencreatingthemockinstead.
Copy
ExamplesThefollowingexamplecreatesamockforthemaininterfaceandlateraddsIDisposabletoittoverifyit'scalledbytheconsumercode:
C#
varmock=newMock<IProcessor>();
mock.Setup(x=>x.Execute("ping"));
//addIDisposableinterface
vardisposable=mock.As<IDisposable>();
disposable.Setup(d=>d.Dispose()).Verifiable();
ExceptionsException Condition
System..::..InvalidOperationExceptionThemocktypehasalreadybeengeneratedbyaccessingtheObjectproperty.
System..::..ArgumentException TheTInterfacespecifiedisnotaninterface.
C#
MoqMock..::..Get<(Of<(<'T>)>)>MethodMockClassExampleSeeAlsoSendFeedbackRetrievesthemockobjectforthegivenobjectinstance.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticMock<T>Get<T>(
Tmocked
)
whereT:class
Parameters
mockedType:TTheinstanceofthemockedobject.
TypeParametersT
Typeofthemocktoretrieve.Canbeomittedasit'sinferredfromtheobjectinstancepassedinasthemockedinstance.
ReturnValue
Themockassociatedwiththemockedobject.
Copy
ExamplesThefollowingexampleshowshowtoaddanewsetuptoanobjectinstancewhichisnottheoriginalMock<(Of<(<'T>)>)>butrathertheobjectassociatedwithit:
C#
//Typedinstance,notthemock,isretrievedfromsometestAPI.
HttpContextBasecontext=GetMockContext();
//context.Requestisthetypedobjectfromthe"real"API
//soinordertoaddasetuptoit,weneedtoget
//themockthat"owns"it
Mock<HttpRequestBase>request=Mock.Get(context.Request);
mock.Setup(req=>req.AppRelativeCurrentExecutionFilePath)
.Returns(tempUrl);
ExceptionsException Condition
System..::..ArgumentException ThereceivedmockedinstancewasnotcreatedbyMoq.
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMock..::..OfMethodMockClassSeeAlsoSendFeedback
OverloadList Name Description
Of<(Of<<'(T>)>>)()()()() Createsanmockobjectoftheindicatedtype.
Of<(Of<<'(T>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
SeeAlsoMockClassMockMembersMoqNamespace
C#
MoqMock..::..Of<(Of<(<'T>)>)>MethodMockClassSeeAlsoSendFeedbackCreatesanmockobjectoftheindicatedtype.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticTOf<T>()
whereT:class
TypeParametersT
Thetypeofthemockedobject.
ReturnValue
Themockedobjectcreated.
SeeAlsoMockClassOfOverloadMoqNamespace
C#
MoqMock..::..Of<(Of<(<'T>)>)>Method(Expression<(Of<(<'Func>)>)>)MockClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Mock.Of``1(System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticTOf<T>(
Expression<Func>predicate
)
whereT:class
Parameters
predicateType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersT
SeeAlsoMockClassOfOverloadMoqNamespace
C#
MoqMock..::..OnGetObjectMethodMockClassSeeAlsoSendFeedbackReturnsthemockedobjectvalue.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
C#
MoqMock..::..SetReturnsDefault<(Of<(<'TReturn>)>)>MethodMockClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Mock.SetReturnsDefault``1(``0)"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidSetReturnsDefault<TReturn>(
TReturnvalue
)
Parameters
valueType:TReturn
TypeParametersTReturn
C#
MoqMock..::..VerifyMethodMockClassExampleSeeAlsoSendFeedbackVerifiesthatallverifiableexpectationshavebeenmet.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerify()
Copy
ExamplesThisexamplesetsupanexpectationandmarksitasverifiable.Afterthemockisused,aVerify()callisissuedonthemocktoensurethemethodinthesetupwasinvoked:
C#
varmock=newMock<IWarehouse>();
this.Setup(x=>x.HasInventory(TALISKER,50)).Verifiable().Returns(true
...
//othertestcode
...
//Willthrowifthetestcodehasdidn'tcallHasInventory.
this.Verify();
ExceptionsException Condition
Moq..::..MockException Notallverifiableexpectationsweremet.
C#
MoqMock..::..VerifyAllMethodMockClassExampleSeeAlsoSendFeedbackVerifiesallexpectationsregardlessofwhethertheyhavebeenflaggedasverifiable.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerifyAll()
Copy
ExamplesThisexamplesetsupanexpectationwithoutmarkingitasverifiable.Afterthemockisused,aVerifyAll()()()()callisissuedonthemocktoensurethatallexpectationsaremet:
C#
varmock=newMock<IWarehouse>();
this.Setup(x=>x.HasInventory(TALISKER,50)).Returns(true);
...
//othertestcode
...
//Willthrowifthetestcodehasdidn'tcallHasInventory,even
//thatexpectationwasnotmarkedasverifiable.
this.VerifyAll();
ExceptionsException Condition
Moq..::..MockException Atleastoneexpectationwasnotmet.
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockPropertiesMockClassSeeAlsoSendFeedback
TheMocktypeexposesthefollowingmembers.
Properties Name Description
Behavior Behaviorofthemock,accordingtothevaluesetintheconstructor.
CallBaseWhetherthebasemembervirtualimplementationwillbecalledformockedclassesifnosetupismatched.DefaultstofalseFalsefalsefalse(FalseinVisualBasic).
DefaultValue Specifiesthebehaviortousewhenreturningdefaultvaluesforunexpectedinvocationsonloosemocks.Object Getsthemockedobjectinstance.
C#
MoqMock..::..BehaviorPropertyMockClassSeeAlsoSendFeedbackBehaviorofthemock,accordingtothevaluesetintheconstructor.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvirtualMockBehaviorBehavior{get;internalset;}
C#
MoqMock..::..CallBasePropertyMockClassSeeAlsoSendFeedbackWhetherthebasemembervirtualimplementationwillbecalledformockedclassesifnosetupismatched.DefaultstofalseFalsefalsefalse(FalseinVisualBasic).
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
C#
MoqMock..::..DefaultValuePropertyMockClassSeeAlsoSendFeedbackSpecifiesthebehaviortousewhenreturningdefaultvaluesforunexpectedinvocationsonloosemocks.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvirtualDefaultValueDefaultValue{get;set;}
C#
MoqMock..::..ObjectPropertyMockClassSeeAlsoSendFeedbackGetsthemockedobjectinstance.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
C#
MoqMock<(Of<(<'T>)>)>ClassMembersExampleSeeAlsoSendFeedbackProvidesamockimplementationofT.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicclassMock<T>:Mock
whereT:class
TypeParametersT
Typetomock,whichcanbeaninterfaceoraclass.
RemarksAnyinterfacetypecanbeusedformocking,butforclasses,onlyabstractandvirtualmemberscanbemocked.
ThebehaviorofthemockwithregardstothesetupsandtheactualcallsisdeterminedbytheoptionalMockBehaviorthatcanbepassedtotheMock<(Of<(<'T>)>)>(MockBehavior)constructor.
Copy
Copy
ExamplesThefollowingexampleshowsestablishingsetupswithspecificvaluesformethodinvocations:
C#
//Arrange
varorder=newOrder(TALISKER,50);
varmock=newMock<IWarehouse>();
mock.Setup(x=>x.HasInventory(TALISKER,50)).Returns(true);
//Act
order.Fill(mock.Object);
//Assert
Assert.True(order.IsFilled);
ThefollowingexampleshowshowtousetheItclasstospecifyconditionsforargumentsinsteadofspecificvalues:
C#
//Arrange
varorder=newOrder(TALISKER,50);
varmock=newMock<IWarehouse>();
//showshowtoexpectavaluewithinarange
mock.Setup(x=>x.HasInventory(
It.IsAny<string>(),
It.IsInRange(0,100,Range.Inclusive)))
.Returns(false);
//showshowtothrowforunexpectedcalls.
mock.Setup(x=>x.Remove(
It.IsAny<string>(),
It.IsAny<int>()))
.Throws(newInvalidOperationException());
//Act
order.Fill(mock.Object);
//Assert
Assert.False(order.IsFilled);
InheritanceHierarchySystem..::..ObjectMoq..::..MockMoq..::..Mock<(Of<(<'T>)>)>
SeeAlsoMock<(Of<(<'T>)>)>MembersMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMock<(Of<(<'T>)>)>MembersMock<(Of<(<'T>)>)>ClassConstructorsMethodsPropertiesSeeAlsoSendFeedback
TheMock<(Of<(<'T>)>)>typeexposesthefollowingmembers.
Constructors Name Description
Mock<(Of<(<'T>)>)>()()()() Initializesaninstanceofthemockwithdefaultbehavior.
Mock<(Of<(<'T>)>)>(array<Object>[]()[][])
Initializesaninstanceofthemockwithdefaultbehaviorandwiththegivenconstructorargumentsfortheclass.(OnlyvalidwhenTisaclass)
Mock<(Of<(<'T>)>)>(MockBehavior)
Initializesaninstanceofthemockwiththespecifiedbehavior.
Mock<(Of<(<'T>)>)>(MockBehavior,array<Object>[]()[][])
Initializesaninstanceofthemockwithaspecificbehaviorwiththegivenconstructorargumentsfortheclass.
Methods Name Description
As<(Of<<'(TInterface>)>>)
Addsaninterfaceimplementationtothemock,allowingsetupstobespecifiedforit.(InheritedfromMock.)
OnGetObjectReturnsthemockedobjectvalue.(OverridesMock..::..OnGetObject()()()().)
Raise(Action<(Of<<'(T>)>>),EventArgs)
RaisestheeventreferencedineventExpressionusingthegivenargsargument.
Raise(Action<(Of<<'(T>)>>),array<Object>[]()[][])
RaisestheeventreferencedineventExpressionusingthegivenargsargumentforanon-EventHandlertypedevent.
SetReturnsDefault<(Of<<'(TReturn>)>>) (InheritedfromMock.)
Setup(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>))
Specifiesasetuponthemockedtypeforacalltotoavoidmethod.
Setup<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
SetupAllProperties
Specifiesthattheallpropertiesonthemockshouldhave"propertybehavior",meaningthatsettingitsvaluewillcauseittobesavedandlaterreturnedwhenthepropertyisrequested.(thisisalsoknownas"stubbing").ThedefaultvalueforeachpropertywillbetheonegeneratedasspecifiedbytheDefaultValuepropertyforthemock.
SetupGet<(Of<<'(TProperty>)>>)SetupProperty<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))SetupProperty<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)
SetupSet(Action<(Of<<'(T>)>>))Specifiesasetuponthemockedtypeforacalltotoapropertysetter.
SetupSet<(Of<<'(TProperty>)>>)(Action<(Of<<'(T>)>>))
Specifiesasetuponthemockedtypeforacalltotoapropertysetter.
Verify()()()()Verifiesthatallverifiableexpectationshavebeenmet.(InheritedfromMock.)
Verify(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>))
Verifiesthataspecificinvocationmatchingthegivenexpressionwasperformedonthemock.UseinconjuntionwiththedefaultLoose.
Verify(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>),Times)
Verifiesthataspecificinvocationmatchingthegivenexpressionwasperformedonthemock.UseinconjuntionwiththedefaultLoose.
Verify(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>),String)
Verifiesthataspecificinvocationmatchingthegivenexpressionwasperformedonthemock,specifyingafailureerrormessage.UseinconjuntionwiththedefaultLoose.
Verify(Expression<(Of
Verifiesthataspecificinvocationmatchingthegivenexpression
<<'(Action<(Of<<'(T>)>>)>)>>),Times,String)
wasperformedonthemock,specifyingafailureerrormessage.UseinconjuntionwiththedefaultLoose.
Verify<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))Verify<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)Verify<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean,T)
VerifyAll
Verifiesallexpectationsregardlessofwhethertheyhavebeenflaggedasverifiable.(InheritedfromMock.)
VerifyGet<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))VerifyGet<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)VerifyGet<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean,T)
VerifySet(Action<(Of<<'(T>)>>)) Verifiesthatapropertywassetonthemock.
VerifySet(Action<(Of<<'(T>)>>),Times)
Verifiesthatapropertywassetonthemock.
VerifySet(Action<(Of<<'(T>)>>),String)
Verifiesthatapropertywassetonthemock,specifyingafailuremessage.
Verifiesthatapropertywasseton
VerifySet(Action<(Of<<'(T>)>>),Times,String)
themock,specifyingafailuremessage.
When
ExtensionMethods Name Description
InSequence<(Of<<'(TMock>)>>)
Performanexpectationinthetrace.(DefinedbyMockSequenceHelper.)
Protected<(Of<<'(T>)>>)
Enableprotectedsetupsforthemock.(DefinedbyProtectedExtension.)
SetupSequence<(Of<<'(TMock,TResult>)>>) (DefinedbySequenceExtensions.)
SetupSet<(Of<<'(T,TProperty>)>>) (DefinedbyMockExtensions.)
VerifySet<(Of<<'(T,TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
Overloaded.(DefinedbyMockExtensions.)
VerifySet<(Of<<'(T,TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)
Overloaded.(DefinedbyMockExtensions.)
VerifySet<(Of<<'(T,TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)
Overloaded.(DefinedbyMockExtensions.)
VerifySet<(Of<<'(T,TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean,T)
Overloaded.(DefinedbyMockExtensions.)
Properties Name Description
BehaviorBehaviorofthemock,accordingtothevaluesetintheconstructor.(InheritedfromMock.)
CallBase
Whetherthebasemembervirtualimplementationwillbecalledformockedclassesifnosetupismatched.DefaultstofalseFalsefalsefalse(FalseinVisualBasic).(InheritedfromMock.)
DefaultValueSpecifiesthebehaviortousewhenreturningdefaultvaluesforunexpectedinvocationsonloosemocks.(InheritedfromMock.)
Object Exposesthemockedobjectinstance.
SeeAlsoMock<(Of<(<'T>)>)>ClassMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMock<(Of<(<'T>)>)>ConstructorMock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
OverloadList Name Description
Mock<(Of<(<'T>)>)>()()()() Initializesaninstanceofthemockwithdefaultbehavior.
Mock<(Of<(<'T>)>)>(array<Object>[]()[][])
Initializesaninstanceofthemockwithdefaultbehaviorandwiththegivenconstructorargumentsfortheclass.(OnlyvalidwhenTisaclass)
Mock<(Of<(<'T>)>)>(MockBehavior)
Initializesaninstanceofthemockwiththespecifiedbehavior.
Mock<(Of<(<'T>)>)>(MockBehavior,array<Object>[]()[][])
Initializesaninstanceofthemockwithaspecificbehaviorwiththegivenconstructorargumentsfortheclass.
SeeAlsoMock<(Of<(<'T>)>)>ClassMock<(Of<(<'T>)>)>MembersMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>ConstructorMock<(Of<(<'T>)>)>ClassExampleSeeAlsoSendFeedbackInitializesaninstanceofthemockwithdefaultbehavior.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicMock()
Copy
ExamplesC#
varmock=newMock<IFormatProvider>();
SeeAlsoMock<(Of<(<'T>)>)>ClassMock<(Of<(<'T>)>)>OverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>Constructor(array<Object>[]()[][])Mock<(Of<(<'T>)>)>ClassExampleSeeAlsoSendFeedbackInitializesaninstanceofthemockwithdefaultbehaviorandwiththegivenconstructorargumentsfortheclass.(OnlyvalidwhenTisaclass)
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicMock(
paramsObject[]args
)
Parameters
argsType:array<System..::..Object>[]()[][]Optionalconstructorargumentsifthemockedtypeisaclass.
RemarksThemockwilltrytofindthebestmatchconstructorgiventheconstructorarguments,andinvokethattoinitializetheinstance.Thisappliesonlyforclasses,notinterfaces.
Copy
ExamplesC#
varmock=newMock<MyProvider>(someArgument,25);
SeeAlsoMock<(Of<(<'T>)>)>ClassMock<(Of<(<'T>)>)>OverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>Constructor(MockBehavior)Mock<(Of<(<'T>)>)>ClassExampleSeeAlsoSendFeedbackInitializesaninstanceofthemockwiththespecifiedbehavior.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicMock(
MockBehaviorbehavior
)
Parameters
behaviorType:Moq..::..MockBehaviorBehaviorofthemock.
Copy
ExamplesC#
varmock=newMock<IFormatProvider>(MockBehavior.Relaxed);
SeeAlsoMock<(Of<(<'T>)>)>ClassMock<(Of<(<'T>)>)>OverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>Constructor(MockBehavior,array<Object>[]()[][])Mock<(Of<(<'T>)>)>ClassExampleSeeAlsoSendFeedbackInitializesaninstanceofthemockwithaspecificbehaviorwiththegivenconstructorargumentsfortheclass.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicMock(
MockBehaviorbehavior,
paramsObject[]args
)
Parameters
behaviorType:Moq..::..MockBehaviorBehaviorofthemock.
argsType:array<System..::..Object>[]()[][]Optionalconstructorargumentsifthemockedtypeisaclass.
RemarksThemockwilltrytofindthebestmatchconstructorgiventheconstructorarguments,andinvokethattoinitializetheinstance.Thisappliesonlytoclasses,notinterfaces.
Copy
ExamplesC#
varmock=newMock<MyProvider>(someArgument,25);
SeeAlsoMock<(Of<(<'T>)>)>ClassMock<(Of<(<'T>)>)>OverloadMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMock<(Of<(<'T>)>)>MethodsMock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
TheMock<(Of<(<'T>)>)>typeexposesthefollowingmembers.
Methods Name Description
As<(Of<<'(TInterface>)>>)
Addsaninterfaceimplementationtothemock,allowingsetupstobespecifiedforit.(InheritedfromMock.)
OnGetObjectReturnsthemockedobjectvalue.(OverridesMock..::..OnGetObject()()()().)
Raise(Action<(Of<<'(T>)>>),EventArgs)
RaisestheeventreferencedineventExpressionusingthegivenargsargument.
Raise(Action<(Of<<'(T>)>>),array<Object>[]()[][])
RaisestheeventreferencedineventExpressionusingthegivenargsargumentforanon-EventHandlertypedevent.
SetReturnsDefault<(Of<<'(TReturn>)>>) (InheritedfromMock.)
Setup(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>))
Specifiesasetuponthemockedtypeforacalltotoavoidmethod.
Setup<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
SetupAllProperties
Specifiesthattheallpropertiesonthemockshouldhave"propertybehavior",meaningthatsettingitsvaluewillcauseittobesavedandlaterreturnedwhenthepropertyisrequested.(thisisalsoknownas"stubbing").ThedefaultvalueforeachpropertywillbetheonegeneratedasspecifiedbytheDefaultValuepropertyforthemock.
SetupGet<(Of<<'(TProperty>)>>)SetupProperty<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))SetupProperty<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)
SetupSet(Action<(Of<<'(T>)>>))Specifiesasetuponthemockedtypeforacalltotoapropertysetter.
SetupSet<(Of<<'(TProperty>)>>)(Action<(Of<<'(T>)>>))
Specifiesasetuponthemockedtypeforacalltotoapropertysetter.
Verify()()()()Verifiesthatallverifiableexpectationshavebeenmet.(InheritedfromMock.)
Verify(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>))
Verifiesthataspecificinvocationmatchingthegivenexpressionwasperformedonthemock.UseinconjuntionwiththedefaultLoose.
Verify(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>),Times)
Verifiesthataspecificinvocationmatchingthegivenexpressionwasperformedonthemock.UseinconjuntionwiththedefaultLoose.
Verify(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>),String)
Verifiesthataspecificinvocationmatchingthegivenexpressionwasperformedonthemock,specifyingafailureerrormessage.UseinconjuntionwiththedefaultLoose.
Verify(Expression<(Of
Verifiesthataspecificinvocationmatchingthegivenexpression
<<'(Action<(Of<<'(T>)>>)>)>>),Times,String)
wasperformedonthemock,specifyingafailureerrormessage.UseinconjuntionwiththedefaultLoose.
Verify<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))Verify<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)Verify<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean,T)
VerifyAll
Verifiesallexpectationsregardlessofwhethertheyhavebeenflaggedasverifiable.(InheritedfromMock.)
VerifyGet<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))VerifyGet<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)VerifyGet<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean,T)
VerifySet(Action<(Of<<'(T>)>>)) Verifiesthatapropertywassetonthemock.
VerifySet(Action<(Of<<'(T>)>>),Times)
Verifiesthatapropertywassetonthemock.
VerifySet(Action<(Of<<'(T>)>>),String)
Verifiesthatapropertywassetonthemock,specifyingafailuremessage.
Verifiesthatapropertywasseton
VerifySet(Action<(Of<<'(T>)>>),Times,String)
themock,specifyingafailuremessage.
When
ExtensionMethods Name Description
InSequence<(Of<<'(TMock>)>>)
Performanexpectationinthetrace.(DefinedbyMockSequenceHelper.)
Protected<(Of<<'(T>)>>)
Enableprotectedsetupsforthemock.(DefinedbyProtectedExtension.)
SetupSequence<(Of<<'(TMock,TResult>)>>) (DefinedbySequenceExtensions.)
SetupSet<(Of<<'(T,TProperty>)>>) (DefinedbyMockExtensions.)
VerifySet<(Of<<'(T,TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
Overloaded.(DefinedbyMockExtensions.)
VerifySet<(Of<<'(T,TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)
Overloaded.(DefinedbyMockExtensions.)
VerifySet<(Of<<'(T,TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)
Overloaded.(DefinedbyMockExtensions.)
VerifySet<(Of<<'(T,TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean,T)
Overloaded.(DefinedbyMockExtensions.)
SeeAlsoMock<(Of<(<'T>)>)>ClassMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..OnGetObjectMethodMock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedbackReturnsthemockedobjectvalue.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SeeAlsoMock<(Of<(<'T>)>)>ClassMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMock<(Of<(<'T>)>)>..::..RaiseMethodMock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
OverloadList Name Description
Raise(Action<(Of<<'(T>)>>),EventArgs)
RaisestheeventreferencedineventExpressionusingthegivenargsargument.
Raise(Action<(Of<<'(T>)>>),array<Object>[]()[][])
RaisestheeventreferencedineventExpressionusingthegivenargsargumentforanon-EventHandlertypedevent.
SeeAlsoMock<(Of<(<'T>)>)>ClassMock<(Of<(<'T>)>)>MembersMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..RaiseMethod(Action<(Of<(<'T>)>)>,EventArgs)Mock<(Of<(<'T>)>)>ClassExampleSeeAlsoSendFeedbackRaisestheeventreferencedineventExpressionusingthegivenargsargument.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidRaise(
Action<T>eventExpression,
EventArgsargs
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>
argsType:System..::..EventArgs
Copy
ExamplesThefollowingexampleshowshowtoraiseaPropertyChangedevent:
C#
varmock=newMock<IViewModel>();
mock.Raise(x=>x.PropertyChanged-=null,newPropertyChangedEventArgs(
Copy
ExamplesThisexampleshowshowtoinvokeaneventwithacustomeventargumentsclassinaviewthatwillcauseitscorrespondingpresentertoreactbychangingitsstate:
C#
varmockView=newMock<IOrdersView>();
varpresenter=newOrdersPresenter(mockView.Object);
//Checkthatthepresenterhasnoselectionbydefault
Assert.Null(presenter.SelectedOrder);
//Raisetheeventwithaspecificargumentsdata
mockView.Raise(v=>v.SelectionChanged+=null,newOrderEventArgs{Order=
//Nowthepresenterreactedtotheevent,andwehaveaselectedorder
Assert.NotNull(presenter.SelectedOrder);
Assert.Equal("moq",presenter.SelectedOrder.ProductName);
ExceptionsException Condition
System..::..ArgumentExceptionTheargsargumentisinvalidforthetargeteventinvocation,ortheeventExpressionisnotaneventattachordetachexpression.
SeeAlsoMock<(Of<(<'T>)>)>ClassRaiseOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..RaiseMethod(Action<(Of<(<'T>)>)>,array<Object>[]()[][])Mock<(Of<(<'T>)>)>ClassExampleSeeAlsoSendFeedbackRaisestheeventreferencedineventExpressionusingthegivenargsargumentforanon-EventHandlertypedevent.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidRaise(
Action<T>eventExpression,
paramsObject[]args
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>
argsType:array<System..::..Object>[]()[][]
Copy
ExamplesThefollowingexampleshowshowtoraiseacustomeventthatdoesnotadheretothestandardEventHandler:
C#
varmock=newMock<IViewModel>();
mock.Raise(x=>x.MyEvent-=null,"Name",bool,25);
ExceptionsException Condition
System..::..ArgumentExceptionTheargsargumentsareinvalidforthetargeteventinvocation,ortheeventExpressionisnotaneventattachordetachexpression.
SeeAlsoMock<(Of<(<'T>)>)>ClassRaiseOverloadMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMock<(Of<(<'T>)>)>..::..SetupMethodMock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
OverloadList Name Description
Setup(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>))
Specifiesasetuponthemockedtypeforacalltotoavoidmethod.
Setup<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
SeeAlsoMock<(Of<(<'T>)>)>ClassMock<(Of<(<'T>)>)>MembersMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..SetupMethod(Expression<(Of<(<'Action<(Of<(<'T>)>)>>)>)>)Mock<(Of<(<'T>)>)>ClassExampleSeeAlsoSendFeedbackSpecifiesasetuponthemockedtypeforacalltotoavoidmethod.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicISetup<T>Setup(
Expression<Action<T>>expression
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Action<(Of<(<'T>)>)>>)>)>Lambdaexpressionthatspecifiestheexpectedmethodinvocation.
RemarksIfmorethanonesetupisspecifiedforthesamemethodorproperty,thelatestonewinsandistheonethatwillbeexecuted.
Copy
ExamplesC#
varmock=newMock<IProcessor>();
mock.Setup(x=>x.Execute("ping"));
SeeAlsoMock<(Of<(<'T>)>)>ClassSetupOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..Setup<(Of<(<'TResult>)>)>Method(Expression<(Of<(<'Func>)>)>)Mock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Mock`1.Setup``1(System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicISetup<T,TResult>Setup<TResult>(
Expression<Func>expression
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersTResult
SeeAlsoMock<(Of<(<'T>)>)>ClassSetupOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..SetupAllPropertiesMethodMock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedbackSpecifiesthattheallpropertiesonthemockshouldhave"propertybehavior",meaningthatsettingitsvaluewillcauseittobesavedandlaterreturnedwhenthepropertyisrequested.(thisisalsoknownas"stubbing").ThedefaultvalueforeachpropertywillbetheonegeneratedasspecifiedbytheDefaultValuepropertyforthemock.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicMock<T>SetupAllProperties()
RemarksIfthemockDefaultValueissettoMock,themockeddefaultvalueswillalsogetallpropertiessetuprecursively.
SeeAlsoMock<(Of<(<'T>)>)>ClassMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..SetupGet<(Of<(<'TProperty>)>)>MethodMock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Mock`1.SetupGet``1(System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicISetupGetter<T,TProperty>SetupGet<TProperty>(
Expression<Func>expression
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersTProperty
SeeAlsoMock<(Of<(<'T>)>)>ClassMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMock<(Of<(<'T>)>)>..::..SetupPropertyMethodMock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
OverloadList Name Description
SetupProperty<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))SetupProperty<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)
SeeAlsoMock<(Of<(<'T>)>)>ClassMock<(Of<(<'T>)>)>MembersMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..SetupProperty<(Of<(<'TProperty>)>)>Method(Expression<(Of<(<'Func>)>)>)Mock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Mock`1.SetupProperty``1(System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicMock<T>SetupProperty<TProperty>(
Expression<Func>property
)
Parameters
propertyType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersTProperty
SeeAlsoMock<(Of<(<'T>)>)>ClassSetupPropertyOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..SetupProperty<(Of<(<'TProperty>)>)>Method(Expression<(Of<(<'Func>)>)>,Boolean)Mock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Mock`1.SetupProperty``1(System.Linq.Expressions.Expression{System.Func`2},System.Boolean)"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicMock<T>SetupProperty<TProperty>(
Expression<Func>property,
boolinitialValue
)
Parameters
propertyType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
initialValueType:System..::..Boolean
TypeParametersTProperty
SeeAlsoMock<(Of<(<'T>)>)>ClassSetupPropertyOverloadMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMock<(Of<(<'T>)>)>..::..SetupSetMethodMock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
OverloadList Name Description
SetupSet<(Of<<'(TProperty>)>>)(Action<(Of<<'(T>)>>))
Specifiesasetuponthemockedtypeforacalltotoapropertysetter.
SetupSet(Action<(Of<<'(T>)>>))
Specifiesasetuponthemockedtypeforacalltotoapropertysetter.
SeeAlsoMock<(Of<(<'T>)>)>ClassMock<(Of<(<'T>)>)>MembersMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..SetupSet<(Of<(<'TProperty>)>)>Method(Action<(Of<(<'T>)>)>)Mock<(Of<(<'T>)>)>ClassExampleSeeAlsoSendFeedbackSpecifiesasetuponthemockedtypeforacalltotoapropertysetter.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicISetupSetter<T,TProperty>SetupSet<TProperty>(
Action<T>setterExpression
)
Parameters
setterExpressionType:System..::..Action<(Of<(<'T>)>)>TheLambdaexpressionthatsetsapropertytoavalue.
TypeParametersTProperty
Typeoftheproperty.Typicallyomittedasitcanbeinferredfromtheexpression.
RemarksIfmorethanonesetupissetforthesamepropertysetter,thelatestonewinsandistheonethatwillbeexecuted.
Thisoverloadsallowstheuseofacallbackalreadytypedforthepropertytype.
Copy
ExamplesC#
mock.SetupSet(x=>x.Suspended=true);
SeeAlsoMock<(Of<(<'T>)>)>ClassSetupSetOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..SetupSetMethod(Action<(Of<(<'T>)>)>)Mock<(Of<(<'T>)>)>ClassExampleSeeAlsoSendFeedbackSpecifiesasetuponthemockedtypeforacalltotoapropertysetter.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicISetup<T>SetupSet(
Action<T>setterExpression
)
Parameters
setterExpressionType:System..::..Action<(Of<(<'T>)>)>Lambdaexpressionthatsetsapropertytoavalue.
RemarksIfmorethanonesetupissetforthesamepropertysetter,thelatestonewinsandistheonethatwillbeexecuted.
Copy
ExamplesC#
mock.SetupSet(x=>x.Suspended=true);
SeeAlsoMock<(Of<(<'T>)>)>ClassSetupSetOverloadMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMock<(Of<(<'T>)>)>..::..VerifyMethodMock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
OverloadList Name Description
Verify()()()()Verifiesthatallverifiableexpectationshavebeenmet.(InheritedfromMock.)
Verify(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>))
Verifiesthataspecificinvocationmatchingthegivenexpressionwasperformedonthemock.UseinconjuntionwiththedefaultLoose.
Verify<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
Verify(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>),Times)
Verifiesthataspecificinvocationmatchingthegivenexpressionwasperformedonthemock.UseinconjuntionwiththedefaultLoose.
Verify(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>),String)
Verifiesthataspecificinvocationmatchingthegivenexpressionwasperformedonthemock,specifyingafailureerrormessage.UseinconjuntionwiththedefaultLoose.
Verify<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)Verify<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)
Verify(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>),Times,String)
Verifiesthataspecificinvocationmatchingthegivenexpressionwasperformedonthemock,specifyingafailureerrormessage.UseinconjuntionwiththedefaultLoose.
Verify<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean,T)
SeeAlsoMock<(Of<(<'T>)>)>ClassMock<(Of<(<'T>)>)>MembersMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..VerifyMethod(Expression<(Of<(<'Action<(Of<(<'T>)>)>>)>)>)Mock<(Of<(<'T>)>)>ClassExampleSeeAlsoSendFeedbackVerifiesthataspecificinvocationmatchingthegivenexpressionwasperformedonthemock.UseinconjuntionwiththedefaultLoose.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerify(
Expression<Action<T>>expression
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Action<(Of<(<'T>)>)>>)>)>Expressiontoverify.
Copy
ExamplesThisexampleassumesthatthemockhasbeenused,andlaterwewanttoverifythatagiveninvocationwithspecificparameterswasperformed:
C#
varmock=newMock<IProcessor>();
//exercisemock
//...
//Willthrowifthetestcodedidn'tcallExecutewitha"ping"stringargument.
mock.Verify(proc=>proc.Execute("ping"));
ExceptionsException Condition
Moq..::..MockException Theinvocationwasnotperformedonthemock.
SeeAlsoMock<(Of<(<'T>)>)>ClassVerifyOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..Verify<(Of<(<'TResult>)>)>Method(Expression<(Of<(<'Func>)>)>)Mock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Mock`1.Verify``1(System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerify<TResult>(
Expression<Func>expression
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersTResult
SeeAlsoMock<(Of<(<'T>)>)>ClassVerifyOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..VerifyMethod(Expression<(Of<(<'Action<(Of<(<'T>)>)>>)>)>,Times)Mock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedbackVerifiesthataspecificinvocationmatchingthegivenexpressionwasperformedonthemock.UseinconjuntionwiththedefaultLoose.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerify(
Expression<Action<T>>expression,
Timestimes
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Action<(Of<(<'T>)>)>>)>)>Expressiontoverify.
timesType:Moq..::..TimesThenumberoftimesamethodisallowedtobecalled.
ExceptionsException Condition
Moq..::..MockException Theinvocationwasnotcallthetimesspecifiedbytimes.
SeeAlsoMock<(Of<(<'T>)>)>ClassVerifyOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..VerifyMethod(Expression<(Of<(<'Action<(Of<(<'T>)>)>>)>)>,String)Mock<(Of<(<'T>)>)>ClassExampleSeeAlsoSendFeedbackVerifiesthataspecificinvocationmatchingthegivenexpressionwasperformedonthemock,specifyingafailureerrormessage.UseinconjuntionwiththedefaultLoose.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerify(
Expression<Action<T>>expression,
stringfailMessage
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Action<(Of<(<'T>)>)>>)>)>Expressiontoverify.
failMessageType:System..::..StringMessagetoshowifverificationfails.
Copy
ExamplesThisexampleassumesthatthemockhasbeenused,andlaterwewanttoverifythatagiveninvocationwithspecificparameterswasperformed:
C#
varmock=newMock<IProcessor>();
//exercisemock
//...
//Willthrowifthetestcodedidn'tcallExecutewitha"ping"stringargument.
mock.Verify(proc=>proc.Execute("ping"));
ExceptionsException Condition
Moq..::..MockException Theinvocationwasnotperformedonthemock.
SeeAlsoMock<(Of<(<'T>)>)>ClassVerifyOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..Verify<(Of<(<'TResult>)>)>Method(Expression<(Of<(<'Func>)>)>,Boolean)Mock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Mock`1.Verify``1(System.Linq.Expressions.Expression{System.Func`2},System.Boolean)"]
Namespace:MoqAssemblies:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerify<TResult>(
Expression<Func>expression,
booltimes
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
timesType:System..::..Boolean
TypeParametersTResult
SeeAlsoMock<(Of<(<'T>)>)>ClassVerifyOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..VerifyMethod(Expression<(Of<(<'Action<(Of<(<'T>)>)>>)>)>,Times,String)Mock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedbackVerifiesthataspecificinvocationmatchingthegivenexpressionwasperformedonthemock,specifyingafailureerrormessage.UseinconjuntionwiththedefaultLoose.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerify(
Expression<Action<T>>expression,
Timestimes,
stringfailMessage
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Action<(Of<(<'T>)>)>>)>)>Expressiontoverify.
timesType:Moq..::..TimesThenumberoftimesamethodisallowedtobecalled.
failMessageType:System..::..StringMessagetoshowifverificationfails.
ExceptionsException Condition
Moq..::..MockException Theinvocationwasnotcallthetimesspecifiedbytimes.
SeeAlsoMock<(Of<(<'T>)>)>ClassVerifyOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..Verify<(Of<(<'TResult>)>)>Method(Expression<(Of<(<'Func>)>)>,Boolean,T)Mock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Mock`1.Verify``1(System.Linq.Expressions.Expression{System.Func`2},System.Boolean,`0)"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerify<TResult>(
Expression<Func>expression,
booltimes,
TfailMessage
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
timesType:System..::..Boolean
failMessageType:T
TypeParametersTResult
SeeAlsoMock<(Of<(<'T>)>)>ClassVerifyOverloadMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMock<(Of<(<'T>)>)>..::..VerifyGetMethodMock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
OverloadList Name Description
VerifyGet<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))VerifyGet<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)VerifyGet<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)VerifyGet<(Of<<'(TProperty>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean,T)
SeeAlsoMock<(Of<(<'T>)>)>ClassMock<(Of<(<'T>)>)>MembersMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..VerifyGet<(Of<(<'TProperty>)>)>Method(Expression<(Of<(<'Func>)>)>)Mock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Mock`1.VerifyGet``1(System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerifyGet<TProperty>(
Expression<Func>expression
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersTProperty
SeeAlsoMock<(Of<(<'T>)>)>ClassVerifyGetOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..VerifyGet<(Of<(<'TProperty>)>)>Method(Expression<(Of<(<'Func>)>)>,Boolean)Mock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Mock`1.VerifyGet``1(System.Linq.Expressions.Expression{System.Func`2},System.Boolean)"]
Namespace:MoqAssemblies:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerifyGet<TProperty>(
Expression<Func>expression,
boolfailMessage
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
failMessageType:System..::..Boolean
TypeParametersTProperty
SeeAlsoMock<(Of<(<'T>)>)>ClassVerifyGetOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..VerifyGet<(Of<(<'TProperty>)>)>Method(Expression<(Of<(<'Func>)>)>,Boolean,T)Mock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Mock`1.VerifyGet``1(System.Linq.Expressions.Expression{System.Func`2},System.Boolean,`0)"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerifyGet<TProperty>(
Expression<Func>expression,
booltimes,
TfailMessage
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
timesType:System..::..Boolean
failMessageType:T
TypeParametersTProperty
SeeAlsoMock<(Of<(<'T>)>)>ClassVerifyGetOverloadMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMock<(Of<(<'T>)>)>..::..VerifySetMethodMock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
OverloadList Name Description
VerifySet(Action<(Of<<'(T>)>>))
Verifiesthatapropertywassetonthemock.
VerifySet(Action<(Of<<'(T>)>>),Times)
Verifiesthatapropertywassetonthemock.
VerifySet(Action<(Of<<'(T>)>>),String)
Verifiesthatapropertywassetonthemock,specifyingafailuremessage.
VerifySet(Action<(Of<<'(T>)>>),Times,String)
Verifiesthatapropertywassetonthemock,specifyingafailuremessage.
SeeAlsoMock<(Of<(<'T>)>)>ClassMock<(Of<(<'T>)>)>MembersMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..VerifySetMethod(Action<(Of<(<'T>)>)>)Mock<(Of<(<'T>)>)>ClassExampleSeeAlsoSendFeedbackVerifiesthatapropertywassetonthemock.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerifySet(
Action<T>setterExpression
)
Parameters
setterExpressionType:System..::..Action<(Of<(<'T>)>)>Expressiontoverify.
Copy
ExamplesThisexampleassumesthatthemockhasbeenused,andlaterwewanttoverifythatagivenpropertywassetonit:
C#
varmock=newMock<IWarehouse>();
//exercisemock
//...
//Willthrowifthetestcodedidn'tsettheIsClosedproperty.
mock.VerifySet(warehouse=>warehouse.IsClosed=true);
ExceptionsException Condition
Moq..::..MockException Theinvocationwasnotperformedonthemock.
SeeAlsoMock<(Of<(<'T>)>)>ClassVerifySetOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..VerifySetMethod(Action<(Of<(<'T>)>)>,Times)Mock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedbackVerifiesthatapropertywassetonthemock.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerifySet(
Action<T>setterExpression,
Timestimes
)
Parameters
setterExpressionType:System..::..Action<(Of<(<'T>)>)>Expressiontoverify.
timesType:Moq..::..TimesThenumberoftimesamethodisallowedtobecalled.
ExceptionsException Condition
Moq..::..MockException Theinvocationwasnotcallthetimesspecifiedbytimes.
SeeAlsoMock<(Of<(<'T>)>)>ClassVerifySetOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..VerifySetMethod(Action<(Of<(<'T>)>)>,String)Mock<(Of<(<'T>)>)>ClassExampleSeeAlsoSendFeedbackVerifiesthatapropertywassetonthemock,specifyingafailuremessage.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerifySet(
Action<T>setterExpression,
stringfailMessage
)
Parameters
setterExpressionType:System..::..Action<(Of<(<'T>)>)>Expressiontoverify.
failMessageType:System..::..StringMessagetoshowifverificationfails.
Copy
ExamplesThisexampleassumesthatthemockhasbeenused,andlaterwewanttoverifythatagivenpropertywassetonit:
C#
varmock=newMock<IWarehouse>();
//exercisemock
//...
//Willthrowifthetestcodedidn'tsettheIsClosedproperty.
mock.VerifySet(warehouse=>warehouse.IsClosed=true,"Warehouseshouldalwaysbeclosedaftertheaction"
ExceptionsException Condition
Moq..::..MockException Theinvocationwasnotperformedonthemock.
SeeAlsoMock<(Of<(<'T>)>)>ClassVerifySetOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..VerifySetMethod(Action<(Of<(<'T>)>)>,Times,String)Mock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedbackVerifiesthatapropertywassetonthemock,specifyingafailuremessage.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvoidVerifySet(
Action<T>setterExpression,
Timestimes,
stringfailMessage
)
Parameters
setterExpressionType:System..::..Action<(Of<(<'T>)>)>Expressiontoverify.
timesType:Moq..::..TimesThenumberoftimesamethodisallowedtobecalled.
failMessageType:System..::..StringMessagetoshowifverificationfails.
ExceptionsException Condition
Moq..::..MockException Theinvocationwasnotcallthetimesspecifiedbytimes.
SeeAlsoMock<(Of<(<'T>)>)>ClassVerifySetOverloadMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..WhenMethodMock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Mock`1.When(System.Func`1)"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicISetupConditionResult<T>When(
Funccondition
)
Parameters
conditionType:System..::..Func<(Of<(<'TResult>)>)>
SeeAlsoMock<(Of<(<'T>)>)>ClassMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMock<(Of<(<'T>)>)>PropertiesMock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedback
TheMock<(Of<(<'T>)>)>typeexposesthefollowingmembers.
Properties Name Description
BehaviorBehaviorofthemock,accordingtothevaluesetintheconstructor.(InheritedfromMock.)
CallBase
Whetherthebasemembervirtualimplementationwillbecalledformockedclassesifnosetupismatched.DefaultstofalseFalsefalsefalse(FalseinVisualBasic).(InheritedfromMock.)
DefaultValueSpecifiesthebehaviortousewhenreturningdefaultvaluesforunexpectedinvocationsonloosemocks.(InheritedfromMock.)
Object Exposesthemockedobjectinstance.
SeeAlsoMock<(Of<(<'T>)>)>ClassMoqNamespace
C#
MoqMock<(Of<(<'T>)>)>..::..ObjectPropertyMock<(Of<(<'T>)>)>ClassSeeAlsoSendFeedbackExposesthemockedobjectinstance.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvirtualTObject{get;}
SeeAlsoMock<(Of<(<'T>)>)>ClassMoqNamespace
C#
MoqMockBehaviorEnumerationSeeAlsoSendFeedbackOptionstocustomizethebehaviorofthemock.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicenumMockBehavior
MembersMembername DescriptionStrictLooseDefault
C#
MoqMockExceptionClassMembersSeeAlsoSendFeedbackExceptionthrownbymockswhensetupsarenotmatched,themockisnotproperlysetup,etc.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
[SerializableAttribute]
publicclassMockException:Exception
RemarksAdistinctexceptiontypeisprovidedsothatexceptionsthrownbythemockcanbedifferentiatedinteststhatexpectotherexceptionstobethrown(i.e.ArgumentException).
Richerexceptionhierarchy/typesarenotprovidedasteststypicallyshouldnotcatchorexpectexceptionsfromthemocks.Thesearetypicallytheresultofchangesinthetestedclassoritscollaboratorsimplementation,andresultinfixesinthemocksetupsothattheydissapearandallowthetesttopass.
InheritanceHierarchySystem..::..ObjectSystem..::..ExceptionMoq..::..MockException
SeeAlsoMockExceptionMembersMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockExceptionMembersMockExceptionClassConstructorsMethodsSeeAlsoSendFeedback
TheMockExceptiontypeexposesthefollowingmembers.
Constructors Name Description
MockException Supportstheserializationinfrastructure.
Methods Name Description
GetObjectData
Supportstheserializationinfrastructure.(OverridesException..::..GetObjectData(SerializationInfo,StreamingContext).)
SeeAlsoMockExceptionClassMoqNamespace
C#
MoqMockExceptionConstructorMockExceptionClassSeeAlsoSendFeedbackSupportstheserializationinfrastructure.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
protectedMockException(
SerializationInfoinfo,
StreamingContextcontext
)
Parameters
infoType:System.Runtime.Serialization..::..SerializationInfoSerializationinformation.
contextType:System.Runtime.Serialization..::..StreamingContextStreamingcontext.
SeeAlsoMockExceptionClassMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockExceptionMethodsMockExceptionClassSeeAlsoSendFeedback
TheMockExceptiontypeexposesthefollowingmembers.
Methods Name Description
GetObjectData
Supportstheserializationinfrastructure.(OverridesException..::..GetObjectData(SerializationInfo,StreamingContext).)
SeeAlsoMockExceptionClassMoqNamespace
C#
MoqMockException..::..GetObjectDataMethodMockExceptionClassSeeAlsoSendFeedbackSupportstheserializationinfrastructure.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicoverridevoidGetObjectData(
SerializationInfoinfo,
StreamingContextcontext
)
Parameters
infoType:System.Runtime.Serialization..::..SerializationInfoSerializationinformation.
contextType:System.Runtime.Serialization..::..StreamingContextStreamingcontext.
Implements
ISerializable..::..GetObjectData(SerializationInfo,StreamingContext)_Exception..::..GetObjectData(SerializationInfo,StreamingContext)
SeeAlsoMockExceptionClassMoqNamespace
C#
MoqMockExtensionsClassMembersSeeAlsoSendFeedbackProvidesadditionalmethodsonmocks.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticclassMockExtensions
InheritanceHierarchySystem..::..ObjectMoq..::..MockExtensions
SeeAlsoMockExtensionsMembersMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockExtensionsMembersMockExtensionsClassMethodsSeeAlsoSendFeedback
TheMockExtensionstypeexposesthefollowingmembers.
Methods Name Description
SetupSet<(Of<<'(T,TProperty>)>>) Obsolete.VerifySet<(Of<<'(T,TProperty>)>>)(Mock<(Of<<'(T>)>>),Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
Obsolete.
VerifySet<(Of<<'(T,TProperty>)>>)(Mock<(Of<<'(T>)>>),Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)
Obsolete.
VerifySet<(Of<<'(T,TProperty>)>>)(Mock<(Of<<'(T>)>>),Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean,T)
Obsolete.
SeeAlsoMockExtensionsClassMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockExtensionsMethodsMockExtensionsClassSeeAlsoSendFeedback
TheMockExtensionstypeexposesthefollowingmembers.
Methods Name Description
SetupSet<(Of<<'(T,TProperty>)>>) Obsolete.VerifySet<(Of<<'(T,TProperty>)>>)(Mock<(Of<<'(T>)>>),Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
Obsolete.
VerifySet<(Of<<'(T,TProperty>)>>)(Mock<(Of<<'(T>)>>),Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)
Obsolete.
VerifySet<(Of<<'(T,TProperty>)>>)(Mock<(Of<<'(T>)>>),Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean,T)
Obsolete.
SeeAlsoMockExtensionsClassMoqNamespace
C#
MoqMockExtensions..::..SetupSet<(Of<(<'T,TProperty>)>)>MethodMockExtensionsClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.MockExtensions.SetupSet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
[ObsoleteAttribute("ReplacedbySetupSet(Action)")]
publicstaticISetupSetter<T,TProperty>SetupSet<T,TProperty>(
thisMock<T>mock,
Expression<Func>expression
)
whereT:class
Parameters
mockType:Moq..::..Mock<(Of<(<'T>)>)>
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersTTProperty
SeeAlsoMockExtensionsClassMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockExtensions..::..VerifySetMethodMockExtensionsClassSeeAlsoSendFeedback
OverloadList Name Description
VerifySet<(Of<<'(T,TProperty>)>>)(Mock<(Of<<'(T>)>>),Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
Obsolete.
VerifySet<(Of<<'(T,TProperty>)>>)(Mock<(Of<<'(T>)>>),Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)
Obsolete.
VerifySet<(Of<<'(T,TProperty>)>>)(Mock<(Of<<'(T>)>>),Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean)VerifySet<(Of<<'(T,TProperty>)>>)(Mock<(Of<<'(T>)>>),Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>),Boolean,T)
Obsolete.
SeeAlsoMockExtensionsClassMockExtensionsMembersMoqNamespace
C#
MoqMockExtensions..::..VerifySet<(Of<(<'T,TProperty>)>)>Method(Mock<(Of<(<'T>)>)>,Expression<(Of<(<'Func>)>)>)MockExtensionsClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.MockExtensions.VerifySet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
[ObsoleteAttribute("ReplacedbyVerifySet(Action)")]
publicstaticvoidVerifySet<T,TProperty>(
thisMock<T>mock,
Expression<Func>expression
)
whereT:class
Parameters
mockType:Moq..::..Mock<(Of<(<'T>)>)>
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersTTProperty
SeeAlsoMockExtensionsClassVerifySetOverloadMoqNamespace
C#
MoqMockExtensions..::..VerifySet<(Of<(<'T,TProperty>)>)>Method(Mock<(Of<(<'T>)>)>,Expression<(Of<(<'Func>)>)>,Boolean)MockExtensionsClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.MockExtensions.VerifySet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func`2},System.Boolean)"]
Namespace:MoqAssemblies:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
[ObsoleteAttribute("ReplacedbyVerifySet(Action,Times)")]
publicstaticvoidVerifySet<T,TProperty>(
thisMock<T>mock,
Expression<Func>expression,
booltimes
)
whereT:class
Parameters
mockType:Moq..::..Mock<(Of<(<'T>)>)>
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
timesType:System..::..Boolean
TypeParametersTTProperty
SeeAlsoMockExtensionsClassVerifySetOverloadMoqNamespace
C#
MoqMockExtensions..::..VerifySet<(Of<(<'T,TProperty>)>)>Method(Mock<(Of<(<'T>)>)>,Expression<(Of<(<'Func>)>)>,Boolean,T)MockExtensionsClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.MockExtensions.VerifySet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func`2},System.Boolean,``0)"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
[ObsoleteAttribute("ReplacedbyVerifySet(Action,Times,string)")]
publicstaticvoidVerifySet<T,TProperty>(
thisMock<T>mock,
Expression<Func>expression,
booltimes,
TfailMessage
)
whereT:class
Parameters
mockType:Moq..::..Mock<(Of<(<'T>)>)>
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
timesType:System..::..Boolean
failMessageType:T
TypeParametersTTProperty
SeeAlsoMockExtensionsClassVerifySetOverloadMoqNamespace
C#
MoqMockFactoryClassMembersExampleSeeAlsoSendFeedbackUtilityfactoryclasstousetoconstructmultiplemockswhenconsistentverificationisdesiredforallofthem.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
[ObsoleteAttribute("ThisclasshasbeenrenamedtoMockRepository.MockFactorywillberetiredinv5.",
false)]
publicclassMockFactory
RemarksIfmultiplemockswillbecreatedduringatest,passingthedesiredMockBehavior(ifdifferentthantheDefaultortheonepassedtothefactoryconstructor)andlaterverifyingeachmockcanbecomerepetitiveandtedious.
ThisfactoryclasshelpsinthatscenariobyprovidingasimplifiedcreationofmultiplemockswithadefaultMockBehavior(unlessoverridenbycallingCreate<(Of<<'(T>)>>)(MockBehavior))andposteriorverification.
Copy
Copy
ExamplesThefollowingisastraightforwardexampleonhowtocreateandautomaticallyverifystrictmocksusingaMockFactory:
C#
varfactory=newMockFactory(MockBehavior.Strict);
varfoo=factory.Create<IFoo>();
varbar=factory.Create<IBar>();
//noneedtocallVerifiable()onthesetup
//aswe'llbevalidatingallofthemanyway.
foo.Setup(f=>f.Do());
bar.Setup(b=>b.Redo());
//exercisethemockshere
factory.VerifyAll();
//Atthispointallsetupsarealreadychecked
//andanoptionalMockExceptionmightbethrown.
//Notealsothatbecausethemocksarestrict,anyinvocation
//thatdoesn'thaveamatchingsetupwillalsothrowaMockException.
Thefollowingexamplesshowshowtosetupthefactorytocreateloosemocksandlaterverifyonlyverifiablesetups:
C#
varfactory=newMockFactory(MockBehavior.Loose);
varfoo=factory.Create<IFoo>();
varbar=factory.Create<IBar>();
//thissetupwillbeverifiedwhenweverifythefactory
foo.Setup(f=>f.Do()).Verifiable();
//thissetupwillNOTbeverified
foo.Setup(f=>f.Calculate());
//thissetupwillbeverifiedwhenweverifythefactory
bar.Setup(b=>b.Redo()).Verifiable();
Copy
//exercisethemockshere
//notethatbecausethemocksareLoose,members
//calledintheinterfacesforwhichnomatching
//setupsexistwillNOTthrowexceptions,
//andwillratherreturndefaultvalues.
factory.Verify();
//Atthispointverifiablesetupsarealreadychecked
//andanoptionalMockExceptionmightbethrown.
Thefollowingexamplesshowshowtosetupthefactorywithadefaultstrictbehavior,overridingthatdefaultforaspecificmock:
C#
varfactory=newMockFactory(MockBehavior.Strict);
//thisparticularonewewantloose
varfoo=factory.Create<IFoo>(MockBehavior.Loose);
varbar=factory.Create<IBar>();
//specifysetups
//exercisethemockshere
factory.Verify();
InheritanceHierarchySystem..::..ObjectMoq..::..MockFactoryMoq..::..MockRepository
SeeAlsoMockFactoryMembersMoqNamespaceMoq..::..MockBehavior
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockFactoryMembersMockFactoryClassConstructorsMethodsPropertiesSeeAlsoSendFeedback
TheMockFactorytypeexposesthefollowingmembers.
Constructors Name Description
MockFactory InitializesthefactorywiththegivendefaultBehaviorfornewlycreatedmocksfromthefactory.
Methods Name Description
Create<(Of<<'(T>)>>)()()()()CreatesanewmockwiththedefaultMockBehaviorspecifiedatfactoryconstructiontime.
Create<(Of<<'(T>)>>)(array<Object>[]()[][])
CreatesanewmockwiththedefaultMockBehaviorspecifiedatfactoryconstructiontimeandwiththethegivenconstructorargumentsfortheclass.
Create<(Of<<'(T>)>>)(MockBehavior)
Createsanewmockwiththegivenbehavior.
Create<(Of<<'(T>)>>)(MockBehavior,array<Object>[]()[][])
Createsanewmockwiththegivenbehaviorandwiththethegivenconstructorargumentsfortheclass.
CreateMock<(Of<<'(T>)>>) Implementscreationofanewmockwithinthefactory.
Verify Verifiesallverifiableexpectationsonallmockscreatedbythisfactory.
VerifyAll Verifiesallverifiableexpectationsonallmockscreatedbythisfactory.
VerifyMocks
InvokesverifyActionforeachmockinMocks,andaccumulatestheresultingMockVerificationExceptionthatmightbethrownfromtheaction.
Properties Name Description
CallBaseWhetherthebasemembervirtualimplementationwillbecalledformockedclassesifnosetupismatched.DefaultstofalseFalsefalsefalse(FalseinVisualBasic).
DefaultValue Specifiesthebehaviortousewhenreturningdefaultvaluesforunexpectedinvocationsonloosemocks.
Mocks Getsthemocksthathavebeencreatedbythisfactoryandthatwillgetverifiedtogether.
C#
MoqMockFactoryConstructorMockFactoryClassSeeAlsoSendFeedbackInitializesthefactorywiththegivendefaultBehaviorfornewlycreatedmocksfromthefactory.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicMockFactory(
MockBehaviordefaultBehavior
)
Parameters
defaultBehaviorType:Moq..::..MockBehaviorThebehaviortouseformockscreatedusingtheCreate<(Of<<'(T>)>>)()()()()factorymethodifnotoverridenbyusingtheCreate<(Of<<'(T>)>>)(MockBehavior)overload.
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockFactoryMethodsMockFactoryClassSeeAlsoSendFeedback
TheMockFactorytypeexposesthefollowingmembers.
Methods Name Description
Create<(Of<<'(T>)>>)()()()()CreatesanewmockwiththedefaultMockBehaviorspecifiedatfactoryconstructiontime.
Create<(Of<<'(T>)>>)(array<Object>[]()[][])
CreatesanewmockwiththedefaultMockBehaviorspecifiedatfactoryconstructiontimeandwiththethegivenconstructorargumentsfortheclass.
Create<(Of<<'(T>)>>)(MockBehavior)
Createsanewmockwiththegivenbehavior.
Create<(Of<<'(T>)>>)(MockBehavior,array<Object>[]()[][])
Createsanewmockwiththegivenbehaviorandwiththethegivenconstructorargumentsfortheclass.
CreateMock<(Of<<'(T>)>>) Implementscreationofanewmockwithinthefactory.
Verify Verifiesallverifiableexpectationsonallmockscreatedbythisfactory.
VerifyAll Verifiesallverifiableexpectationsonallmockscreatedbythisfactory.
VerifyMocks
InvokesverifyActionforeachmockinMocks,andaccumulatestheresultingMockVerificationExceptionthatmightbethrownfromtheaction.
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockFactory..::..CreateMethodMockFactoryClassSeeAlsoSendFeedback
OverloadList Name Description
Create<(Of<<'(T>)>>)()()()()CreatesanewmockwiththedefaultMockBehaviorspecifiedatfactoryconstructiontime.
Create<(Of<<'(T>)>>)(array<Object>[]()[][])
CreatesanewmockwiththedefaultMockBehaviorspecifiedatfactoryconstructiontimeandwiththethegivenconstructorargumentsfortheclass.
Create<(Of<<'(T>)>>)(MockBehavior)
Createsanewmockwiththegivenbehavior.
Create<(Of<<'(T>)>>)(MockBehavior,array<Object>[]()[][])
Createsanewmockwiththegivenbehaviorandwiththethegivenconstructorargumentsfortheclass.
SeeAlsoMockFactoryClassMockFactoryMembersMoqNamespace
C#
MoqMockFactory..::..Create<(Of<(<'T>)>)>MethodMockFactoryClassExampleSeeAlsoSendFeedbackCreatesanewmockwiththedefaultMockBehaviorspecifiedatfactoryconstructiontime.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicMock<T>Create<T>()
whereT:class
TypeParametersT
Typetomock.
ReturnValue
AnewMock<(Of<(<'T>)>)>.
Copy
ExamplesC#
varfactory=newMockFactory(MockBehavior.Strict);
varfoo=factory.Create<IFoo>();
//usemockontests
factory.VerifyAll();
SeeAlsoMockFactoryClassCreateOverloadMoqNamespace
C#
MoqMockFactory..::..Create<(Of<(<'T>)>)>Method(array<Object>[]()[][])MockFactoryClassExampleSeeAlsoSendFeedbackCreatesanewmockwiththedefaultMockBehaviorspecifiedatfactoryconstructiontimeandwiththethegivenconstructorargumentsfortheclass.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicMock<T>Create<T>(
paramsObject[]args
)
whereT:class
Parameters
argsType:array<System..::..Object>[]()[][]Constructorargumentsformockedclasses.
TypeParametersT
Typetomock.
ReturnValue
AnewMock<(Of<(<'T>)>)>.
RemarksThemockwilltrytofindthebestmatchconstructorgiventheconstructorarguments,andinvokethattoinitializetheinstance.Thisappliesonlytoclasses,notinterfaces.
Copy
ExamplesC#
varfactory=newMockFactory(MockBehavior.Default);
varmock=factory.Create<MyBase>("Foo",25,true);
//usemockontests
factory.Verify();
SeeAlsoMockFactoryClassCreateOverloadMoqNamespace
C#
MoqMockFactory..::..Create<(Of<(<'T>)>)>Method(MockBehavior)MockFactoryClassExampleSeeAlsoSendFeedbackCreatesanewmockwiththegivenbehavior.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicMock<T>Create<T>(
MockBehaviorbehavior
)
whereT:class
Parameters
behaviorType:Moq..::..MockBehaviorBehaviortouseforthemock,whichoverridesthedefaultbehaviorspecifiedatfactoryconstructiontime.
TypeParametersT
Typetomock.
ReturnValue
AnewMock<(Of<(<'T>)>)>.
Copy
ExamplesThefollowingexampleshowshowtocreateamockwithadifferentbehaviortothatspecifiedasthedefaultforthefactory:
C#
varfactory=newMockFactory(MockBehavior.Strict);
varfoo=factory.Create<IFoo>(MockBehavior.Loose);
SeeAlsoMockFactoryClassCreateOverloadMoqNamespace
C#
MoqMockFactory..::..Create<(Of<(<'T>)>)>Method(MockBehavior,array<Object>[]()[][])MockFactoryClassExampleSeeAlsoSendFeedbackCreatesanewmockwiththegivenbehaviorandwiththethegivenconstructorargumentsfortheclass.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicMock<T>Create<T>(
MockBehaviorbehavior,
paramsObject[]args
)
whereT:class
Parameters
behaviorType:Moq..::..MockBehaviorBehaviortouseforthemock,whichoverridesthedefaultbehaviorspecifiedatfactoryconstructiontime.
argsType:array<System..::..Object>[]()[][]Constructorargumentsformockedclasses.
TypeParametersT
Typetomock.
ReturnValue
AnewMock<(Of<(<'T>)>)>.
RemarksThemockwilltrytofindthebestmatchconstructorgiventheconstructorarguments,andinvokethattoinitializetheinstance.Thisappliesonlytoclasses,notinterfaces.
Copy
ExamplesThefollowingexampleshowshowtocreateamockwithadifferentbehaviortothatspecifiedasthedefaultforthefactory,passingconstructorarguments:
C#
varfactory=newMockFactory(MockBehavior.Default);
varmock=factory.Create<MyBase>(MockBehavior.Strict,"Foo",25,true
SeeAlsoMockFactoryClassCreateOverloadMoqNamespace
C#
MoqMockFactory..::..CreateMock<(Of<(<'T>)>)>MethodMockFactoryClassSeeAlsoSendFeedbackImplementscreationofanewmockwithinthefactory.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
protectedvirtualMock<T>CreateMock<T>(
MockBehaviorbehavior,
Object[]args
)
whereT:class
Parameters
behaviorType:Moq..::..MockBehaviorThebehaviorforthenewmock.
argsType:array<System..::..Object>[]()[][]Optionalargumentsfortheconstructionofthemock.
TypeParametersT
Typetomock.
C#
MoqMockFactory..::..VerifyMethodMockFactoryClassSeeAlsoSendFeedbackVerifiesallverifiableexpectationsonallmockscreatedbythisfactory.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvirtualvoidVerify()
ExceptionsException Condition
Moq..::..MockException Oneormoremockshadexpectationsthatwerenotsatisfied.
SeeAlsoMockFactoryClassMoqNamespaceMock..::..Verify()()()()
C#
MoqMockFactory..::..VerifyAllMethodMockFactoryClassSeeAlsoSendFeedbackVerifiesallverifiableexpectationsonallmockscreatedbythisfactory.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicvirtualvoidVerifyAll()
ExceptionsException Condition
Moq..::..MockException Oneormoremockshadexpectationsthatwerenotsatisfied.
SeeAlsoMockFactoryClassMoqNamespaceMock..::..Verify()()()()
C#
MoqMockFactory..::..VerifyMocksMethodMockFactoryClassSeeAlsoSendFeedbackInvokesverifyActionforeachmockinMocks,andaccumulatestheresultingMockVerificationExceptionthatmightbethrownfromtheaction.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
protectedvirtualvoidVerifyMocks(
Action<Mock>verifyAction
)
Parameters
verifyActionType:System..::..Action<(Of<(<'Mock>)>)>Theactiontoexecuteagainsteachmock.
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockFactoryPropertiesMockFactoryClassSeeAlsoSendFeedback
TheMockFactorytypeexposesthefollowingmembers.
Properties Name Description
CallBaseWhetherthebasemembervirtualimplementationwillbecalledformockedclassesifnosetupismatched.DefaultstofalseFalsefalsefalse(FalseinVisualBasic).
DefaultValue Specifiesthebehaviortousewhenreturningdefaultvaluesforunexpectedinvocationsonloosemocks.
Mocks Getsthemocksthathavebeencreatedbythisfactoryandthatwillgetverifiedtogether.
C#
MoqMockFactory..::..CallBasePropertyMockFactoryClassSeeAlsoSendFeedbackWhetherthebasemembervirtualimplementationwillbecalledformockedclassesifnosetupismatched.DefaultstofalseFalsefalsefalse(FalseinVisualBasic).
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
C#
MoqMockFactory..::..DefaultValuePropertyMockFactoryClassSeeAlsoSendFeedbackSpecifiesthebehaviortousewhenreturningdefaultvaluesforunexpectedinvocationsonloosemocks.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicDefaultValueDefaultValue{get;set;}
C#
MoqMockFactory..::..MocksPropertyMockFactoryClassSeeAlsoSendFeedbackGetsthemocksthathavebeencreatedbythisfactoryandthatwillgetverifiedtogether.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
protectedinternalIEnumerable<Mock>Mocks{get;}
C#
MoqMockRepositoryClassMembersExampleSeeAlsoSendFeedbackUtilityrepositoryclasstousetoconstructmultiplemockswhenconsistentverificationisdesiredforallofthem.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicclassMockRepository:MockFactory
RemarksIfmultiplemockswillbecreatedduringatest,passingthedesiredMockBehavior(ifdifferentthantheDefaultortheonepassedtotherepositoryconstructor)andlaterverifyingeachmockcanbecomerepetitiveandtedious.
ThisrepositoryclasshelpsinthatscenariobyprovidingasimplifiedcreationofmultiplemockswithadefaultMockBehavior(unlessoverridenbycallingCreate<(Of<<'(T>)>>)(MockBehavior))andposteriorverification.
Copy
Copy
ExamplesThefollowingisastraightforwardexampleonhowtocreateandautomaticallyverifystrictmocksusingaMockRepository:
C#
varrepository=newMockRepository(MockBehavior.Strict);
varfoo=repository.Create<IFoo>();
varbar=repository.Create<IBar>();
//noneedtocallVerifiable()onthesetup
//aswe'llbevalidatingallofthemanyway.
foo.Setup(f=>f.Do());
bar.Setup(b=>b.Redo());
//exercisethemockshere
repository.VerifyAll();
//Atthispointallsetupsarealreadychecked
//andanoptionalMockExceptionmightbethrown.
//Notealsothatbecausethemocksarestrict,anyinvocation
//thatdoesn'thaveamatchingsetupwillalsothrowaMockException.
Thefollowingexamplesshowshowtosetuptherepositorytocreateloosemocksandlaterverifyonlyverifiablesetups:
C#
varrepository=newMockRepository(MockBehavior.Loose);
varfoo=repository.Create<IFoo>();
varbar=repository.Create<IBar>();
//thissetupwillbeverifiedwhenweverifytherepository
foo.Setup(f=>f.Do()).Verifiable();
//thissetupwillNOTbeverified
foo.Setup(f=>f.Calculate());
//thissetupwillbeverifiedwhenweverifytherepository
bar.Setup(b=>b.Redo()).Verifiable();
Copy
//exercisethemockshere
//notethatbecausethemocksareLoose,members
//calledintheinterfacesforwhichnomatching
//setupsexistwillNOTthrowexceptions,
//andwillratherreturndefaultvalues.
repository.Verify();
//Atthispointverifiablesetupsarealreadychecked
//andanoptionalMockExceptionmightbethrown.
Thefollowingexamplesshowshowtosetuptherepositorywithadefaultstrictbehavior,overridingthatdefaultforaspecificmock:
C#
varrepository=newMockRepository(MockBehavior.Strict);
//thisparticularonewewantloose
varfoo=repository.Create<IFoo>(MockBehavior.Loose);
varbar=repository.Create<IBar>();
//specifysetups
//exercisethemockshere
repository.Verify();
InheritanceHierarchySystem..::..ObjectMoq..::..MockFactoryMoq..::..MockRepository
SeeAlsoMockRepositoryMembersMoqNamespaceMoq..::..MockBehavior
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockRepositoryMembersMockRepositoryClassConstructorsMethodsPropertiesSeeAlsoSendFeedback
TheMockRepositorytypeexposesthefollowingmembers.
Constructors Name Description
MockRepositoryInitializestherepositorywiththegivendefaultBehaviorfornewlycreatedmocksfromtherepository.
Methods Name Description
Create<(Of<<'(T>)>>)()()()()
CreatesanewmockwiththedefaultMockBehaviorspecifiedatfactoryconstructiontime.(InheritedfromMockFactory.)
Create<(Of<<'(T>)>>)(array<Object>[]()[][])
CreatesanewmockwiththedefaultMockBehaviorspecifiedatfactoryconstructiontimeandwiththethegivenconstructorargumentsfortheclass.(InheritedfromMockFactory.)
Create<(Of<<'(T>)>>)(MockBehavior)
Createsanewmockwiththegivenbehavior.(InheritedfromMockFactory.)
Create<(Of<<'(T>)>>)(MockBehavior,array<Object>[]()[][])
Createsanewmockwiththegivenbehaviorandwiththethegivenconstructorargumentsfortheclass.(InheritedfromMockFactory.)
CreateMock<(Of<<'(T>)>>)Implementscreationofanewmockwithinthefactory.(InheritedfromMockFactory.)
Of<(Of<<'(T>)>>)()()()()
Accesstheuniverseofmocksofthegiventype,toretrievethosethatbehaveaccordingtotheLINQqueryspecification.
Of<(Of<<'(T>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
OneOf<(Of<<'(T>)>>)()()()() Createsanmockobjectoftheindicatedtype.
OneOf<(Of<<'(T>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
VerifyVerifiesallverifiableexpectationsonallmockscreatedbythisfactory.(InheritedfromMockFactory.)
VerifyAllVerifiesallverifiableexpectationsonallmockscreatedbythisfactory.(InheritedfromMockFactory.)
VerifyMocks
InvokesverifyActionforeachmockinMocks,andaccumulatestheresultingMockVerificationExceptionthatmightbethrownfromtheaction.(InheritedfromMockFactory.)
Properties Name Description
CallBase
Whetherthebasemembervirtualimplementationwillbecalledformockedclassesifnosetupismatched.DefaultstofalseFalsefalsefalse(FalseinVisualBasic).(InheritedfromMockFactory.)
DefaultValueSpecifiesthebehaviortousewhenreturningdefaultvaluesforunexpectedinvocationsonloosemocks.(InheritedfromMockFactory.)
MocksGetsthemocksthathavebeencreatedbythisfactoryandthatwillgetverifiedtogether.(InheritedfromMockFactory.)
SeeAlsoMockRepositoryClassMoqNamespace
C#
MoqMockRepositoryConstructorMockRepositoryClassSeeAlsoSendFeedbackInitializestherepositorywiththegivendefaultBehaviorfornewlycreatedmocksfromtherepository.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicMockRepository(
MockBehaviordefaultBehavior
)
Parameters
defaultBehaviorType:Moq..::..MockBehaviorThebehaviortouseformockscreatedusingtheCreate<(Of<<'(T>)>>)()()()()repositorymethodifnotoverridenbyusingtheCreate<(Of<<'(T>)>>)(MockBehavior)overload.
SeeAlsoMockRepositoryClassMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockRepositoryMethodsMockRepositoryClassSeeAlsoSendFeedback
TheMockRepositorytypeexposesthefollowingmembers.
Methods Name Description
Create<(Of<<'(T>)>>)()()()()
CreatesanewmockwiththedefaultMockBehaviorspecifiedatfactoryconstructiontime.(InheritedfromMockFactory.)
Create<(Of<<'(T>)>>)(array<Object>[]()[][])
CreatesanewmockwiththedefaultMockBehaviorspecifiedatfactoryconstructiontimeandwiththethegivenconstructorargumentsfortheclass.(InheritedfromMockFactory.)
Create<(Of<<'(T>)>>)(MockBehavior)
Createsanewmockwiththegivenbehavior.(InheritedfromMockFactory.)
Create<(Of<<'(T>)>>)(MockBehavior,array<Object>[]()[][])
Createsanewmockwiththegivenbehaviorandwiththethegivenconstructorargumentsfortheclass.(InheritedfromMockFactory.)
CreateMock<(Of<<'(T>)>>)Implementscreationofanewmockwithinthefactory.(InheritedfromMockFactory.)
Of<(Of<<'(T>)>>)()()()()
Accesstheuniverseofmocksofthegiventype,toretrievethosethatbehaveaccordingtotheLINQqueryspecification.
Of<(Of<<'(T>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
OneOf<(Of<<'(T>)>>)()()()() Createsanmockobjectoftheindicatedtype.
OneOf<(Of<<'(T>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
VerifyVerifiesallverifiableexpectationsonallmockscreatedbythisfactory.(InheritedfromMockFactory.)
VerifyAllVerifiesallverifiableexpectationsonallmockscreatedbythisfactory.(InheritedfromMockFactory.)
VerifyMocks
InvokesverifyActionforeachmockinMocks,andaccumulatestheresultingMockVerificationExceptionthatmightbethrownfromtheaction.(InheritedfromMockFactory.)
SeeAlsoMockRepositoryClassMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockRepository..::..CreateMethodMockRepositoryClassSeeAlsoSendFeedback
OverloadList Name Description
Create<(Of<<'(T>)>>)()()()()
CreatesanewmockwiththedefaultMockBehaviorspecifiedatfactoryconstructiontime.(InheritedfromMockFactory.)
Create<(Of<<'(T>)>>)(array<Object>[]()[][])
CreatesanewmockwiththedefaultMockBehaviorspecifiedatfactoryconstructiontimeandwiththethegivenconstructorargumentsfortheclass.(InheritedfromMockFactory.)
Create<(Of<<'(T>)>>)(MockBehavior)
Createsanewmockwiththegivenbehavior.(InheritedfromMockFactory.)
Create<(Of<<'(T>)>>)(MockBehavior,array<Object>[]()[][])
Createsanewmockwiththegivenbehaviorandwiththethegivenconstructorargumentsfortheclass.(InheritedfromMockFactory.)
SeeAlsoMockRepositoryClassMockRepositoryMembersMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockRepository..::..OfMethodMockRepositoryClassSeeAlsoSendFeedback
OverloadList Name Description
Of<(Of<<'(T>)>>)()()()()Accesstheuniverseofmocksofthegiventype,toretrievethosethatbehaveaccordingtotheLINQqueryspecification.
Of<(Of<<'(T>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
SeeAlsoMockRepositoryClassMockRepositoryMembersMoqNamespace
C#
MoqMockRepository..::..Of<(Of<(<'T>)>)>MethodMockRepositoryClassSeeAlsoSendFeedbackAccesstheuniverseofmocksofthegiventype,toretrievethosethatbehaveaccordingtotheLINQqueryspecification.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
TypeParametersT
Thetypeofthemockedobjecttoquery.
SeeAlsoMockRepositoryClassOfOverloadMoqNamespace
C#
MoqMockRepository..::..Of<(Of<(<'T>)>)>Method(Expression<(Of<(<'Func>)>)>)MockRepositoryClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.MockRepository.Of``1(System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicIQueryable<T>Of<T>(
Expression<Func>specification
)
whereT:class
Parameters
specificationType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersT
SeeAlsoMockRepositoryClassOfOverloadMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockRepository..::..OneOfMethodMockRepositoryClassSeeAlsoSendFeedback
OverloadList Name Description
OneOf<(Of<<'(T>)>>)()()()() Createsanmockobjectoftheindicatedtype.
OneOf<(Of<<'(T>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
SeeAlsoMockRepositoryClassMockRepositoryMembersMoqNamespace
C#
MoqMockRepository..::..OneOf<(Of<(<'T>)>)>MethodMockRepositoryClassSeeAlsoSendFeedbackCreatesanmockobjectoftheindicatedtype.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicTOneOf<T>()
whereT:class
TypeParametersT
Thetypeofthemockedobject.
ReturnValue
Themockedobjectcreated.
SeeAlsoMockRepositoryClassOneOfOverloadMoqNamespace
C#
MoqMockRepository..::..OneOf<(Of<(<'T>)>)>Method(Expression<(Of<(<'Func>)>)>)MockRepositoryClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.MockRepository.OneOf``1(System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicTOneOf<T>(
Expression<Func>specification
)
whereT:class
Parameters
specificationType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersT
SeeAlsoMockRepositoryClassOneOfOverloadMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockRepositoryPropertiesMockRepositoryClassSeeAlsoSendFeedback
TheMockRepositorytypeexposesthefollowingmembers.
Properties Name Description
CallBase
Whetherthebasemembervirtualimplementationwillbecalledformockedclassesifnosetupismatched.DefaultstofalseFalsefalsefalse(FalseinVisualBasic).(InheritedfromMockFactory.)
DefaultValueSpecifiesthebehaviortousewhenreturningdefaultvaluesforunexpectedinvocationsonloosemocks.(InheritedfromMockFactory.)
MocksGetsthemocksthathavebeencreatedbythisfactoryandthatwillgetverifiedtogether.(InheritedfromMockFactory.)
SeeAlsoMockRepositoryClassMoqNamespace
C#
MoqMocksClassMembersSeeAlsoSendFeedbackAllowsqueryingtheuniverseofmocksforthosethatbehaveaccordingtotheLINQqueryspecification.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticclassMocks
InheritanceHierarchySystem..::..ObjectMoq..::..Mocks
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMocksMembersMocksClassMethodsSeeAlsoSendFeedback
Methods Name Description
Of<(Of<<'(T>)>>)()()()()
Accesstheuniverseofmocksofthegiventype,toretrievethosethatbehaveaccordingtotheLINQqueryspecification.
Of<(Of<<'(T>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
OneOf<(Of<<'(T>)>>)()()()()
Obsolete.Createsanmockobjectoftheindicatedtype.
OneOf<(Of<<'(T>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
Obsolete.
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMocksMethodsMocksClassSeeAlsoSendFeedback
Methods Name Description
Of<(Of<<'(T>)>>)()()()()
Accesstheuniverseofmocksofthegiventype,toretrievethosethatbehaveaccordingtotheLINQqueryspecification.
Of<(Of<<'(T>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
OneOf<(Of<<'(T>)>>)()()()()
Obsolete.Createsanmockobjectoftheindicatedtype.
OneOf<(Of<<'(T>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
Obsolete.
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMocks..::..OfMethodMocksClassSeeAlsoSendFeedback
OverloadList Name Description
Of<(Of<<'(T>)>>)()()()()Accesstheuniverseofmocksofthegiventype,toretrievethosethatbehaveaccordingtotheLINQqueryspecification.
Of<(Of<<'(T>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
SeeAlsoMocksClassMocksMembersMoqNamespace
C#
MoqMocks..::..Of<(Of<(<'T>)>)>MethodMocksClassSeeAlsoSendFeedbackAccesstheuniverseofmocksofthegiventype,toretrievethosethatbehaveaccordingtotheLINQqueryspecification.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticIQueryable<T>Of<T>()
whereT:class
TypeParametersT
Thetypeofthemockedobjecttoquery.
SeeAlsoMocksClassOfOverloadMoqNamespace
C#
MoqMocks..::..Of<(Of<(<'T>)>)>Method(Expression<(Of<(<'Func>)>)>)MocksClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Mocks.Of``1(System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticIQueryable<T>Of<T>(
Expression<Func>specification
)
whereT:class
Parameters
specificationType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersT
SeeAlsoMocksClassOfOverloadMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMocks..::..OneOfMethodMocksClassSeeAlsoSendFeedback
OverloadList Name Description
OneOf<(Of<<'(T>)>>)()()()()Obsolete.Createsanmockobjectoftheindicatedtype.
OneOf<(Of<<'(T>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>)) Obsolete.
SeeAlsoMocksClassMocksMembersMoqNamespace
C#
MoqMocks..::..OneOf<(Of<(<'T>)>)>MethodMocksClassSeeAlsoSendFeedbackCreatesanmockobjectoftheindicatedtype.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
[ObsoleteAttribute("MovedtoMock.Of<T>,asit'sasingleone,sonoreasontobeonMocks.",
true)]
publicstaticTOneOf<T>()
whereT:class
TypeParametersT
Thetypeofthemockedobject.
ReturnValue
Themockedobjectcreated.
SeeAlsoMocksClassOneOfOverloadMoqNamespace
C#
MoqMocks..::..OneOf<(Of<(<'T>)>)>Method(Expression<(Of<(<'Func>)>)>)MocksClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Mocks.OneOf``1(System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
[ObsoleteAttribute("MovedtoMock.Of<T>,asit'sasingleone,sonoreasontobeonMocks.",
true)]
publicstaticTOneOf<T>(
Expression<Func>specification
)
whereT:class
Parameters
specificationType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersT
SeeAlsoMocksClassOneOfOverloadMoqNamespace
C#
MoqMockSequenceClassMembersSeeAlsoSendFeedbackHelperclasstosetupafulltracebetweenmanymocks
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicclassMockSequence
InheritanceHierarchySystem..::..ObjectMoq..::..MockSequence
SeeAlsoMockSequenceMembersMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockSequenceMembersMockSequenceClassConstructorsPropertiesSeeAlsoSendFeedback
TheMockSequencetypeexposesthefollowingmembers.
Constructors Name DescriptionMockSequence Initializeatracesetup
Properties Name DescriptionCyclic Allowsequencetoberepeated
SeeAlsoMockSequenceClassMoqNamespace
C#
MoqMockSequenceConstructorMockSequenceClassSeeAlsoSendFeedbackInitializeatracesetup
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicMockSequence()
SeeAlsoMockSequenceClassMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockSequencePropertiesMockSequenceClassSeeAlsoSendFeedback
TheMockSequencetypeexposesthefollowingmembers.
Properties Name DescriptionCyclic Allowsequencetoberepeated
SeeAlsoMockSequenceClassMoqNamespace
C#
MoqMockSequence..::..CyclicPropertyMockSequenceClassSeeAlsoSendFeedbackAllowsequencetoberepeated
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SeeAlsoMockSequenceClassMoqNamespace
C#
MoqMockSequenceHelperClassMembersSeeAlsoSendFeedbackdefineniceapi
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticclassMockSequenceHelper
InheritanceHierarchySystem..::..ObjectMoq..::..MockSequenceHelper
SeeAlsoMockSequenceHelperMembersMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockSequenceHelperMembersMockSequenceHelperClassMethodsSeeAlsoSendFeedback
TheMockSequenceHelpertypeexposesthefollowingmembers.
Methods Name Description
InSequence<(Of<<'(TMock>)>>) Performanexpectationinthetrace.
SeeAlsoMockSequenceHelperClassMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqMockSequenceHelperMethodsMockSequenceHelperClassSeeAlsoSendFeedback
TheMockSequenceHelpertypeexposesthefollowingmembers.
Methods Name Description
InSequence<(Of<<'(TMock>)>>) Performanexpectationinthetrace.
SeeAlsoMockSequenceHelperClassMoqNamespace
C#
MoqMockSequenceHelper..::..InSequence<(Of<(<'TMock>)>)>MethodMockSequenceHelperClassSeeAlsoSendFeedbackPerformanexpectationinthetrace.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticISetupConditionResult<TMock>InSequence<TMock>(
thisMock<TMock>mock,
MockSequencesequence
)
whereTMock:class
Parameters
mockType:Moq..::..Mock<(Of<(<'TMock>)>)>
sequenceType:Moq..::..MockSequence
TypeParametersTMock
SeeAlsoMockSequenceHelperClassMoqNamespace
C#
MoqRangeEnumerationSeeAlsoSendFeedbackKindofrangetouseinafilterspecifiedthroughIsInRange<(Of<<'(TValue>)>>)(TValue,TValue,Range).
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicenumRange
MembersMembername DescriptionInclusiveExclusive
C#
MoqSequenceExtensionsClassMembersSeeAlsoSendFeedbackHelperforsequencingreturnvaluesinthesamemethod.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticclassSequenceExtensions
InheritanceHierarchySystem..::..ObjectMoq..::..SequenceExtensions
SeeAlsoSequenceExtensionsMembersMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqSequenceExtensionsMembersSequenceExtensionsClassMethodsSeeAlsoSendFeedback
TheSequenceExtensionstypeexposesthefollowingmembers.
Methods Name Description
SetupSequence<(Of<<'(TMock,TResult>)>>)
SeeAlsoSequenceExtensionsClassMoqNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqSequenceExtensionsMethodsSequenceExtensionsClassSeeAlsoSendFeedback
TheSequenceExtensionstypeexposesthefollowingmembers.
Methods Name Description
SetupSequence<(Of<<'(TMock,TResult>)>>)
SeeAlsoSequenceExtensionsClassMoqNamespace
C#
MoqSequenceExtensions..::..SetupSequence<(Of<(<'TMock,TResult>)>)>MethodSequenceExtensionsClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.SequenceExtensions.SetupSequence``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticISetupSequentialResult<TResult>SetupSequence<TMock,TResult>(
thisMock<TMock>mock,
Expression<Func>expression
)
whereTMock:class
Parameters
mockType:Moq..::..Mock<(Of<(<'TMock>)>)>
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersTMockTResult
SeeAlsoSequenceExtensionsClassMoqNamespace
C#
MoqTimesStructureMembersSeeAlsoSendFeedbackDefinesthenumberofinvocationsallowedbyamockedmethod.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstructTimes
C#IncludeProtectedMembersIncludeInheritedMembers
MoqTimesMembersTimesStructureMethodsOperatorsSeeAlsoSendFeedback
TheTimestypeexposesthefollowingmembers.
Methods Name Description
AtLeast SpecifiesthatamockedmethodshouldbeinvokedcallCounttimesasminimum.
AtLeastOnce Specifiesthatamockedmethodshouldbeinvokedonetimeasminimum.
AtMost SpecifiesthatamockedmethodshouldbeinvokedcallCounttimeasmaximun.
AtMostOnce Specifiesthatamockedmethodshouldbeinvokedonetimeasmaximun.
Between SpecifiesthatamockedmethodshouldbeinvokedbetweencallCountFromandcallCountTotimes.
EqualsDetermineswhetherthespecifiedObjectisequaltothisinstance.(OverridesValueType..::..Equals(Object).)
Exactly SpecifiesthatamockedmethodshouldbeinvokedexactlycallCounttimes.
GetHashCode Returnsahashcodeforthisinstance.(OverridesValueType..::..GetHashCode()()()().)Never Specifiesthatamockedmethodshouldnotbeinvoked.
Once Specifiesthatamockedmethodshouldbeinvokedexactlyonetime.
Operators Name Description
Equality DetermineswhethertwospecifiedTimesobjectshavethesamevalue.
Inequality DetermineswhethertwospecifiedTimesobjectshavedifferentvalues.
C#IncludeProtectedMembersIncludeInheritedMembers
MoqTimesMethodsTimesStructureSeeAlsoSendFeedback
TheTimestypeexposesthefollowingmembers.
Methods Name Description
AtLeast SpecifiesthatamockedmethodshouldbeinvokedcallCounttimesasminimum.
AtLeastOnce Specifiesthatamockedmethodshouldbeinvokedonetimeasminimum.
AtMost SpecifiesthatamockedmethodshouldbeinvokedcallCounttimeasmaximun.
AtMostOnce Specifiesthatamockedmethodshouldbeinvokedonetimeasmaximun.
Between SpecifiesthatamockedmethodshouldbeinvokedbetweencallCountFromandcallCountTotimes.
EqualsDetermineswhetherthespecifiedObjectisequaltothisinstance.(OverridesValueType..::..Equals(Object).)
Exactly SpecifiesthatamockedmethodshouldbeinvokedexactlycallCounttimes.
GetHashCode Returnsahashcodeforthisinstance.(OverridesValueType..::..GetHashCode()()()().)Never Specifiesthatamockedmethodshouldnotbeinvoked.
Once Specifiesthatamockedmethodshouldbeinvokedexactlyonetime.
C#
MoqTimes..::..AtLeastMethodTimesStructureSeeAlsoSendFeedbackSpecifiesthatamockedmethodshouldbeinvokedcallCounttimesasminimum.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticTimesAtLeast(
intcallCount
)
Parameters
callCountType:System..::..Int32Theminimunnumberoftimes.
ReturnValue
Anobjectdefiningtheallowednumberofinvocations.
C#
MoqTimes..::..AtLeastOnceMethodTimesStructureSeeAlsoSendFeedbackSpecifiesthatamockedmethodshouldbeinvokedonetimeasminimum.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticTimesAtLeastOnce()
ReturnValue
Anobjectdefiningtheallowednumberofinvocations.
C#
MoqTimes..::..AtMostMethodTimesStructureSeeAlsoSendFeedbackSpecifiesthatamockedmethodshouldbeinvokedcallCounttimeasmaximun.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticTimesAtMost(
intcallCount
)
Parameters
callCountType:System..::..Int32Themaximunnumberoftimes.
ReturnValue
Anobjectdefiningtheallowednumberofinvocations.
C#
MoqTimes..::..AtMostOnceMethodTimesStructureSeeAlsoSendFeedbackSpecifiesthatamockedmethodshouldbeinvokedonetimeasmaximun.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticTimesAtMostOnce()
ReturnValue
Anobjectdefiningtheallowednumberofinvocations.
C#
MoqTimes..::..BetweenMethodTimesStructureSeeAlsoSendFeedbackSpecifiesthatamockedmethodshouldbeinvokedbetweencallCountFromandcallCountTotimes.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticTimesBetween(
intcallCountFrom,
intcallCountTo,
RangerangeKind
)
Parameters
callCountFromType:System..::..Int32Theminimunnumberoftimes.
callCountToType:System..::..Int32Themaximunnumberoftimes.
rangeKindType:Moq..::..RangeThekindofrange.SeeRange.
ReturnValue
Anobjectdefiningtheallowednumberofinvocations.
C#
MoqTimes..::..EqualsMethodTimesStructureSeeAlsoSendFeedbackDetermineswhetherthespecifiedObjectisequaltothisinstance.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicoverrideboolEquals(
Objectobj
)
Parameters
objType:System..::..ObjectTheObjecttocomparewiththisinstance.
ReturnValue
trueifthespecifiedObjectisequaltothisinstance;otherwise,false.
C#
MoqTimes..::..ExactlyMethodTimesStructureSeeAlsoSendFeedbackSpecifiesthatamockedmethodshouldbeinvokedexactlycallCounttimes.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticTimesExactly(
intcallCount
)
Parameters
callCountType:System..::..Int32Thetimesthatamethodorpropertycanbecalled.
ReturnValue
Anobjectdefiningtheallowednumberofinvocations.
C#
MoqTimes..::..GetHashCodeMethodTimesStructureSeeAlsoSendFeedbackReturnsahashcodeforthisinstance.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicoverrideintGetHashCode()
ReturnValue
Ahashcodeforthisinstance,suitableforuseinhashingalgorithmsanddatastructureslikeahashtable.
C#
MoqTimes..::..NeverMethodTimesStructureSeeAlsoSendFeedbackSpecifiesthatamockedmethodshouldnotbeinvoked.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticTimesNever()
ReturnValue
Anobjectdefiningtheallowednumberofinvocations.
C#
MoqTimes..::..OnceMethodTimesStructureSeeAlsoSendFeedbackSpecifiesthatamockedmethodshouldbeinvokedexactlyonetime.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticTimesOnce()
ReturnValue
Anobjectdefiningtheallowednumberofinvocations.
C#IncludeProtectedMembersIncludeInheritedMembers
MoqTimesOperatorsTimesStructureSeeAlsoSendFeedback
TheTimestypeexposesthefollowingmembers.
Operators Name Description
Equality DetermineswhethertwospecifiedTimesobjectshavethesamevalue.
Inequality DetermineswhethertwospecifiedTimesobjectshavedifferentvalues.
C#
MoqTimes..::..EqualityOperatorTimesStructureSeeAlsoSendFeedbackDetermineswhethertwospecifiedTimesobjectshavethesamevalue.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticbooloperator==(
Timesleft,
Timesright
)
Parameters
leftType:Moq..::..TimesThefirstTimes.
rightType:Moq..::..TimesThesecondTimes.
ReturnValue
trueifthevalueofleftisthesameasthevalueofright;otherwise,false.
C#
MoqTimes..::..InequalityOperatorTimesStructureSeeAlsoSendFeedbackDetermineswhethertwospecifiedTimesobjectshavedifferentvalues.
Namespace:MoqAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticbooloperator!=(
Timesleft,
Timesright
)
Parameters
leftType:Moq..::..TimesThefirstTimes.
rightType:Moq..::..TimesThesecondTimes.
ReturnValue
trueifthevalueofleftisdifferentfromthevalueofright;otherwise,false.
C#
MoqMoq.LanguageNamespaceSendFeedbackThisnamespacedefinestheinterfacesthatcontainthemethodsavailableinMoqfluentAPI,suchasSetup,Callback,Returns,Throws,etc.
Reviewthedocumentationoftheavailablemethodsontheseinterfacesforcodeexamples.Thewaytheseinterfacesarecomposed,groupedandmadevisibleatdifferentstagesduringanexpectation(i.e.Verifiableisthelast"verb"andcan'tbespecifiedbeforetheReturns)isinternalbuttheAPIwillnaturallyleadyoutotheproperwayofusingit,sodon'tworrytoomuchaboutwho(andwhere)exposestheselanguageinterfaces.TheywillshowupinIntellisensewhenit'sappropriate.
Dousetheirdocumentationtolearnaboutoptions(especiallywhenthereareseveraloverloadsavailable)thatmaybeabetterfitforaparticularscenario.
Interfaces Interface Description
ICallback DefinestheCallbackverbandoverloads.ICallback<(Of<(<'TMock,TResult>)>)>
DefinestheCallbackverbandoverloadsforcallbacksonsetupsthatreturnavalue.
ICallbackGetter<(Of<(<'TMock,TProperty>)>)>
DefinestheCallbackverbforpropertygettersetups.
ICallbackSetter<(Of<(<'TProperty>)>)>
DefinestheCallbackverbforpropertysettersetups.
IRaise<(Of<(<'T>)>)> DefinestheRaisesverb.IReturns<(Of<(<'TMock,TResult>)>)> DefinestheReturnsverb.
IReturnsGetter<(Of<(<'TMock,TProperty>)>)>
DefinestheReturnsverbforpropertygetsetups.
ISetupConditionResult<(Of<(<'T>)>)> ImplementsthefluentAPI.
ISetupSequentialResult<(Of<(<'TResult>)>)> LanguageforReturnSequence
IThrows DefinestheThrowsverb.IVerifies DefinestheVerifiableverb.
C#
MoqICallbackInterfaceMembersSeeAlsoSendFeedbackDefinestheCallbackverbandoverloads.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicinterfaceICallback:IHideObjectMembers
SeeAlsoICallbackMembersMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqICallbackMembersICallbackInterfaceMethodsSeeAlsoSendFeedback
Methods Name Description
Callback(Action)Specifiesacallbacktoinvokewhenthemethodiscalled.
Callback<(Of<<'(T>)>>)(Action<(Of<<'(T>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginal
arguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2>)>>)(Action<(Of<(<'T1,T2>)>)>)Callback<(Of<<'(T1,T2,T3>)>>)(Action<(Of<(<'T1,T2,T3>)>)>)Callback<(Of<<'(T1,T2,T3,T4>)>>)(Action<(Of<(<'T1,T2,T3,T4>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8>)>)>)
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
SeeAlsoICallbackInterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqICallbackMethodsICallbackInterfaceSeeAlsoSendFeedback
Methods Name Description
Callback(Action)Specifiesacallbacktoinvokewhenthemethodiscalled.
Callback<(Of<<'(T>)>>)(Action<(Of<<'(T>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginal
arguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2>)>>)(Action<(Of<(<'T1,T2>)>)>)Callback<(Of<<'(T1,T2,T3>)>>)(Action<(Of<(<'T1,T2,T3>)>)>)Callback<(Of<<'(T1,T2,T3,T4>)>>)(Action<(Of<(<'T1,T2,T3,T4>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8>)>)>)
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
SeeAlsoICallbackInterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqICallback..::..CallbackMethodICallbackInterfaceSeeAlsoSendFeedback
OverloadList Name Description
Callback(Action)Specifiesacallbacktoinvokewhenthemethodiscalled.
Callback<(Of<<'(T>)>>)(Action<(Of<<'(T>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginal
arguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2>)>>)(Action<(Of<(<'T1,T2>)>)>)Callback<(Of<<'(T1,T2,T3>)>>)(Action<(Of<(<'T1,T2,T3>)>)>)Callback<(Of<<'(T1,T2,T3,T4>)>>)(Action<(Of<(<'T1,T2,T3,T4>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8>)>)>)
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
SeeAlsoICallbackInterfaceICallbackMembersMoq.LanguageNamespace
C#
MoqICallback..::..CallbackMethod(Action)ICallbackInterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalled.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback(
Actionaction
)
Parameters
actionType:System..::..ActionThecallbackmethodtoinvoke.
Copy
ExamplesThefollowingexamplespecifiesacallbacktosetabooleanvaluethatcanbeusedlater:
C#
varcalled=false;
mock.Setup(x=>x.Execute())
.Callback(()=>called=true);
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T>)>)>Method(Action<(Of<(<'T>)>)>)ICallbackInterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T>(
Action<T>action
)
Parameters
actionType:System..::..Action<(Of<(<'T>)>)>Thecallbackmethodtoinvoke.
TypeParametersT
Theargumenttypeoftheinvokedmethod.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentvalue.
Noticehowthespecificstringargumentisretrievedbysimplydeclaringitaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(It.IsAny<string>()))
.Callback((stringcommand)=>Console.WriteLine(command));
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>)>)ICallbackInterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>action
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.
ReturnValue
AreferencetoICallbackResultinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>)>)ICallbackInterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>action
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.
ReturnValue
AreferencetoICallbackResultinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>)>)ICallbackInterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>action
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.T12
Thetypeofthetwelfthargumentoftheinvokedmethod.
ReturnValue
AreferencetoICallbackResultinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>)>)ICallbackInterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.T12
Thetypeofthetwelfthargumentoftheinvokedmethod.T13
Thetypeofthethirteenthargumentoftheinvokedmethod.
ReturnValue
AreferencetoICallbackResultinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>)>)ICallbackInterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.T12
Thetypeofthetwelfthargumentoftheinvokedmethod.T13
Thetypeofthethirteenthargumentoftheinvokedmethod.T14
Thetypeofthefourteenthargumentoftheinvokedmethod.
ReturnValue
AreferencetoICallbackResultinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>)>)ICallbackInterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.T12
Thetypeofthetwelfthargumentoftheinvokedmethod.T13
Thetypeofthethirteenthargumentoftheinvokedmethod.T14
Thetypeofthefourteenthargumentoftheinvokedmethod.T15
Thetypeofthefifteenthargumentoftheinvokedmethod.
ReturnValue
AreferencetoICallbackResultinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>)>)ICallbackInterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.T12
Thetypeofthetwelfthargumentoftheinvokedmethod.T13
Thetypeofthethirteenthargumentoftheinvokedmethod.T14
Thetypeofthefourteenthargumentoftheinvokedmethod.T15
Thetypeofthefifteenthargumentoftheinvokedmethod.T16
Thetypeofthesixteenthargumentoftheinvokedmethod.
ReturnValue
AreferencetoICallbackResultinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T1,T2>)>)>Method(Action)ICallbackInterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ICallback.Callback``2(System.Action`2)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T1,T2>(
Actionaction
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2>)>)>
TypeParametersT1T2
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T1,T2,T3>)>)>Method(Action)ICallbackInterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ICallback.Callback``3(System.Action`3)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T1,T2,T3>(
Actionaction
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3>)>)>
TypeParametersT1T2T3
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T1,T2,T3,T4>)>)>Method(Action)ICallbackInterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ICallback.Callback``4(System.Action`4)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T1,T2,T3,T4>(
Actionaction
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4>)>)>
TypeParametersT1T2T3T4
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T1,T2,T3,T4,T5>)>)>Method(Action)ICallbackInterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ICallback.Callback``5(System.Action`5)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T1,T2,T3,T4,T5>(
Actionaction
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5>)>)>
TypeParametersT1T2T3T4T5
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6>)>)>Method(Action)ICallbackInterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ICallback.Callback``6(System.Action`6)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T1,T2,T3,T4,T5,T6>(
Actionaction
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6>)>)>
TypeParametersT1T2T3T4T5T6
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7>)>)>Method(Action)ICallbackInterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ICallback.Callback``7(System.Action`7)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T1,T2,T3,T4,T5,T6,T7>(
Actionaction
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7>)>)>
TypeParametersT1T2T3T4T5T6T7
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8>)>)>Method(Action)ICallbackInterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ICallback.Callback``8(System.Action`8)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T1,T2,T3,T4,T5,T6,T7,T8>(
Actionaction
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8>)>)>
TypeParametersT1T2T3T4T5T6T7T8
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9>)>)>)ICallbackInterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback<T1,T2,T3,T4,T5,T6,T7,T8,T9>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9>action
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.
ReturnValue
AreferencetoICallbackResultinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoICallbackInterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>InterfaceMembersSeeAlsoSendFeedbackDefinestheCallbackverbandoverloadsforcallbacksonsetupsthatreturnavalue.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicinterfaceICallback<TMock,TResult>:IHideObjectMembers
whereTMock:class
TypeParametersTMock
Mockedtype.TResult
Typeofthereturnvalueofthesetup.
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>MembersMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqICallback<(Of<(<'TMock,TResult>)>)>MembersICallback<(Of<(<'TMock,TResult>)>)>InterfaceMethodsSeeAlsoSendFeedback
Methods Name Description
Callback(Action)Specifiesacallbacktoinvokewhenthemethodiscalled.
Callback<(Of<<'(T>)>>)(Action<(Of<<'(T>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginal
arguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2>)>>)(Action<(Of<(<'T1,T2>)>)>)Callback<(Of<<'(T1,T2,T3>)>>)(Action<(Of<(<'T1,T2,T3>)>)>)Callback<(Of<<'(T1,T2,T3,T4>)>>)(Action<(Of<(<'T1,T2,T3,T4>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8>)>)>)
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqICallback<(Of<(<'TMock,TResult>)>)>MethodsICallback<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
Methods Name Description
Callback(Action)Specifiesacallbacktoinvokewhenthemethodiscalled.
Callback<(Of<<'(T>)>>)(Action<(Of<<'(T>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginal
arguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2>)>>)(Action<(Of<(<'T1,T2>)>)>)Callback<(Of<<'(T1,T2,T3>)>>)(Action<(Of<(<'T1,T2,T3>)>)>)Callback<(Of<<'(T1,T2,T3,T4>)>>)(Action<(Of<(<'T1,T2,T3,T4>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8>)>)>)
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..CallbackMethodICallback<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
OverloadList Name Description
Callback(Action)Specifiesacallbacktoinvokewhenthemethodiscalled.
Callback<(Of<<'(T>)>>)(Action<(Of<<'(T>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginal
arguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Callback<(Of<<'(T1,T2>)>>)(Action<(Of<(<'T1,T2>)>)>)Callback<(Of<<'(T1,T2,T3>)>>)(Action<(Of<(<'T1,T2,T3>)>)>)Callback<(Of<<'(T1,T2,T3,T4>)>>)(Action<(Of<(<'T1,T2,T3,T4>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7>)>)>)Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8>)>>)(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8>)>)>)
Callback<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>)(Action<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>))
Specifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceICallback<(Of<(<'TMock,TResult>)>)>MembersMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..CallbackMethod(Action)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalled.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback(
Actionaction
)
Parameters
actionType:System..::..ActionThecallbackmethodtoinvoke.
Copy
ExamplesThefollowingexamplespecifiesacallbacktosetabooleanvaluethatcanbeusedlater:
C#
varcalled=false;
mock.Setup(x=>x.Execute())
.Callback(()=>called=true)
.Returns(true);
Notethatinthecaseofvalue-returningmethods,aftertheCallbackcallyoucanstillspecifythereturnvalue.
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T>)>)>Method(Action<(Of<(<'T>)>)>)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T>(
Action<T>action
)
Parameters
actionType:System..::..Action<(Of<(<'T>)>)>Callbackmethodtoinvoke.
TypeParametersT
Thetypeoftheargumentoftheinvokedmethod.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentvalue.
Noticehowthespecificstringargumentisretrievedbysimplydeclaringitaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(It.IsAny<string>()))
.Callback(command=>Console.WriteLine(command))
.Returns(true);
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>)>)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>action
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.
ReturnValue
AreferencetoIReturnsThrowsinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)=>Console.WriteLine(arg1+arg2+arg3+arg4+arg5+arg6+arg7+arg8+arg9+arg10));
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>)>)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>action
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.
ReturnValue
AreferencetoIReturnsThrowsinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11)=>Console.WriteLine(arg1+arg2+arg3+arg4+arg5+arg6+arg7+arg8+arg9+arg10+arg11));
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>)>)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>action
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.T12
Thetypeofthetwelfthargumentoftheinvokedmethod.
ReturnValue
AreferencetoIReturnsThrowsinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12)=>Console.WriteLine(arg1+arg2+arg3+arg4+arg5+arg6+arg7+arg8+arg9+arg10+arg11+arg12));
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>)>)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.T12
Thetypeofthetwelfthargumentoftheinvokedmethod.T13
Thetypeofthethirteenthargumentoftheinvokedmethod.
ReturnValue
AreferencetoIReturnsThrowsinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13)=>Console.WriteLine(arg1+arg2+arg3+arg4+arg5+arg6+arg7+arg8+arg9+arg10+arg11+arg12+arg13));
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>)>)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.T12
Thetypeofthetwelfthargumentoftheinvokedmethod.T13
Thetypeofthethirteenthargumentoftheinvokedmethod.T14
Thetypeofthefourteenthargumentoftheinvokedmethod.
ReturnValue
AreferencetoIReturnsThrowsinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14)=>Console.WriteLine(arg1+arg2+arg3+arg4+arg5+arg6+arg7+arg8+arg9+arg10+arg11+arg12+arg13+arg14));
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>)>)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.T12
Thetypeofthetwelfthargumentoftheinvokedmethod.T13
Thetypeofthethirteenthargumentoftheinvokedmethod.T14
Thetypeofthefourteenthargumentoftheinvokedmethod.T15
Thetypeofthefifteenthargumentoftheinvokedmethod.
ReturnValue
AreferencetoIReturnsThrowsinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15)=>Console.WriteLine(arg1+arg2+arg3+arg4+arg5+arg6+arg7+arg8+arg9+arg10+arg11+arg12+arg13+arg14+arg15));
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>)>)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.T12
Thetypeofthetwelfthargumentoftheinvokedmethod.T13
Thetypeofthethirteenthargumentoftheinvokedmethod.T14
Thetypeofthefourteenthargumentoftheinvokedmethod.T15
Thetypeofthefifteenthargumentoftheinvokedmethod.T16
Thetypeofthesixteenthargumentoftheinvokedmethod.
ReturnValue
AreferencetoIReturnsThrowsinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15,arg16)=>Console.WriteLine(arg1+arg2+arg3+arg4+arg5+arg6+arg7+arg8+arg9+arg10+arg11+arg12+arg13+arg14+arg15+arg16));
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T1,T2>)>)>Method(Action)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ICallback`2.Callback``2(System.Action`2)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T1,T2>(
Actionaction
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2>)>)>
TypeParametersT1T2
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T1,T2,T3>)>)>Method(Action)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ICallback`2.Callback``3(System.Action`3)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T1,T2,T3>(
Actionaction
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3>)>)>
TypeParametersT1T2T3
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T1,T2,T3,T4>)>)>Method(Action)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ICallback`2.Callback``4(System.Action`4)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T1,T2,T3,T4>(
Actionaction
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4>)>)>
TypeParametersT1T2T3T4
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T1,T2,T3,T4,T5>)>)>Method(Action)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ICallback`2.Callback``5(System.Action`5)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T1,T2,T3,T4,T5>(
Actionaction
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5>)>)>
TypeParametersT1T2T3T4T5
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6>)>)>Method(Action)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ICallback`2.Callback``6(System.Action`6)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T1,T2,T3,T4,T5,T6>(
Actionaction
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6>)>)>
TypeParametersT1T2T3T4T5T6
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7>)>)>Method(Action)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ICallback`2.Callback``7(System.Action`7)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T1,T2,T3,T4,T5,T6,T7>(
Actionaction
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7>)>)>
TypeParametersT1T2T3T4T5T6T7
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8>)>)>Method(Action)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ICallback`2.Callback``8(System.Action`8)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T1,T2,T3,T4,T5,T6,T7,T8>(
Actionaction
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8>)>)>
TypeParametersT1T2T3T4T5T6T7T8
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallback<(Of<(<'TMock,TResult>)>)>..::..Callback<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9>)>)>Method(Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9>)>)>)ICallback<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthemethodiscalledthatreceivestheoriginalarguments.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrows<TMock,TResult>Callback<T1,T2,T3,T4,T5,T6,T7,T8,T9>(
Action<T1,T2,T3,T4,T5,T6,T7,T8,T9>action
)
Parameters
actionType:System..::..Action<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9>)>)>Thecallbackmethodtoinvoke.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.
ReturnValue
AreferencetoIReturnsThrowsinterface.
Copy
ExamplesInvokesthegivencallbackwiththeconcreteinvocationargumentsvalues.
Noticehowthespecificargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpressionforthecallback:
C#
mock.Setup(x=>x.Execute(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>()))
.Callback((arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)=>Console.WriteLine(arg1+arg2+arg3+arg4+arg5+arg6+arg7+arg8+arg9));
SeeAlsoICallback<(Of<(<'TMock,TResult>)>)>InterfaceCallbackOverloadMoq.LanguageNamespace
C#
MoqICallbackGetter<(Of<(<'TMock,TProperty>)>)>InterfaceMembersSeeAlsoSendFeedbackDefinestheCallbackverbforpropertygettersetups.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicinterfaceICallbackGetter<TMock,TProperty>:IHideObjectMembers
whereTMock:class
TypeParametersTMock
Mockedtype.TProperty
Typeoftheproperty.
SeeAlsoICallbackGetter<(Of<(<'TMock,TProperty>)>)>MembersMoq.LanguageNamespaceMockSetupGet``1(Expression<(Of<<'(Func<(Of<<'(UTP,UMP>)>>)>)>>))
C#IncludeProtectedMembersIncludeInheritedMembers
MoqICallbackGetter<(Of<(<'TMock,TProperty>)>)>MembersICallbackGetter<(Of<(<'TMock,TProperty>)>)>InterfaceMethodsSeeAlsoSendFeedback
TheICallbackGetter<(Of<(<'TMock,TProperty>)>)>typeexposesthefollowingmembers.
Methods Name Description
Callback Specifiesacallbacktoinvokewhenthepropertyisretrieved.
SeeAlsoICallbackGetter<(Of<(<'TMock,TProperty>)>)>InterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqICallbackGetter<(Of<(<'TMock,TProperty>)>)>MethodsICallbackGetter<(Of<(<'TMock,TProperty>)>)>InterfaceSeeAlsoSendFeedback
TheICallbackGetter<(Of<(<'TMock,TProperty>)>)>typeexposesthefollowingmembers.
Methods Name Description
Callback Specifiesacallbacktoinvokewhenthepropertyisretrieved.
SeeAlsoICallbackGetter<(Of<(<'TMock,TProperty>)>)>InterfaceMoq.LanguageNamespace
C#
MoqICallbackGetter<(Of<(<'TMock,TProperty>)>)>..::..CallbackMethodICallbackGetter<(Of<(<'TMock,TProperty>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthepropertyisretrieved.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsThrowsGetter<TMock,TProperty>Callback(
Actionaction
)
Parameters
actionType:System..::..ActionCallbackmethodtoinvoke.
Copy
ExamplesInvokesthegivencallbackwiththepropertyvaluebeingset.
C#
mock.SetupGet(x=>x.Suspended)
.Callback(()=>called=true)
.Returns(true);
SeeAlsoICallbackGetter<(Of<(<'TMock,TProperty>)>)>InterfaceMoq.LanguageNamespace
C#
MoqICallbackSetter<(Of<(<'TProperty>)>)>InterfaceMembersSeeAlsoSendFeedbackDefinestheCallbackverbforpropertysettersetups.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicinterfaceICallbackSetter<TProperty>:IHideObjectMembers
TypeParametersTProperty
Typeoftheproperty.
SeeAlsoICallbackSetter<(Of<(<'TProperty>)>)>MembersMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqICallbackSetter<(Of<(<'TProperty>)>)>MembersICallbackSetter<(Of<(<'TProperty>)>)>InterfaceMethodsSeeAlsoSendFeedback
TheICallbackSetter<(Of<(<'TProperty>)>)>typeexposesthefollowingmembers.
Methods Name Description
Callback Specifiesacallbacktoinvokewhenthepropertyissetthatreceivesthepropertyvaluebeingset.
SeeAlsoICallbackSetter<(Of<(<'TProperty>)>)>InterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqICallbackSetter<(Of<(<'TProperty>)>)>MethodsICallbackSetter<(Of<(<'TProperty>)>)>InterfaceSeeAlsoSendFeedback
TheICallbackSetter<(Of<(<'TProperty>)>)>typeexposesthefollowingmembers.
Methods Name Description
Callback Specifiesacallbacktoinvokewhenthepropertyissetthatreceivesthepropertyvaluebeingset.
SeeAlsoICallbackSetter<(Of<(<'TProperty>)>)>InterfaceMoq.LanguageNamespace
C#
MoqICallbackSetter<(Of<(<'TProperty>)>)>..::..CallbackMethodICallbackSetter<(Of<(<'TProperty>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesacallbacktoinvokewhenthepropertyissetthatreceivesthepropertyvaluebeingset.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ICallbackResultCallback(
Action<TProperty>action
)
Parameters
actionType:System..::..Action<(Of<(<'TProperty>)>)>Callbackmethodtoinvoke.
Copy
ExamplesInvokesthegivencallbackwiththepropertyvaluebeingset.
C#
mock.SetupSet(x=>x.Suspended)
.Callback((boolstate)=>Console.WriteLine(state));
SeeAlsoICallbackSetter<(Of<(<'TProperty>)>)>InterfaceMoq.LanguageNamespace
C#
MoqIRaise<(Of<(<'T>)>)>InterfaceMembersSeeAlsoSendFeedbackDefinestheRaisesverb.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicinterfaceIRaise<T>:IHideObjectMembers
TypeParametersT
SeeAlsoIRaise<(Of<(<'T>)>)>MembersMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIRaise<(Of<(<'T>)>)>MembersIRaise<(Of<(<'T>)>)>InterfaceMethodsSeeAlsoSendFeedback
Methods Name Description
Raises(Action<(Of<<'(T>)>>),EventArgs)
Specifiestheeventthatwillberaisedwhenthesetupismet.
Raises(Action<(Of<<'(T>)>>),Func<(Of<(<'TResult>)>)>)
Raises(Action<(Of<<'(T>)>>),array<Object>[]()[][])
Specifiesthecustomeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>)(Action<(Of Specifiesthe
<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,EventArgs>)>>))
eventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,TResult>)>)>)Raises<(Of<<'(T1,T2,T3>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,T4,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4,T5>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,T4,T5,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4,T5,T6>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,T4,T5,T6,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,TResult>)>)>)
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIRaise<(Of<(<'T>)>)>MethodsIRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
Methods Name Description
Raises(Action<(Of<<'(T>)>>),EventArgs)
Specifiestheeventthatwillberaisedwhenthesetupismet.
Raises(Action<(Of<<'(T>)>>),Func<(Of<(<'TResult>)>)>)
Raises(Action<(Of<<'(T>)>>),array<Object>[]()[][])
Specifiesthecustomeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>)(Action<(Of Specifiesthe
<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,EventArgs>)>>))
eventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,TResult>)>)>)Raises<(Of<<'(T1,T2,T3>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,T4,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4,T5>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,T4,T5,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4,T5,T6>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,T4,T5,T6,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,TResult>)>)>)
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIRaise<(Of<(<'T>)>)>..::..RaisesMethodIRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
OverloadList Name Description
Raises(Action<(Of<<'(T>)>>),EventArgs)
Specifiestheeventthatwillberaisedwhenthesetupismet.
Raises(Action<(Of<<'(T>)>>),Func<(Of<(<'TResult>)>)>)
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>)(Action<(Of<<'(T>)>>),Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,EventArgs>)>>))
Specifiestheeventthatwillberaisedwhenthesetupismatched.
Raises<(Of<<'(T1>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T,TResult>)>)>)Raises<(Of<<'(T1,T2>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,TResult>)>)>)Raises<(Of<<'(T1,T2,T3>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,T4,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4,T5>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,T4,T5,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4,T5,T6>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,T4,T5,T6,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,TResult>)>)>)Raises<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8>)>>)(Action<(Of<<'(T>)>>),Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,TResult>)>)>)
Raises(Action<(Of<<'(T>)>>),array<Object>[]()[][])
Specifiesthecustomeventthatwillberaisedwhenthesetupismatched.
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceIRaise<(Of<(<'T>)>)>MembersMoq.LanguageNamespace
C#
MoqIRaise<(Of<(<'T>)>)>..::..RaisesMethod(Action<(Of<(<'T>)>)>,EventArgs)IRaise<(Of<(<'T>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiestheeventthatwillberaisedwhenthesetupismet.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises(
Action<T>eventExpression,
EventArgsargs
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>Anexpressionthatrepresentsaneventattachordetachaction.
argsType:System..::..EventArgsTheeventargumentstopassfortheraisedevent.
Copy
ExamplesThefollowingexampleshowshowtoraiseaneventwhenthesetupismet:
C#
varmock=newMock<IContainer>();
mock.Setup(add=>add.Add(It.IsAny<string>(),It.IsAny<object>()))
.Raises(add=>add.Added+=null,EventArgs.Empty);
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespace
C#
MoqIRaise<(Of<(<'T>)>)>..::..RaisesMethod(Action<(Of<(<'T>)>)>,Func)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IRaise`1.Raises(System.Action{`0},System.Func`1)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises(
Action<T>eventExpression,
Funcfunc
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>
funcType:System..::..Func<(Of<(<'TResult>)>)>
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespace
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9>)>)>Method(Action<(Of<(<'T>)>)>,Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,EventArgs>)>)>)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedbackSpecifiestheeventthatwillberaisedwhenthesetupismatched.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1,T2,T3,T4,T5,T6,T7,T8,T9>(
Action<T>eventExpression,
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,EventArgs>func
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>Theexpressionthatrepresentsaneventattachordetachaction.
funcType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,EventArgs>)>)>ThefunctionthatwillbuildtheEventArgstopasswhenraisingtheevent.
TypeParametersT1
Thetypeofthefirstargumentreceivedbytheexpectedinvocation.T2
Thetypeofthesecondargumentreceivedbytheexpectedinvocation.T3
Thetypeofthethirdargumentreceivedbytheexpectedinvocation.T4
Thetypeofthefourthargumentreceivedbytheexpectedinvocation.T5
Thetypeofthefifthargumentreceivedbytheexpectedinvocation.T6
Thetypeofthesixthargumentreceivedbytheexpectedinvocation.T7
Thetypeoftheseventhargumentreceivedbytheexpectedinvocation.T8
Thetypeoftheeighthargumentreceivedbytheexpectedinvocation.T9
Thetypeoftheninethargumentreceivedbytheexpectedinvocation.
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespaceIRaise<(Of<(<'T>)>)>..::..Raises(Action<(Of<<'(T>)>>),EventArgs)
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>)>Method(Action<(Of<(<'T>)>)>,Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,EventArgs>)>)>)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedbackSpecifiestheeventthatwillberaisedwhenthesetupismatched.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(
Action<T>eventExpression,
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,EventArgs>func
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>Theexpressionthatrepresentsaneventattachordetachaction.
funcType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,EventArgs>)>)>ThefunctionthatwillbuildtheEventArgstopasswhenraisingtheevent.
TypeParametersT1
Thetypeofthefirstargumentreceivedbytheexpectedinvocation.T2
Thetypeofthesecondargumentreceivedbytheexpectedinvocation.T3
Thetypeofthethirdargumentreceivedbytheexpectedinvocation.T4
Thetypeofthefourthargumentreceivedbytheexpectedinvocation.T5
Thetypeofthefifthargumentreceivedbytheexpectedinvocation.T6
Thetypeofthesixthargumentreceivedbytheexpectedinvocation.T7
Thetypeoftheseventhargumentreceivedbytheexpectedinvocation.T8
Thetypeoftheeighthargumentreceivedbytheexpectedinvocation.T9
Thetypeoftheninethargumentreceivedbytheexpectedinvocation.T10
Thetypeofthetenthargumentreceivedbytheexpectedinvocation.
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespaceIRaise<(Of<(<'T>)>)>..::..Raises(Action<(Of<<'(T>)>>),EventArgs)
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>)>Method(Action<(Of<(<'T>)>)>,Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,EventArgs>)>)>)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedbackSpecifiestheeventthatwillberaisedwhenthesetupismatched.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(
Action<T>eventExpression,
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,EventArgs
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>Theexpressionthatrepresentsaneventattachordetachaction.
funcType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,EventArgs>)>)>ThefunctionthatwillbuildtheEventArgstopasswhenraisingtheevent.
TypeParametersT1
Thetypeofthefirstargumentreceivedbytheexpectedinvocation.T2
Thetypeofthesecondargumentreceivedbytheexpectedinvocation.T3
Thetypeofthethirdargumentreceivedbytheexpectedinvocation.T4
Thetypeofthefourthargumentreceivedbytheexpectedinvocation.T5
Thetypeofthefifthargumentreceivedbytheexpectedinvocation.T6
Thetypeofthesixthargumentreceivedbytheexpectedinvocation.T7
Thetypeoftheseventhargumentreceivedbytheexpectedinvocation.T8
Thetypeoftheeighthargumentreceivedbytheexpectedinvocation.T9
Thetypeoftheninethargumentreceivedbytheexpectedinvocation.T10
Thetypeofthetenthargumentreceivedbytheexpectedinvocation.T11
Thetypeoftheeleventhargumentreceivedbytheexpectedinvocation.
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespaceIRaise<(Of<(<'T>)>)>..::..Raises(Action<(Of<<'(T>)>>),EventArgs)
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>)>Method(Action<(Of<(<'T>)>)>,Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,EventArgs>)>)>)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedbackSpecifiestheeventthatwillberaisedwhenthesetupismatched.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(
Action<T>eventExpression,
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,EventArgs
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>Theexpressionthatrepresentsaneventattachordetachaction.
funcType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,EventArgs>)>)>ThefunctionthatwillbuildtheEventArgstopasswhenraisingtheevent.
TypeParametersT1
Thetypeofthefirstargumentreceivedbytheexpectedinvocation.T2
Thetypeofthesecondargumentreceivedbytheexpectedinvocation.T3
Thetypeofthethirdargumentreceivedbytheexpectedinvocation.T4
Thetypeofthefourthargumentreceivedbytheexpectedinvocation.T5
Thetypeofthefifthargumentreceivedbytheexpectedinvocation.T6
Thetypeofthesixthargumentreceivedbytheexpectedinvocation.T7
Thetypeoftheseventhargumentreceivedbytheexpectedinvocation.T8
Thetypeoftheeighthargumentreceivedbytheexpectedinvocation.T9
Thetypeoftheninethargumentreceivedbytheexpectedinvocation.T10
Thetypeofthetenthargumentreceivedbytheexpectedinvocation.T11
Thetypeoftheeleventhargumentreceivedbytheexpectedinvocation.T12
Thetypeofthetwelfthargumentreceivedbytheexpectedinvocation.
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespaceIRaise<(Of<(<'T>)>)>..::..Raises(Action<(Of<<'(T>)>>),EventArgs)
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>)>Method(Action<(Of<(<'T>)>)>,Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,EventArgs>)>)>)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedbackSpecifiestheeventthatwillberaisedwhenthesetupismatched.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(
Action<T>eventExpression,
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>Theexpressionthatrepresentsaneventattachordetachaction.
funcType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,EventArgs>)>)>ThefunctionthatwillbuildtheEventArgstopasswhenraisingtheevent.
TypeParametersT1
Thetypeofthefirstargumentreceivedbytheexpectedinvocation.T2
Thetypeofthesecondargumentreceivedbytheexpectedinvocation.T3
Thetypeofthethirdargumentreceivedbytheexpectedinvocation.T4
Thetypeofthefourthargumentreceivedbytheexpectedinvocation.T5
Thetypeofthefifthargumentreceivedbytheexpectedinvocation.T6
Thetypeofthesixthargumentreceivedbytheexpectedinvocation.T7
Thetypeoftheseventhargumentreceivedbytheexpectedinvocation.T8
Thetypeoftheeighthargumentreceivedbytheexpectedinvocation.T9
Thetypeoftheninethargumentreceivedbytheexpectedinvocation.T10
Thetypeofthetenthargumentreceivedbytheexpectedinvocation.T11
Thetypeoftheeleventhargumentreceivedbytheexpectedinvocation.T12
Thetypeofthetwelfthargumentreceivedbytheexpectedinvocation.T13
Thetypeofthethirteenthargumentreceivedbytheexpectedinvocation.
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespaceIRaise<(Of<(<'T>)>)>..::..Raises(Action<(Of<<'(T>)>>),EventArgs)
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>)>Method(Action<(Of<(<'T>)>)>,Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,EventArgs>)>)>)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedbackSpecifiestheeventthatwillberaisedwhenthesetupismatched.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>(
Action<T>eventExpression,
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>Theexpressionthatrepresentsaneventattachordetachaction.
funcType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,EventArgs>)>)>ThefunctionthatwillbuildtheEventArgstopasswhenraisingtheevent.
TypeParametersT1
Thetypeofthefirstargumentreceivedbytheexpectedinvocation.T2
Thetypeofthesecondargumentreceivedbytheexpectedinvocation.T3
Thetypeofthethirdargumentreceivedbytheexpectedinvocation.T4
Thetypeofthefourthargumentreceivedbytheexpectedinvocation.T5
Thetypeofthefifthargumentreceivedbytheexpectedinvocation.T6
Thetypeofthesixthargumentreceivedbytheexpectedinvocation.T7
Thetypeoftheseventhargumentreceivedbytheexpectedinvocation.T8
Thetypeoftheeighthargumentreceivedbytheexpectedinvocation.T9
Thetypeoftheninethargumentreceivedbytheexpectedinvocation.T10
Thetypeofthetenthargumentreceivedbytheexpectedinvocation.T11
Thetypeoftheeleventhargumentreceivedbytheexpectedinvocation.T12
Thetypeofthetwelfthargumentreceivedbytheexpectedinvocation.T13
Thetypeofthethirteenthargumentreceivedbytheexpectedinvocation.T14
Thetypeofthefourteenthargumentreceivedbytheexpectedinvocation.
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespaceIRaise<(Of<(<'T>)>)>..::..Raises(Action<(Of<<'(T>)>>),EventArgs)
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>)>Method(Action<(Of<(<'T>)>)>,Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,EventArgs>)>)>)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedbackSpecifiestheeventthatwillberaisedwhenthesetupismatched.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>(
Action<T>eventExpression,
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>Theexpressionthatrepresentsaneventattachordetachaction.
funcType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,EventArgs>)>)>ThefunctionthatwillbuildtheEventArgstopasswhenraisingtheevent.
TypeParametersT1
Thetypeofthefirstargumentreceivedbytheexpectedinvocation.T2
Thetypeofthesecondargumentreceivedbytheexpectedinvocation.T3
Thetypeofthethirdargumentreceivedbytheexpectedinvocation.T4
Thetypeofthefourthargumentreceivedbytheexpectedinvocation.T5
Thetypeofthefifthargumentreceivedbytheexpectedinvocation.T6
Thetypeofthesixthargumentreceivedbytheexpectedinvocation.T7
Thetypeoftheseventhargumentreceivedbytheexpectedinvocation.T8
Thetypeoftheeighthargumentreceivedbytheexpectedinvocation.T9
Thetypeoftheninethargumentreceivedbytheexpectedinvocation.T10
Thetypeofthetenthargumentreceivedbytheexpectedinvocation.T11
Thetypeoftheeleventhargumentreceivedbytheexpectedinvocation.T12
Thetypeofthetwelfthargumentreceivedbytheexpectedinvocation.T13
Thetypeofthethirteenthargumentreceivedbytheexpectedinvocation.T14
Thetypeofthefourteenthargumentreceivedbytheexpectedinvocation.T15
Thetypeofthefifteenthargumentreceivedbytheexpectedinvocation.
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespaceIRaise<(Of<(<'T>)>)>..::..Raises(Action<(Of<<'(T>)>>),EventArgs)
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>)>Method(Action<(Of<(<'T>)>)>,Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,EventArgs>)>)>)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedbackSpecifiestheeventthatwillberaisedwhenthesetupismatched.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>(
Action<T>eventExpression,
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>Theexpressionthatrepresentsaneventattachordetachaction.
funcType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,EventArgs>)>)>ThefunctionthatwillbuildtheEventArgstopasswhenraisingtheevent.
TypeParametersT1
Thetypeofthefirstargumentreceivedbytheexpectedinvocation.T2
Thetypeofthesecondargumentreceivedbytheexpectedinvocation.T3
Thetypeofthethirdargumentreceivedbytheexpectedinvocation.T4
Thetypeofthefourthargumentreceivedbytheexpectedinvocation.T5
Thetypeofthefifthargumentreceivedbytheexpectedinvocation.T6
Thetypeofthesixthargumentreceivedbytheexpectedinvocation.T7
Thetypeoftheseventhargumentreceivedbytheexpectedinvocation.T8
Thetypeoftheeighthargumentreceivedbytheexpectedinvocation.T9
Thetypeoftheninethargumentreceivedbytheexpectedinvocation.T10
Thetypeofthetenthargumentreceivedbytheexpectedinvocation.T11
Thetypeoftheeleventhargumentreceivedbytheexpectedinvocation.T12
Thetypeofthetwelfthargumentreceivedbytheexpectedinvocation.T13
Thetypeofthethirteenthargumentreceivedbytheexpectedinvocation.T14
Thetypeofthefourteenthargumentreceivedbytheexpectedinvocation.T15
Thetypeofthefifteenthargumentreceivedbytheexpectedinvocation.T16
Thetypeofthesixteenthargumentreceivedbytheexpectedinvocation.
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespaceIRaise<(Of<(<'T>)>)>..::..Raises(Action<(Of<<'(T>)>>),EventArgs)
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1>)>)>Method(Action<(Of<(<'T>)>)>,Func)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IRaise`1.Raises``1(System.Action{`0},System.Func`2)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1>(
Action<T>eventExpression,
Funcfunc
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>
funcType:System..::..Func<(Of<(<'T,TResult>)>)>
TypeParametersT1
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespace
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1,T2>)>)>Method(Action<(Of<(<'T>)>)>,Func)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IRaise`1.Raises``2(System.Action{`0},System.Func`3)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1,T2>(
Action<T>eventExpression,
Funcfunc
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>
funcType:System..::..Func<(Of<(<'T1,T2,TResult>)>)>
TypeParametersT1T2
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespace
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1,T2,T3>)>)>Method(Action<(Of<(<'T>)>)>,Func)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IRaise`1.Raises``3(System.Action{`0},System.Func`4)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1,T2,T3>(
Action<T>eventExpression,
Funcfunc
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>
funcType:System..::..Func<(Of<(<'T1,T2,T3,TResult>)>)>
TypeParametersT1T2T3
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespace
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1,T2,T3,T4>)>)>Method(Action<(Of<(<'T>)>)>,Func)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IRaise`1.Raises``4(System.Action{`0},System.Func`5)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1,T2,T3,T4>(
Action<T>eventExpression,
Funcfunc
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>
funcType:System..::..Func<(Of<(<'T1,T2,T3,T4,TResult>)>)>
TypeParametersT1T2T3T4
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespace
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1,T2,T3,T4,T5>)>)>Method(Action<(Of<(<'T>)>)>,Func)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IRaise`1.Raises``5(System.Action{`0},System.Func`6)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1,T2,T3,T4,T5>(
Action<T>eventExpression,
Funcfunc
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>
funcType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,TResult>)>)>
TypeParametersT1T2T3T4T5
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespace
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1,T2,T3,T4,T5,T6>)>)>Method(Action<(Of<(<'T>)>)>,Func)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IRaise`1.Raises``6(System.Action{`0},System.Func`7)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1,T2,T3,T4,T5,T6>(
Action<T>eventExpression,
Funcfunc
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>
funcType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,TResult>)>)>
TypeParametersT1T2T3T4T5T6
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespace
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1,T2,T3,T4,T5,T6,T7>)>)>Method(Action<(Of<(<'T>)>)>,Func)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IRaise`1.Raises``7(System.Action{`0},System.Func`8)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1,T2,T3,T4,T5,T6,T7>(
Action<T>eventExpression,
Funcfunc
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>
funcType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,TResult>)>)>
TypeParametersT1T2T3T4T5T6T7
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespace
C#
MoqIRaise<(Of<(<'T>)>)>..::..Raises<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8>)>)>Method(Action<(Of<(<'T>)>)>,Func)IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IRaise`1.Raises``8(System.Action{`0},System.Func`9)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises<T1,T2,T3,T4,T5,T6,T7,T8>(
Action<T>eventExpression,
Funcfunc
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>
funcType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,TResult>)>)>
TypeParametersT1T2T3T4T5T6T7T8
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespace
C#
MoqIRaise<(Of<(<'T>)>)>..::..RaisesMethod(Action<(Of<(<'T>)>)>,array<Object>[]()[][])IRaise<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedbackSpecifiesthecustomeventthatwillberaisedwhenthesetupismatched.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IVerifiesRaises(
Action<T>eventExpression,
paramsObject[]args
)
Parameters
eventExpressionType:System..::..Action<(Of<(<'T>)>)>Anexpressionthatrepresentsaneventattachordetachaction.
argsType:array<System..::..Object>[]()[][]Theargumentstopasstothecustomdelegate(nonEventHandler-compatible).
SeeAlsoIRaise<(Of<(<'T>)>)>InterfaceRaisesOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>InterfaceMembersSeeAlsoSendFeedbackDefinestheReturnsverb.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicinterfaceIReturns<TMock,TResult>:IHideObjectMembers
whereTMock:class
TypeParametersTMock
Mockedtype.TResult
Typeofthereturnvaluefromtheexpression.
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>MembersMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIReturns<(Of<(<'TMock,TResult>)>)>MembersIReturns<(Of<(<'TMock,TResult>)>)>InterfaceMethodsSeeAlsoSendFeedback
Methods Name Description
Returns(Func<(Of<(<'TResult>)>)>)
Returns(TResult) Specifiesthevaluetoreturn.
Returns<(Of<<'(T>)>>)(Func<(Of<(<'T,TResult>)>)>)
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,
Specifiesafunctionthatwillcalculatethevalueto
T15>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,TResult>)>>))
returnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2>)>>)(Func<(Of<(<'T1,T2,TResult>)>)>)Returns<(Of<<'(T1,T2,T3>)>>)(Func<(Of<(<'T1,T2,T3,TResult>)>)>)Returns<(Of<<'(T1,T2,T3,T4>)>>)(Func<(Of<(<'T1,T2,T3,T4,TResult>)>)>)Returns<(Of<<'(T1,T2,T3,T4,T5>)>>)(Func<(Of<(<'T1,T2,T3,T4,T5,TResult>)>)>)Returns<(Of<<'(T1,T2,T3,T4,T5,T6>)>>)(Func<(Of<(<'T1,T2,T3,T4,T5,T6,TResult>)>)>)Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7>)>>)(Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,TResult>)>)>)Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8>)>>)(Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,TResult>)>)>)
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIReturns<(Of<(<'TMock,TResult>)>)>MethodsIReturns<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
Methods Name Description
Returns(Func<(Of<(<'TResult>)>)>)
Returns(TResult) Specifiesthevaluetoreturn.
Returns<(Of<<'(T>)>>)(Func<(Of<(<'T,TResult>)>)>)
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,
Specifiesafunctionthatwillcalculatethevalueto
T15>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,TResult>)>>))
returnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2>)>>)(Func<(Of<(<'T1,T2,TResult>)>)>)Returns<(Of<<'(T1,T2,T3>)>>)(Func<(Of<(<'T1,T2,T3,TResult>)>)>)Returns<(Of<<'(T1,T2,T3,T4>)>>)(Func<(Of<(<'T1,T2,T3,T4,TResult>)>)>)Returns<(Of<<'(T1,T2,T3,T4,T5>)>>)(Func<(Of<(<'T1,T2,T3,T4,T5,TResult>)>)>)Returns<(Of<<'(T1,T2,T3,T4,T5,T6>)>>)(Func<(Of<(<'T1,T2,T3,T4,T5,T6,TResult>)>)>)Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7>)>>)(Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,TResult>)>)>)Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8>)>>)(Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,TResult>)>)>)
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..ReturnsMethodIReturns<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
OverloadList Name Description
Returns(Func<(Of<(<'TResult>)>)>)
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6, Specifiesafunctionthat
T7,T8,T9,T10,T11,T12,T13,T14,T15>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,TResult>)>>))
willcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>>)(Func<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,TResult>)>>))
Specifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Returns<(Of<<'(T>)>>)(Func<(Of<(<'T,TResult>)>)>)Returns<(Of<<'(T1,T2>)>>)(Func<(Of<(<'T1,T2,TResult>)>)>)Returns<(Of<<'(T1,T2,T3>)>>)(Func<(Of<(<'T1,T2,T3,TResult>)>)>)Returns<(Of<<'(T1,T2,T3,T4>)>>)(Func<(Of<(<'T1,T2,T3,T4,TResult>)>)>)Returns<(Of<<'(T1,T2,T3,T4,T5>)>>)(Func<(Of<(<'T1,T2,T3,T4,T5,TResult>)>)>)Returns<(Of<<'(T1,T2,T3,T4,T5,T6>)>>)(Func<(Of<(<'T1,T2,T3,T4,T5,T6,TResult>)>)>)Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7>)>>)(Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,TResult>)>)>)Returns<(Of<<'(T1,T2,T3,T4,T5,T6,T7,T8>)>>)(Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,TResult>)>)>)
Returns(TResult) Specifiesthevaluetoreturn.
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceIReturns<(Of<(<'TMock,TResult>)>)>MembersMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..ReturnsMethod(Func)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IReturns`2.Returns(System.Func`1)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns(
FuncvalueFunction
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'TResult>)>)>
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9>)>)>Method(Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,TResult>)>)>)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T1,T2,T3,T4,T5,T6,T7,T8,T9>(
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,TResult>valueFunction
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,TResult>)>)>Thefunctionthatwillcalculatethereturnvalue.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.
Copy
ExamplesThereturnvalueiscalculatedfromthevalueoftheactualmethodinvocationarguments.Noticehowtheargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpression:
C#
mock.Setup(x=>x.Execute(
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>()))
.Returns((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)>)>Method(Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TResult>)>)>)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TResult>valueFunction
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TResult>)>)>Thefunctionthatwillcalculatethereturnvalue.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.
Copy
ExamplesThereturnvalueiscalculatedfromthevalueoftheactualmethodinvocationarguments.Noticehowtheargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpression:
C#
mock.Setup(x=>x.Execute(
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>()))
.Returns((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)>)>Method(Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TResult>)>)>)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TResult>
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TResult>)>)>Thefunctionthatwillcalculatethereturnvalue.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.
Copy
ExamplesThereturnvalueiscalculatedfromthevalueoftheactualmethodinvocationarguments.Noticehowtheargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpression:
C#
mock.Setup(x=>x.Execute(
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>()))
.Returns((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)>)>Method(Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TResult>)>)>)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TResult>
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TResult>)>)>Thefunctionthatwillcalculatethereturnvalue.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.T12
Thetypeofthetwelfthargumentoftheinvokedmethod.
Copy
ExamplesThereturnvalueiscalculatedfromthevalueoftheactualmethodinvocationarguments.Noticehowtheargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpression:
C#
mock.Setup(x=>x.Execute(
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>()))
.Returns((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)>)>Method(Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TResult>)>)>)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TResult>
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TResult>)>)>Thefunctionthatwillcalculatethereturnvalue.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.T12
Thetypeofthetwelfthargumentoftheinvokedmethod.T13
Thetypeofthethirteenthargumentoftheinvokedmethod.
Copy
ExamplesThereturnvalueiscalculatedfromthevalueoftheactualmethodinvocationarguments.Noticehowtheargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpression:
C#
mock.Setup(x=>x.Execute(
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>()))
.Returns((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)>)>Method(Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TResult>)>)>)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>(
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TResult>
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TResult>)>)>Thefunctionthatwillcalculatethereturnvalue.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.T12
Thetypeofthetwelfthargumentoftheinvokedmethod.T13
Thetypeofthethirteenthargumentoftheinvokedmethod.T14
Thetypeofthefourteenthargumentoftheinvokedmethod.
Copy
ExamplesThereturnvalueiscalculatedfromthevalueoftheactualmethodinvocationarguments.Noticehowtheargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpression:
C#
mock.Setup(x=>x.Execute(
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>()))
.Returns((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>)>)>Method(Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,TResult>)>)>)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>(
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,TResult>
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,TResult>)>)>Thefunctionthatwillcalculatethereturnvalue.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.T12
Thetypeofthetwelfthargumentoftheinvokedmethod.T13
Thetypeofthethirteenthargumentoftheinvokedmethod.T14
Thetypeofthefourteenthargumentoftheinvokedmethod.T15
Thetypeofthefifteenthargumentoftheinvokedmethod.
Copy
ExamplesThereturnvalueiscalculatedfromthevalueoftheactualmethodinvocationarguments.Noticehowtheargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpression:
C#
mock.Setup(x=>x.Execute(
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>()))
.Returns((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>)>)>Method(Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,TResult>)>)>)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesafunctionthatwillcalculatethevaluetoreturnfromthemethod,retrievingtheargumentsfortheinvocation.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>(
Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,TResult>
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,TResult>)>)>Thefunctionthatwillcalculatethereturnvalue.
TypeParametersT1
Thetypeofthefirstargumentoftheinvokedmethod.T2
Thetypeofthesecondargumentoftheinvokedmethod.T3
Thetypeofthethirdargumentoftheinvokedmethod.T4
Thetypeofthefourthargumentoftheinvokedmethod.T5
Thetypeofthefifthargumentoftheinvokedmethod.T6
Thetypeofthesixthargumentoftheinvokedmethod.T7
Thetypeoftheseventhargumentoftheinvokedmethod.T8
Thetypeoftheeighthargumentoftheinvokedmethod.T9
Thetypeoftheninethargumentoftheinvokedmethod.T10
Thetypeofthetenthargumentoftheinvokedmethod.T11
Thetypeoftheeleventhargumentoftheinvokedmethod.T12
Thetypeofthetwelfthargumentoftheinvokedmethod.T13
Thetypeofthethirteenthargumentoftheinvokedmethod.T14
Thetypeofthefourteenthargumentoftheinvokedmethod.T15
Thetypeofthefifteenthargumentoftheinvokedmethod.T16
Thetypeofthesixteenthargumentoftheinvokedmethod.
Copy
ExamplesThereturnvalueiscalculatedfromthevalueoftheactualmethodinvocationarguments.Noticehowtheargumentsareretrievedbysimplydeclaringthemaspartofthelambdaexpression:
C#
mock.Setup(x=>x.Execute(
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<int>()))
.Returns((stringarg1,stringarg2,stringarg3,stringarg4,string
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T>)>)>Method(Func)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IReturns`2.Returns``1(System.Func`2)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T>(
FuncvalueFunction
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T,TResult>)>)>
TypeParametersT
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T1,T2>)>)>Method(Func)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IReturns`2.Returns``2(System.Func`3)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T1,T2>(
FuncvalueFunction
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T1,T2,TResult>)>)>
TypeParametersT1T2
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T1,T2,T3>)>)>Method(Func)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IReturns`2.Returns``3(System.Func`4)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T1,T2,T3>(
FuncvalueFunction
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T1,T2,T3,TResult>)>)>
TypeParametersT1T2T3
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T1,T2,T3,T4>)>)>Method(Func)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IReturns`2.Returns``4(System.Func`5)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T1,T2,T3,T4>(
FuncvalueFunction
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T1,T2,T3,T4,TResult>)>)>
TypeParametersT1T2T3T4
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T1,T2,T3,T4,T5>)>)>Method(Func)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IReturns`2.Returns``5(System.Func`6)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T1,T2,T3,T4,T5>(
FuncvalueFunction
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,TResult>)>)>
TypeParametersT1T2T3T4T5
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T1,T2,T3,T4,T5,T6>)>)>Method(Func)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IReturns`2.Returns``6(System.Func`7)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T1,T2,T3,T4,T5,T6>(
FuncvalueFunction
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,TResult>)>)>
TypeParametersT1T2T3T4T5T6
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T1,T2,T3,T4,T5,T6,T7>)>)>Method(Func)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IReturns`2.Returns``7(System.Func`8)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T1,T2,T3,T4,T5,T6,T7>(
FuncvalueFunction
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,TResult>)>)>
TypeParametersT1T2T3T4T5T6T7
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..Returns<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8>)>)>Method(Func)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IReturns`2.Returns``8(System.Func`9)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns<T1,T2,T3,T4,T5,T6,T7,T8>(
FuncvalueFunction
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'T1,T2,T3,T4,T5,T6,T7,T8,TResult>)>)>
TypeParametersT1T2T3T4T5T6T7T8
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturns<(Of<(<'TMock,TResult>)>)>..::..ReturnsMethod(TResult)IReturns<(Of<(<'TMock,TResult>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesthevaluetoreturn.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns(
TResultvalue
)
Parameters
valueType:TResultThevaluetoreturn,ornullNothingnullptranullreference(NothinginVisualBasic).
Copy
ExamplesReturnatruevaluefromthemethodcall:
C#
mock.Setup(x=>x.Execute("ping"))
.Returns(true);
SeeAlsoIReturns<(Of<(<'TMock,TResult>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturnsGetter<(Of<(<'TMock,TProperty>)>)>InterfaceMembersSeeAlsoSendFeedbackDefinestheReturnsverbforpropertygetsetups.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicinterfaceIReturnsGetter<TMock,TProperty>:IHideObjectMembers
whereTMock:class
TypeParametersTMock
Mockedtype.TProperty
Typeoftheproperty.
SeeAlsoIReturnsGetter<(Of<(<'TMock,TProperty>)>)>MembersMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIReturnsGetter<(Of<(<'TMock,TProperty>)>)>MembersIReturnsGetter<(Of<(<'TMock,TProperty>)>)>InterfaceMethodsSeeAlsoSendFeedback
Methods Name Description
Returns(Func<(Of<(<'TResult>)>)>)Returns(TProperty) Specifiesthevaluetoreturn.
SeeAlsoIReturnsGetter<(Of<(<'TMock,TProperty>)>)>InterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIReturnsGetter<(Of<(<'TMock,TProperty>)>)>MethodsIReturnsGetter<(Of<(<'TMock,TProperty>)>)>InterfaceSeeAlsoSendFeedback
Methods Name Description
Returns(Func<(Of<(<'TResult>)>)>)Returns(TProperty) Specifiesthevaluetoreturn.
SeeAlsoIReturnsGetter<(Of<(<'TMock,TProperty>)>)>InterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIReturnsGetter<(Of<(<'TMock,TProperty>)>)>..::..ReturnsMethodIReturnsGetter<(Of<(<'TMock,TProperty>)>)>InterfaceSeeAlsoSendFeedback
OverloadList Name Description
Returns(Func<(Of<(<'TResult>)>)>)Returns(TProperty) Specifiesthevaluetoreturn.
SeeAlsoIReturnsGetter<(Of<(<'TMock,TProperty>)>)>InterfaceIReturnsGetter<(Of<(<'TMock,TProperty>)>)>MembersMoq.LanguageNamespace
C#
MoqIReturnsGetter<(Of<(<'TMock,TProperty>)>)>..::..ReturnsMethod(Func)IReturnsGetter<(Of<(<'TMock,TProperty>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.IReturnsGetter`2.Returns(System.Func`1)"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns(
FuncvalueFunction
)
Parameters
valueFunctionType:System..::..Func<(Of<(<'TResult>)>)>
SeeAlsoIReturnsGetter<(Of<(<'TMock,TProperty>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqIReturnsGetter<(Of<(<'TMock,TProperty>)>)>..::..ReturnsMethod(TProperty)IReturnsGetter<(Of<(<'TMock,TProperty>)>)>InterfaceExampleSeeAlsoSendFeedbackSpecifiesthevaluetoreturn.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IReturnsResult<TMock>Returns(
TPropertyvalue
)
Parameters
valueType:TPropertyThevaluetoreturn,ornullNothingnullptranullreference(NothinginVisualBasic).
Copy
ExamplesReturnatruevaluefromthepropertygettercall:
C#
mock.SetupGet(x=>x.Suspended)
.Returns(true);
SeeAlsoIReturnsGetter<(Of<(<'TMock,TProperty>)>)>InterfaceReturnsOverloadMoq.LanguageNamespace
C#
MoqISetupConditionResult<(Of<(<'T>)>)>InterfaceMembersSeeAlsoSendFeedbackImplementsthefluentAPI.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicinterfaceISetupConditionResult<T>
whereT:class
TypeParametersT
SeeAlsoISetupConditionResult<(Of<(<'T>)>)>MembersMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqISetupConditionResult<(Of<(<'T>)>)>MembersISetupConditionResult<(Of<(<'T>)>)>InterfaceMethodsSeeAlsoSendFeedback
TheISetupConditionResult<(Of<(<'T>)>)>typeexposesthefollowingmembers.
Methods Name Description
Setup(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>))
Theexpectationwillbeconsideredonlyintheformercondition.
Setup<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))SetupGet<(Of<<'(TProperty>)>>)SetupSet(Action<(Of<<'(T>)>>)) Setupstheset.SetupSet<(Of<<'(TProperty>)>>)(Action<(Of<<'(T>)>>)) Setupstheset.
SeeAlsoISetupConditionResult<(Of<(<'T>)>)>InterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqISetupConditionResult<(Of<(<'T>)>)>MethodsISetupConditionResult<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
TheISetupConditionResult<(Of<(<'T>)>)>typeexposesthefollowingmembers.
Methods Name Description
Setup(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>))
Theexpectationwillbeconsideredonlyintheformercondition.
Setup<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))SetupGet<(Of<<'(TProperty>)>>)SetupSet(Action<(Of<<'(T>)>>)) Setupstheset.SetupSet<(Of<<'(TProperty>)>>)(Action<(Of<<'(T>)>>)) Setupstheset.
SeeAlsoISetupConditionResult<(Of<(<'T>)>)>InterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqISetupConditionResult<(Of<(<'T>)>)>..::..SetupMethodISetupConditionResult<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
OverloadList Name Description
Setup(Expression<(Of<<'(Action<(Of<<'(T>)>>)>)>>))
Theexpectationwillbeconsideredonlyintheformercondition.
Setup<(Of<<'(TResult>)>>)(Expression<(Of<<'(Func<(Of<(<'T,TResult>)>)>>)>>))
SeeAlsoISetupConditionResult<(Of<(<'T>)>)>InterfaceISetupConditionResult<(Of<(<'T>)>)>MembersMoq.LanguageNamespace
C#
MoqISetupConditionResult<(Of<(<'T>)>)>..::..SetupMethod(Expression<(Of<(<'Action<(Of<(<'T>)>)>>)>)>)ISetupConditionResult<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedbackTheexpectationwillbeconsideredonlyintheformercondition.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ISetup<T>Setup(
Expression<Action<T>>expression
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Action<(Of<(<'T>)>)>>)>)>
ReturnValue
SeeAlsoISetupConditionResult<(Of<(<'T>)>)>InterfaceSetupOverloadMoq.LanguageNamespace
C#
MoqISetupConditionResult<(Of<(<'T>)>)>..::..Setup<(Of<(<'TResult>)>)>Method(Expression<(Of<(<'Func>)>)>)ISetupConditionResult<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ISetupConditionResult`1.Setup``1(System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ISetup<T,TResult>Setup<TResult>(
Expression<Func>expression
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersTResult
SeeAlsoISetupConditionResult<(Of<(<'T>)>)>InterfaceSetupOverloadMoq.LanguageNamespace
C#
MoqISetupConditionResult<(Of<(<'T>)>)>..::..SetupGet<(Of<(<'TProperty>)>)>MethodISetupConditionResult<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Language.ISetupConditionResult`1.SetupGet``1(System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ISetupGetter<T,TProperty>SetupGet<TProperty>(
Expression<Func>expression
)
Parameters
expressionType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersTProperty
SeeAlsoISetupConditionResult<(Of<(<'T>)>)>InterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqISetupConditionResult<(Of<(<'T>)>)>..::..SetupSetMethodISetupConditionResult<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedback
OverloadList Name Description
SetupSet(Action<(Of<<'(T>)>>)) Setupstheset.
SetupSet<(Of<<'(TProperty>)>>)(Action<(Of<<'(T>)>>))
Setupstheset.
SeeAlsoISetupConditionResult<(Of<(<'T>)>)>InterfaceISetupConditionResult<(Of<(<'T>)>)>MembersMoq.LanguageNamespace
C#
MoqISetupConditionResult<(Of<(<'T>)>)>..::..SetupSetMethod(Action<(Of<(<'T>)>)>)ISetupConditionResult<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedbackSetupstheset.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ISetup<T>SetupSet(
Action<T>setterExpression
)
Parameters
setterExpressionType:System..::..Action<(Of<(<'T>)>)>Thesetterexpression.
ReturnValue
SeeAlsoISetupConditionResult<(Of<(<'T>)>)>InterfaceSetupSetOverloadMoq.LanguageNamespace
C#
MoqISetupConditionResult<(Of<(<'T>)>)>..::..SetupSet<(Of<(<'TProperty>)>)>Method(Action<(Of<(<'T>)>)>)ISetupConditionResult<(Of<(<'T>)>)>InterfaceSeeAlsoSendFeedbackSetupstheset.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ISetupSetter<T,TProperty>SetupSet<TProperty>(
Action<T>setterExpression
)
Parameters
setterExpressionType:System..::..Action<(Of<(<'T>)>)>Thesetterexpression.
TypeParametersTProperty
Thetypeoftheproperty.
ReturnValue
SeeAlsoISetupConditionResult<(Of<(<'T>)>)>InterfaceSetupSetOverloadMoq.LanguageNamespace
C#
MoqISetupSequentialResult<(Of<(<'TResult>)>)>InterfaceMembersSeeAlsoSendFeedbackLanguageforReturnSequence
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicinterfaceISetupSequentialResult<TResult>
TypeParametersTResult
SeeAlsoISetupSequentialResult<(Of<(<'TResult>)>)>MembersMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqISetupSequentialResult<(Of<(<'TResult>)>)>MembersISetupSequentialResult<(Of<(<'TResult>)>)>InterfaceMethodsSeeAlsoSendFeedback
TheISetupSequentialResult<(Of<(<'TResult>)>)>typeexposesthefollowingmembers.
Methods Name Description
Returns ReturnsvalueThrows(Exception) ThrowsanexceptionThrows<(Of<<'(TException>)>>)()()()() Throwsanexception
SeeAlsoISetupSequentialResult<(Of<(<'TResult>)>)>InterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqISetupSequentialResult<(Of<(<'TResult>)>)>MethodsISetupSequentialResult<(Of<(<'TResult>)>)>InterfaceSeeAlsoSendFeedback
TheISetupSequentialResult<(Of<(<'TResult>)>)>typeexposesthefollowingmembers.
Methods Name Description
Returns ReturnsvalueThrows(Exception) ThrowsanexceptionThrows<(Of<<'(TException>)>>)()()()() Throwsanexception
SeeAlsoISetupSequentialResult<(Of<(<'TResult>)>)>InterfaceMoq.LanguageNamespace
C#
MoqISetupSequentialResult<(Of<(<'TResult>)>)>..::..ReturnsMethodISetupSequentialResult<(Of<(<'TResult>)>)>InterfaceSeeAlsoSendFeedbackReturnsvalue
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ISetupSequentialResult<TResult>Returns(
TResultvalue
)
Parameters
valueType:TResult
SeeAlsoISetupSequentialResult<(Of<(<'TResult>)>)>InterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqISetupSequentialResult<(Of<(<'TResult>)>)>..::..ThrowsMethodISetupSequentialResult<(Of<(<'TResult>)>)>InterfaceSeeAlsoSendFeedback
OverloadList Name Description
Throws<(Of<<'(TException>)>>)()()()() ThrowsanexceptionThrows(Exception) Throwsanexception
SeeAlsoISetupSequentialResult<(Of<(<'TResult>)>)>InterfaceISetupSequentialResult<(Of<(<'TResult>)>)>MembersMoq.LanguageNamespace
C#
MoqISetupSequentialResult<(Of<(<'TResult>)>)>..::..Throws<(Of<(<'TException>)>)>MethodISetupSequentialResult<(Of<(<'TResult>)>)>InterfaceSeeAlsoSendFeedbackThrowsanexception
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
voidThrows<TException>()
whereTException:new(),Exception
TypeParametersTException
SeeAlsoISetupSequentialResult<(Of<(<'TResult>)>)>InterfaceThrowsOverloadMoq.LanguageNamespace
C#
MoqISetupSequentialResult<(Of<(<'TResult>)>)>..::..ThrowsMethod(Exception)ISetupSequentialResult<(Of<(<'TResult>)>)>InterfaceSeeAlsoSendFeedbackThrowsanexception
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
voidThrows(
Exceptionexception
)
Parameters
exceptionType:System..::..Exception
SeeAlsoISetupSequentialResult<(Of<(<'TResult>)>)>InterfaceThrowsOverloadMoq.LanguageNamespace
C#
MoqIThrowsInterfaceMembersSeeAlsoSendFeedbackDefinestheThrowsverb.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicinterfaceIThrows:IHideObjectMembers
SeeAlsoIThrowsMembersMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIThrowsMembersIThrowsInterfaceMethodsSeeAlsoSendFeedback
Methods Name Description
Throws(Exception) Specifiestheexceptiontothrowwhenthemethodisinvoked.
Throws<(Of<<'(TException>)>>)()()()()
Specifiesthetypeofexceptiontothrowwhenthemethodisinvoked.
SeeAlsoIThrowsInterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIThrowsMethodsIThrowsInterfaceSeeAlsoSendFeedback
Methods Name Description
Throws(Exception) Specifiestheexceptiontothrowwhenthemethodisinvoked.
Throws<(Of<<'(TException>)>>)()()()()
Specifiesthetypeofexceptiontothrowwhenthemethodisinvoked.
SeeAlsoIThrowsInterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIThrows..::..ThrowsMethodIThrowsInterfaceSeeAlsoSendFeedback
OverloadList Name Description
Throws<(Of<<'(TException>)>>)()()()()
Specifiesthetypeofexceptiontothrowwhenthemethodisinvoked.
Throws(Exception) Specifiestheexceptiontothrowwhenthemethodisinvoked.
SeeAlsoIThrowsInterfaceIThrowsMembersMoq.LanguageNamespace
C#
MoqIThrows..::..Throws<(Of<(<'TException>)>)>MethodIThrowsInterfaceExampleSeeAlsoSendFeedbackSpecifiesthetypeofexceptiontothrowwhenthemethodisinvoked.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IThrowsResultThrows<TException>()
whereTException:new(),Exception
TypeParametersTException
Typeofexceptiontoinstantiateandthrowwhenthesetupismatched.
Copy
ExamplesThisexampleshowshowtothrowanexceptionwhenthemethodisinvokedwithanemptystringargument:
C#
mock.Setup(x=>x.Execute(""))
.Throws<ArgumentException>();
SeeAlsoIThrowsInterfaceThrowsOverloadMoq.LanguageNamespace
C#
MoqIThrows..::..ThrowsMethod(Exception)IThrowsInterfaceExampleSeeAlsoSendFeedbackSpecifiestheexceptiontothrowwhenthemethodisinvoked.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
IThrowsResultThrows(
Exceptionexception
)
Parameters
exceptionType:System..::..ExceptionExceptioninstancetothrow.
Copy
ExamplesThisexampleshowshowtothrowanexceptionwhenthemethodisinvokedwithanemptystringargument:
C#
mock.Setup(x=>x.Execute(""))
.Throws(newArgumentException());
SeeAlsoIThrowsInterfaceThrowsOverloadMoq.LanguageNamespace
C#
MoqIVerifiesInterfaceMembersSeeAlsoSendFeedbackDefinestheVerifiableverb.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicinterfaceIVerifies:IHideObjectMembers
SeeAlsoIVerifiesMembersMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIVerifiesMembersIVerifiesInterfaceMethodsSeeAlsoSendFeedback
Methods Name Description
Verifiable()()()()Markstheexpectationasverifiable,meaningthatacalltoVerify()()()()willcheckifthisparticularexpectationwasmet.
Verifiable(String)
Markstheexpectationasverifiable,meaningthatacalltoVerify()()()()willcheckifthisparticularexpectationwasmet,andspecifiesamessageforfailures.
SeeAlsoIVerifiesInterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIVerifiesMethodsIVerifiesInterfaceSeeAlsoSendFeedback
Methods Name Description
Verifiable()()()()Markstheexpectationasverifiable,meaningthatacalltoVerify()()()()willcheckifthisparticularexpectationwasmet.
Verifiable(String)
Markstheexpectationasverifiable,meaningthatacalltoVerify()()()()willcheckifthisparticularexpectationwasmet,andspecifiesamessageforfailures.
SeeAlsoIVerifiesInterfaceMoq.LanguageNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIVerifies..::..VerifiableMethodIVerifiesInterfaceSeeAlsoSendFeedback
OverloadList Name Description
Verifiable()()()()Markstheexpectationasverifiable,meaningthatacalltoVerify()()()()willcheckifthisparticularexpectationwasmet.
Verifiable(String)
Markstheexpectationasverifiable,meaningthatacalltoVerify()()()()willcheckifthisparticularexpectationwasmet,andspecifiesamessageforfailures.
SeeAlsoIVerifiesInterfaceIVerifiesMembersMoq.LanguageNamespace
C#
MoqIVerifies..::..VerifiableMethodIVerifiesInterfaceExampleSeeAlsoSendFeedbackMarkstheexpectationasverifiable,meaningthatacalltoVerify()()()()willcheckifthisparticularexpectationwasmet.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
voidVerifiable()
Copy
ExamplesThefollowingexamplemarkstheexpectationasverifiable:
C#
mock.Expect(x=>x.Execute("ping"))
.Returns(true)
.Verifiable();
SeeAlsoIVerifiesInterfaceVerifiableOverloadMoq.LanguageNamespace
C#
MoqIVerifies..::..VerifiableMethod(String)IVerifiesInterfaceExampleSeeAlsoSendFeedbackMarkstheexpectationasverifiable,meaningthatacalltoVerify()()()()willcheckifthisparticularexpectationwasmet,andspecifiesamessageforfailures.
Namespace:Moq.LanguageAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
voidVerifiable(
stringfailMessage
)
Parameters
failMessageType:System..::..String
Copy
ExamplesThefollowingexamplemarkstheexpectationasverifiable:
C#
mock.Expect(x=>x.Execute("ping"))
.Returns(true)
.Verifiable("Pingshouldbeexecutedalways!");
SeeAlsoIVerifiesInterfaceVerifiableOverloadMoq.LanguageNamespace
C#
MoqMoq.ProtectedNamespaceSendFeedbackImportingthisnamespacewillenabletheProtected()methodonmocks,enablingexpectationsonprotectedmembersbyspecifyingthemembernameasastring.
Classes Class Description
ItExpr
Allowsthespecificationofamatchingconditionforanargumentinaprotectedmembersetup,ratherthanaspecificargumentvalue."ItExpr"referstotheargumentbeingmatched.
ProtectedExtension
EnablestheProtected()methodonMock<(Of<(<'T>)>)>,allowingsetupstobesetforprotectedmembersbyusingtheirnameasastring,ratherthanstrong-typingthemwhichisnotpossibleduetotheirvisibility.
Interfaces Interface Description
IProtectedMock<(Of<(<'TMock>)>)>
Allowssetupstobespecifiedforprotectedmembersbyusingtheirnameasastring,ratherthanstrong-typingthemwhichisnotpossibleduetotheirvisibility.
C#
MoqIProtectedMock<(Of<(<'TMock>)>)>InterfaceMembersSeeAlsoSendFeedbackAllowssetupstobespecifiedforprotectedmembersbyusingtheirnameasastring,ratherthanstrong-typingthemwhichisnotpossibleduetotheirvisibility.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicinterfaceIProtectedMock<TMock>:IHideObjectMembers
whereTMock:class
TypeParametersTMock
SeeAlsoIProtectedMock<(Of<(<'TMock>)>)>MembersMoq.ProtectedNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIProtectedMock<(Of<(<'TMock>)>)>MembersIProtectedMock<(Of<(<'TMock>)>)>InterfaceMethodsSeeAlsoSendFeedback
TheIProtectedMock<(Of<(<'TMock>)>)>typeexposesthefollowingmembers.
Methods Name Description
Setup(String,array<Object>[]()[][])
SpecifiesasetupforavoidmethodinvocationwiththegivenvoidMethodName,optionallyspecifyingargumentsforthemethodcall.
Setup<(Of<<'(TResult>)>>)(String,array<Object>[]()[][])
SpecifiesasetupforaninvocationonapropertyoranonvoidmethodwiththegivenmethodOrPropertyName,optionallyspecifyingargumentsforthemethodcall.
SetupGet<(Of<<'(TProperty>)>>)
SpecifiesasetupforaninvocationonapropertygetterwiththegivenpropertyName.
SetupSet<(Of<<'(TProperty>)>>)
SpecifiesasetupforaninvocationonapropertysetterwiththegivenpropertyName.
Verify(String,Times,array<Object>[]()[][])
SpecifiesaverifyforavoidmethodwiththegivenmethodName,optionallyspecifyingargumentsforthemethodcall.UseinconjuntionwiththedefaultLoose.
Verify<(Of<<'(TResult>)>>)(String,Times,array<Object>[]()[][])
SpecifiesaverifyforaninvocationonapropertyoranonvoidmethodwiththegivenmethodName,optionallyspecifyingargumentsforthemethodcall.
VerifyGet<(Of<<'(TProperty>)>>)
SpecifiesaverifyforaninvocationonapropertygetterwiththegivenpropertyName.Theinvocationwasnotcallthetimesspecifiedbytimes.
VerifySet<(Of<<'(TProperty>)>>)
SpecifiesasetupforaninvocationonapropertysetterwiththegivenpropertyName.
SeeAlsoIProtectedMock<(Of<(<'TMock>)>)>InterfaceMoq.ProtectedNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIProtectedMock<(Of<(<'TMock>)>)>MethodsIProtectedMock<(Of<(<'TMock>)>)>InterfaceSeeAlsoSendFeedback
TheIProtectedMock<(Of<(<'TMock>)>)>typeexposesthefollowingmembers.
Methods Name Description
Setup(String,array<Object>[]()[][])
SpecifiesasetupforavoidmethodinvocationwiththegivenvoidMethodName,optionallyspecifyingargumentsforthemethodcall.
Setup<(Of<<'(TResult>)>>)(String,array<Object>[]()[][])
SpecifiesasetupforaninvocationonapropertyoranonvoidmethodwiththegivenmethodOrPropertyName,optionallyspecifyingargumentsforthemethodcall.
SetupGet<(Of<<'(TProperty>)>>)
SpecifiesasetupforaninvocationonapropertygetterwiththegivenpropertyName.
SetupSet<(Of<<'(TProperty>)>>)
SpecifiesasetupforaninvocationonapropertysetterwiththegivenpropertyName.
Verify(String,Times,array<Object>[]()[][])
SpecifiesaverifyforavoidmethodwiththegivenmethodName,optionallyspecifyingargumentsforthemethodcall.UseinconjuntionwiththedefaultLoose.
Verify<(Of<<'(TResult>)>>)(String,Times,array<Object>[]()[][])
SpecifiesaverifyforaninvocationonapropertyoranonvoidmethodwiththegivenmethodName,optionallyspecifyingargumentsforthemethodcall.
VerifyGet<(Of<<'(TProperty>)>>)
SpecifiesaverifyforaninvocationonapropertygetterwiththegivenpropertyName.Theinvocationwasnotcallthetimesspecifiedbytimes.
VerifySet<(Of<<'(TProperty>)>>)
SpecifiesasetupforaninvocationonapropertysetterwiththegivenpropertyName.
SeeAlsoIProtectedMock<(Of<(<'TMock>)>)>InterfaceMoq.ProtectedNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIProtectedMock<(Of<(<'TMock>)>)>..::..SetupMethodIProtectedMock<(Of<(<'TMock>)>)>InterfaceSeeAlsoSendFeedback
OverloadList Name Description
Setup<(Of<<'(TResult>)>>)(String,array<Object>[]()[][])
SpecifiesasetupforaninvocationonapropertyoranonvoidmethodwiththegivenmethodOrPropertyName,optionallyspecifyingargumentsforthemethodcall.
Setup(String,array<Object>[]()[][])
SpecifiesasetupforavoidmethodinvocationwiththegivenvoidMethodName,optionallyspecifyingargumentsforthemethodcall.
SeeAlsoIProtectedMock<(Of<(<'TMock>)>)>InterfaceIProtectedMock<(Of<(<'TMock>)>)>MembersMoq.ProtectedNamespace
C#
MoqIProtectedMock<(Of<(<'TMock>)>)>..::..Setup<(Of<(<'TResult>)>)>Method(String,array<Object>[]()[][])IProtectedMock<(Of<(<'TMock>)>)>InterfaceSeeAlsoSendFeedbackSpecifiesasetupforaninvocationonapropertyoranonvoidmethodwiththegivenmethodOrPropertyName,optionallyspecifyingargumentsforthemethodcall.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ISetup<TMock,TResult>Setup<TResult>(
stringmethodOrPropertyName,
paramsObject[]args
)
Parameters
methodOrPropertyNameType:System..::..StringThenameofthemethodorpropertytobeinvoked.
argsType:array<System..::..Object>[]()[][]Theoptionalargumentsfortheinvocation.Ifargumentmatchersareused,remembertouseItExprratherthanIt.
TypeParametersTResult
Thereturntypeofthemethodorproperty.
SeeAlsoIProtectedMock<(Of<(<'TMock>)>)>InterfaceSetupOverloadMoq.ProtectedNamespace
C#
MoqIProtectedMock<(Of<(<'TMock>)>)>..::..SetupMethod(String,array<Object>[]()[][])IProtectedMock<(Of<(<'TMock>)>)>InterfaceSeeAlsoSendFeedbackSpecifiesasetupforavoidmethodinvocationwiththegivenvoidMethodName,optionallyspecifyingargumentsforthemethodcall.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ISetup<TMock>Setup(
stringvoidMethodName,
paramsObject[]args
)
Parameters
voidMethodNameType:System..::..StringThenameofthevoidmethodtobeinvoked.
argsType:array<System..::..Object>[]()[][]Theoptionalargumentsfortheinvocation.Ifargumentmatchersareused,remembertouseItExprratherthanIt.
SeeAlsoIProtectedMock<(Of<(<'TMock>)>)>InterfaceSetupOverloadMoq.ProtectedNamespace
C#
MoqIProtectedMock<(Of<(<'TMock>)>)>..::..SetupGet<(Of<(<'TProperty>)>)>MethodIProtectedMock<(Of<(<'TMock>)>)>InterfaceSeeAlsoSendFeedbackSpecifiesasetupforaninvocationonapropertygetterwiththegivenpropertyName.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ISetupGetter<TMock,TProperty>SetupGet<TProperty>(
stringpropertyName
)
Parameters
propertyNameType:System..::..StringThenameoftheproperty.
TypeParametersTProperty
Thetypeoftheproperty.
SeeAlsoIProtectedMock<(Of<(<'TMock>)>)>InterfaceMoq.ProtectedNamespace
C#
MoqIProtectedMock<(Of<(<'TMock>)>)>..::..SetupSet<(Of<(<'TProperty>)>)>MethodIProtectedMock<(Of<(<'TMock>)>)>InterfaceSeeAlsoSendFeedbackSpecifiesasetupforaninvocationonapropertysetterwiththegivenpropertyName.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
ISetupSetter<TMock,TProperty>SetupSet<TProperty>(
stringpropertyName,
Objectvalue
)
Parameters
propertyNameType:System..::..StringThenameoftheproperty.
valueType:System..::..ObjectThepropertyvalue.Ifargumentmatchersareused,remembertouseItExprratherthanIt.
TypeParametersTProperty
Thetypeoftheproperty.
SeeAlsoIProtectedMock<(Of<(<'TMock>)>)>InterfaceMoq.ProtectedNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqIProtectedMock<(Of<(<'TMock>)>)>..::..VerifyMethodIProtectedMock<(Of<(<'TMock>)>)>InterfaceSeeAlsoSendFeedback
OverloadList Name Description
Verify<(Of<<'(TResult>)>>)(String,Times,array<Object>[]()[][])
SpecifiesaverifyforaninvocationonapropertyoranonvoidmethodwiththegivenmethodName,optionallyspecifyingargumentsforthemethodcall.
Verify(String,Times,array<Object>[]()[][])
SpecifiesaverifyforavoidmethodwiththegivenmethodName,optionallyspecifyingargumentsforthemethodcall.UseinconjuntionwiththedefaultLoose.
SeeAlsoIProtectedMock<(Of<(<'TMock>)>)>InterfaceIProtectedMock<(Of<(<'TMock>)>)>MembersMoq.ProtectedNamespace
C#
MoqIProtectedMock<(Of<(<'TMock>)>)>..::..Verify<(Of<(<'TResult>)>)>Method(String,Times,array<Object>[]()[][])IProtectedMock<(Of<(<'TMock>)>)>InterfaceSeeAlsoSendFeedbackSpecifiesaverifyforaninvocationonapropertyoranonvoidmethodwiththegivenmethodName,optionallyspecifyingargumentsforthemethodcall.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
voidVerify<TResult>(
stringmethodName,
Timestimes,
paramsObject[]args
)
Parameters
methodNameType:System..::..StringThenameofthemethodorpropertytobeinvoked.
timesType:Moq..::..TimesThenumberoftimesamethodisallowedtobecalled.
argsType:array<System..::..Object>[]()[][]Theoptionalargumentsfortheinvocation.Ifargumentmatchersareused,remembertouseItExprratherthanIt.
TypeParametersTResult
Thetypeofreturnvaluefromtheexpression.
ExceptionsException Condition
Moq..::..MockException Theinvocationwasnotcallthetimesspecifiedbytimes.
SeeAlsoIProtectedMock<(Of<(<'TMock>)>)>InterfaceVerifyOverloadMoq.ProtectedNamespace
C#
MoqIProtectedMock<(Of<(<'TMock>)>)>..::..VerifyMethod(String,Times,array<Object>[]()[][])IProtectedMock<(Of<(<'TMock>)>)>InterfaceSeeAlsoSendFeedbackSpecifiesaverifyforavoidmethodwiththegivenmethodName,optionallyspecifyingargumentsforthemethodcall.UseinconjuntionwiththedefaultLoose.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
voidVerify(
stringmethodName,
Timestimes,
paramsObject[]args
)
Parameters
methodNameType:System..::..StringThenameofthevoidmethodtobeverified.
timesType:Moq..::..TimesThenumberoftimesamethodisallowedtobecalled.
argsType:array<System..::..Object>[]()[][]Theoptionalargumentsfortheinvocation.Ifargumentmatchersareused,remembertouseItExprratherthanIt.
ExceptionsException Condition
Moq..::..MockException Theinvocationwasnotcallthetimesspecifiedbytimes.
SeeAlsoIProtectedMock<(Of<(<'TMock>)>)>InterfaceVerifyOverloadMoq.ProtectedNamespace
C#
MoqIProtectedMock<(Of<(<'TMock>)>)>..::..VerifyGet<(Of<(<'TProperty>)>)>MethodIProtectedMock<(Of<(<'TMock>)>)>InterfaceSeeAlsoSendFeedbackSpecifiesaverifyforaninvocationonapropertygetterwiththegivenpropertyName.Theinvocationwasnotcallthetimesspecifiedbytimes.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
voidVerifyGet<TProperty>(
stringpropertyName,
Timestimes
)
Parameters
propertyNameType:System..::..StringThenameoftheproperty.
timesType:Moq..::..TimesThenumberoftimesamethodisallowedtobecalled.
TypeParametersTProperty
Thetypeoftheproperty.
SeeAlsoIProtectedMock<(Of<(<'TMock>)>)>InterfaceMoq.ProtectedNamespace
C#
MoqIProtectedMock<(Of<(<'TMock>)>)>..::..VerifySet<(Of<(<'TProperty>)>)>MethodIProtectedMock<(Of<(<'TMock>)>)>InterfaceSeeAlsoSendFeedbackSpecifiesasetupforaninvocationonapropertysetterwiththegivenpropertyName.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
voidVerifySet<TProperty>(
stringpropertyName,
Timestimes,
Objectvalue
)
Parameters
propertyNameType:System..::..StringThenameoftheproperty.
timesType:Moq..::..TimesThenumberoftimesamethodisallowedtobecalled.
valueType:System..::..ObjectThepropertyvalue.
TypeParametersTProperty
Thetypeoftheproperty.Ifargumentmatchersareused,remembertouseItExprratherthanIt.
ExceptionsException Condition
Moq..::..MockException Theinvocationwasnotcallthetimesspecifiedbytimes.
SeeAlsoIProtectedMock<(Of<(<'TMock>)>)>InterfaceMoq.ProtectedNamespace
C#
MoqItExprClassMembersSeeAlsoSendFeedbackAllowsthespecificationofamatchingconditionforanargumentinaprotectedmembersetup,ratherthanaspecificargumentvalue."ItExpr"referstotheargumentbeingmatched.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticclassItExpr
RemarksUsethisvariantofargumentmatchinginsteadofItforprotectedsetups.
Thisclassallowsthesetuptomatchamethodinvocationwithanarbitraryvalue,withavalueinaspecifiedrange,orevenonethatmatchesagivenpredicate,ornull.
InheritanceHierarchySystem..::..ObjectMoq.Protected..::..ItExpr
SeeAlsoItExprMembersMoq.ProtectedNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqItExprMembersItExprClassMethodsSeeAlsoSendFeedback
TheItExprtypeexposesthefollowingmembers.
Methods Name Description
Is<(Of<<'(TValue>)>>)IsAny<(Of<<'(TValue>)>>) MatchesanyvalueofthegivenTValuetype.
IsInRange<(Of<<'(TValue>)>>) Matchesanyvaluethatisintherangespecified.
IsNull<(Of<<'(TValue>)>>) MatchesanullvalueofthegivenTValuetype.
IsRegex(String) Matchesastringargumentifitmatchesthegivenregularexpressionpattern.
IsRegex(String,RegexOptions)
Matchesastringargumentifitmatchesthegivenregularexpressionpattern.
SeeAlsoItExprClassMoq.ProtectedNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqItExprMethodsItExprClassSeeAlsoSendFeedback
TheItExprtypeexposesthefollowingmembers.
Methods Name Description
Is<(Of<<'(TValue>)>>)IsAny<(Of<<'(TValue>)>>) MatchesanyvalueofthegivenTValuetype.
IsInRange<(Of<<'(TValue>)>>) Matchesanyvaluethatisintherangespecified.
IsNull<(Of<<'(TValue>)>>) MatchesanullvalueofthegivenTValuetype.
IsRegex(String) Matchesastringargumentifitmatchesthegivenregularexpressionpattern.
IsRegex(String,RegexOptions)
Matchesastringargumentifitmatchesthegivenregularexpressionpattern.
SeeAlsoItExprClassMoq.ProtectedNamespace
C#
MoqItExpr..::..Is<(Of<(<'TValue>)>)>MethodItExprClassSeeAlsoSendFeedback
[Missing<summary>documentationfor"M:Moq.Protected.ItExpr.Is``1(System.Linq.Expressions.Expression{System.Func`2})"]
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticExpressionIs<TValue>(
Expression<Func>match
)
Parameters
matchType:System.Linq.Expressions..::..Expression<(Of<(<'Func<(Of<(<'T,TResult>)>)>>)>)>
TypeParametersTValue
SeeAlsoItExprClassMoq.ProtectedNamespace
C#
MoqItExpr..::..IsAny<(Of<(<'TValue>)>)>MethodItExprClassExampleSeeAlsoSendFeedbackMatchesanyvalueofthegivenTValuetype.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
TypeParametersTValue
Typeofthevalue.
RemarksTypicallyusedwhentheactualargumentvalueforamethodcallisnotrelevant.
Copy
ExamplesC#
//ThrowsanexceptionforacalltoRemovewithanystringvalue.
mock.Protected()
.Setup("Remove",ItExpr.IsAny<string>())
.Throws(newInvalidOperationException());
SeeAlsoItExprClassMoq.ProtectedNamespace
C#
MoqItExpr..::..IsInRange<(Of<(<'TValue>)>)>MethodItExprClassExampleSeeAlsoSendFeedbackMatchesanyvaluethatisintherangespecified.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticExpressionIsInRange<TValue>(
TValuefrom,
TValueto,
RangerangeKind
)
whereTValue:IComparable
Parameters
fromType:TValueThelowerboundoftherange.
toType:TValueTheupperboundoftherange.
rangeKindType:Moq..::..RangeThekindofrange.SeeRange.
TypeParametersTValue
Typeoftheargumenttocheck.
Copy
ExamplesThefollowingexampleshowshowtoexpectamethodcallwithanintegerargumentwithinthe0..100range.
C#
mock.Protected()
.Setup("HasInventory",
ItExpr.IsAny<string>(),
ItExpr.IsInRange(0,100,Range.Inclusive))
.Returns(false);
SeeAlsoItExprClassMoq.ProtectedNamespace
C#
MoqItExpr..::..IsNull<(Of<(<'TValue>)>)>MethodItExprClassExampleSeeAlsoSendFeedbackMatchesanullvalueofthegivenTValuetype.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
TypeParametersTValue
Typeofthevalue.
RemarksRequiredforprotectedmocksasthenullvaluecannotbeuseddirectlyasitpreventspropermethodoverloadselection.
Copy
ExamplesC#
//ThrowsanexceptionforacalltoRemovewithanullstringvalue.
mock.Protected()
.Setup("Remove",ItExpr.IsNull<string>())
.Throws(newInvalidOperationException());
SeeAlsoItExprClassMoq.ProtectedNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqItExpr..::..IsRegexMethodItExprClassSeeAlsoSendFeedback
OverloadList Name Description
IsRegex(String) Matchesastringargumentifitmatchesthegivenregularexpressionpattern.
IsRegex(String,RegexOptions)
Matchesastringargumentifitmatchesthegivenregularexpressionpattern.
SeeAlsoItExprClassItExprMembersMoq.ProtectedNamespace
C#
MoqItExpr..::..IsRegexMethod(String)ItExprClassExampleSeeAlsoSendFeedbackMatchesastringargumentifitmatchesthegivenregularexpressionpattern.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticExpressionIsRegex(
stringregex
)
Parameters
regexType:System..::..StringThepatterntousetomatchthestringargumentvalue.
Copy
ExamplesThefollowingexampleshowshowtoexpectacalltoamethodwherethestringargumentmatchesthegivenregularexpression:
C#
mock.Protected()
.Setup("Check",ItExpr.IsRegex("[a-z]+"))
.Returns(1);
SeeAlsoItExprClassIsRegexOverloadMoq.ProtectedNamespace
C#
MoqItExpr..::..IsRegexMethod(String,RegexOptions)ItExprClassExampleSeeAlsoSendFeedbackMatchesastringargumentifitmatchesthegivenregularexpressionpattern.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticExpressionIsRegex(
stringregex,
RegexOptionsoptions
)
Parameters
regexType:System..::..StringThepatterntousetomatchthestringargumentvalue.
optionsType:System.Text.RegularExpressions..::..RegexOptionsTheoptionsusedtointerpretthepattern.
Copy
ExamplesThefollowingexampleshowshowtoexpectacalltoamethodwherethestringargumentmatchesthegivenregularexpression,inacaseinsensitiveway:
C#
mock.Protected()
.Setup("Check",ItExpr.IsRegex("[a-z]+",RegexOptions.IgnoreCase))
.Returns(1);
SeeAlsoItExprClassIsRegexOverloadMoq.ProtectedNamespace
C#
MoqProtectedExtensionClassMembersSeeAlsoSendFeedbackEnablestheProtected()methodonMock<(Of<(<'T>)>)>,allowingsetupstobesetforprotectedmembersbyusingtheirnameasastring,ratherthanstrong-typingthemwhichisnotpossibleduetotheirvisibility.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticclassProtectedExtension
InheritanceHierarchySystem..::..ObjectMoq.Protected..::..ProtectedExtension
SeeAlsoProtectedExtensionMembersMoq.ProtectedNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqProtectedExtensionMembersProtectedExtensionClassMethodsSeeAlsoSendFeedback
TheProtectedExtensiontypeexposesthefollowingmembers.
Methods Name Description
Protected<(Of<<'(T>)>>) Enableprotectedsetupsforthemock.
SeeAlsoProtectedExtensionClassMoq.ProtectedNamespace
C#IncludeProtectedMembersIncludeInheritedMembers
MoqProtectedExtensionMethodsProtectedExtensionClassSeeAlsoSendFeedback
TheProtectedExtensiontypeexposesthefollowingmembers.
Methods Name Description
Protected<(Of<<'(T>)>>) Enableprotectedsetupsforthemock.
SeeAlsoProtectedExtensionClassMoq.ProtectedNamespace
C#
MoqProtectedExtension..::..Protected<(Of<(<'T>)>)>MethodProtectedExtensionClassSeeAlsoSendFeedbackEnableprotectedsetupsforthemock.
Namespace:Moq.ProtectedAssembly:Moq(inMoq.dll)Version:4.0.10827.0(4.0.0.0)
SyntaxC#
publicstaticIProtectedMock<T>Protected<T>(
thisMock<T>mock
)
whereT:class
Parameters
mockType:Moq..::..Mock<(Of<(<'T>)>)>Themocktosettheprotectedsetupson.
TypeParametersT
Mockedobjecttype.Typicallyomittedasitcanbeinferredfromthemockinstance.
SeeAlsoProtectedExtensionClassMoq.ProtectedNamespace
Top Related