From de9eb65dd8b1b87327540e5d1fbd4f8ef506d8a4 Mon Sep 17 00:00:00 2001 From: Michael Wildman Date: Tue, 16 Oct 2018 00:59:45 +1300 Subject: [PATCH 01/13] Add failing unit test for #706 --- .../Moq.Tests/Regressions/IssueReportsFixture.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/Moq.Tests/Regressions/IssueReportsFixture.cs b/tests/Moq.Tests/Regressions/IssueReportsFixture.cs index 32296da2b..f23dd1fa4 100644 --- a/tests/Moq.Tests/Regressions/IssueReportsFixture.cs +++ b/tests/Moq.Tests/Regressions/IssueReportsFixture.cs @@ -2010,6 +2010,22 @@ public interface IMyInterface #endregion + #region 706 + public class Issue706 + { + [Fact] + public void CallBase_should_not_be_allowed_for_delegate_mocks() + { + Mock mock = new Mock(); + Language.Flow.ISetup setup = mock.Setup(m => m()); + + Exception ex = Assert.Throws(() => setup.CallBase()); + Assert.Equal(ex.Message, "CallBase cannot be used to mock delegates."); + } + } + + #endregion + // Old @ Google Code #region #47 From 50132ad165c8d4acc426e8a5c729e22e1ada2296 Mon Sep 17 00:00:00 2001 From: Michael Wildman Date: Tue, 16 Oct 2018 00:59:46 +1300 Subject: [PATCH 02/13] Check if mocked type is a Delegate before allowing CallBase --- src/Moq/MethodCall.cs | 5 + src/Moq/Properties/Resources.Designer.cs | 1413 +++++++++-------- src/Moq/Properties/Resources.resx | 655 ++++---- .../Regressions/IssueReportsFixture.cs | 3 +- 4 files changed, 1047 insertions(+), 1029 deletions(-) diff --git a/src/Moq/MethodCall.cs b/src/Moq/MethodCall.cs index 8203a2833..811518db0 100644 --- a/src/Moq/MethodCall.cs +++ b/src/Moq/MethodCall.cs @@ -123,6 +123,11 @@ public override void Execute(Invocation invocation) public virtual void SetCallBaseResponse() { + if (typeof(Delegate).IsAssignableFrom(this.Mock.TargetType)) + { + throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseUsedOnDelegateException)); + } + this.callBase = true; } diff --git a/src/Moq/Properties/Resources.Designer.cs b/src/Moq/Properties/Resources.Designer.cs index 23e17f0dc..ed6a4bee6 100644 --- a/src/Moq/Properties/Resources.Designer.cs +++ b/src/Moq/Properties/Resources.Designer.cs @@ -9,706 +9,715 @@ //------------------------------------------------------------------------------ namespace Moq.Properties { - using System; - using System.Reflection; - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Moq.Properties.Resources", typeof(Resources).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Mock type has already been initialized by accessing its Object property. Adding interfaces must be done before that.. - /// - internal static string AlreadyInitialized { - get { - return ResourceManager.GetString("AlreadyInitialized", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Value cannot be an empty string.. - /// - internal static string ArgumentCannotBeEmpty { - get { - return ResourceManager.GetString("ArgumentCannotBeEmpty", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Can only add interfaces to the mock.. - /// - internal static string AsMustBeInterface { - get { - return ResourceManager.GetString("AsMustBeInterface", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Can't set return value for void method {0}.. - /// - internal static string CantSetReturnValueForVoid { - get { - return ResourceManager.GetString("CantSetReturnValueForVoid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Configured setups: {0}. - /// - internal static string ConfiguredSetups { - get { - return ResourceManager.GetString("ConfiguredSetups", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Constructor arguments cannot be passed for delegate mocks.. - /// - internal static string ConstructorArgsForDelegate { - get { - return ResourceManager.GetString("ConstructorArgsForDelegate", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Constructor arguments cannot be passed for interface mocks.. - /// - internal static string ConstructorArgsForInterface { - get { - return ResourceManager.GetString("ConstructorArgsForInterface", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A matching constructor for the given arguments was not found on the mocked type.. - /// - internal static string ConstructorNotFound { - get { - return ResourceManager.GetString("ConstructorNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Delays have to be greater than zero to ensure an async callback is used.. - /// - internal static string DelaysMustBeGreaterThanZero { - get { - return ResourceManager.GetString("DelaysMustBeGreaterThanZero", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Could not locate event for attach or detach method {0}.. - /// - internal static string EventNotFound { - get { - return ResourceManager.GetString("EventNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expression is not an event attach or detach, or the event is declared in a class but not marked virtual.. - /// - internal static string ExpressionIsNotEventAttachOrDetachOrIsNotVirtual { - get { - return ResourceManager.GetString("ExpressionIsNotEventAttachOrDetachOrIsNotVirtual", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expression {0} involves a field access, which is not supported. Use properties instead.. - /// - internal static string FieldsNotSupported { - get { - return ResourceManager.GetString("FieldsNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid callback. This overload of the "Callback" method only accepts "void" (C#) or "Sub" (VB.NET) delegates with parameter types matching those of the set up method.. - /// - internal static string InvalidCallbackNotADelegateWithReturnTypeVoid { - get { - return ResourceManager.GetString("InvalidCallbackNotADelegateWithReturnTypeVoid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid callback. Setup on method with {0} parameter(s) cannot invoke callback with different number of parameters ({1}).. - /// - internal static string InvalidCallbackParameterCountMismatch { - get { - return ResourceManager.GetString("InvalidCallbackParameterCountMismatch", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid callback. Setup on method with parameters ({0}) cannot invoke callback with parameters ({1}).. - /// - internal static string InvalidCallbackParameterMismatch { - get { - return ResourceManager.GetString("InvalidCallbackParameterMismatch", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid callback. Setup on method with return type ({0}) cannot invoke callback with return type ({1}).. - /// - internal static string InvalidCallbackReturnTypeMismatch { - get { - return ResourceManager.GetString("InvalidCallbackReturnTypeMismatch", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type to mock must be an interface or an abstract or non-sealed class. . - /// - internal static string InvalidMockClass { - get { - return ResourceManager.GetString("InvalidMockClass", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot retrieve a mock with the given object type {0} as it's not the main type of the mock or any of its additional interfaces. - ///Please cast the argument to one of the supported types: {1}. - ///Remember that there's no generics covariance in the CLR, so your object must be one of these types in order for the call to succeed.. - /// - internal static string InvalidMockGetType { - get { - return ResourceManager.GetString("InvalidMockGetType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid callback. This overload of the "Returns" method only accepts non-"void" (C#) or "Function" (VB.NET) delegates with parameter types matching those of the set up method.. - /// - internal static string InvalidReturnsCallbackNotADelegateWithReturnType { - get { - return ResourceManager.GetString("InvalidReturnsCallbackNotADelegateWithReturnType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The equals ("==" or "=" in VB) and the conditional 'and' ("&&" or "AndAlso" in VB) operators are the only ones supported in the query specification expression. Unsupported expression: {0}. - /// - internal static string LinqBinaryOperatorNotSupported { - get { - return ResourceManager.GetString("LinqBinaryOperatorNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to LINQ method '{0}' not supported.. - /// - internal static string LinqMethodNotSupported { - get { - return ResourceManager.GetString("LinqMethodNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expression contains a call to a method which is not virtual (overridable in VB) or abstract. Unsupported expression: {0}. - /// - internal static string LinqMethodNotVirtual { - get { - return ResourceManager.GetString("LinqMethodNotVirtual", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Member {0}.{1} does not exist.. - /// - internal static string MemberMissing { - get { - return ResourceManager.GetString("MemberMissing", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Method {0}.{1} is public. Use strong-typed Expect overload instead: - ///mock.Setup(x => x.{1}()); - ///. - /// - internal static string MethodIsPublic { - get { - return ResourceManager.GetString("MethodIsPublic", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot set up {0}.{1} because it is not accessible to the proxy generator used by Moq: - ///{2}. - /// - internal static string MethodNotVisibleToProxyFactory { - get { - return ResourceManager.GetString("MethodNotVisibleToProxyFactory", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Minimum delay has to be lower than maximum delay.. - /// - internal static string MinDelayMustBeLessThanMaxDelay { - get { - return ResourceManager.GetString("MinDelayMustBeLessThanMaxDelay", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} invocation failed with mock behavior {1}. - ///{2}. - /// - internal static string MockExceptionMessage { - get { - return ResourceManager.GetString("MockExceptionMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expected only {0} calls to {1}.. - /// - internal static string MoreThanNCalls { - get { - return ResourceManager.GetString("MoreThanNCalls", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expected only one call to {0}.. - /// - internal static string MoreThanOneCall { - get { - return ResourceManager.GetString("MoreThanOneCall", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No invocations performed.. - /// - internal static string NoInvocationsPerformed { - get { - return ResourceManager.GetString("NoInvocationsPerformed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock at least {2} times, but was {4} times: {1}. - /// - internal static string NoMatchingCallsAtLeast { - get { - return ResourceManager.GetString("NoMatchingCallsAtLeast", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock at least once, but was never performed: {1}. - /// - internal static string NoMatchingCallsAtLeastOnce { - get { - return ResourceManager.GetString("NoMatchingCallsAtLeastOnce", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock at most {3} times, but was {4} times: {1}. - /// - internal static string NoMatchingCallsAtMost { - get { - return ResourceManager.GetString("NoMatchingCallsAtMost", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock at most once, but was {4} times: {1}. - /// - internal static string NoMatchingCallsAtMostOnce { - get { - return ResourceManager.GetString("NoMatchingCallsAtMostOnce", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock between {2} and {3} times (Exclusive), but was {4} times: {1}. - /// - internal static string NoMatchingCallsBetweenExclusive { - get { - return ResourceManager.GetString("NoMatchingCallsBetweenExclusive", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock between {2} and {3} times (Inclusive), but was {4} times: {1}. - /// - internal static string NoMatchingCallsBetweenInclusive { - get { - return ResourceManager.GetString("NoMatchingCallsBetweenInclusive", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock exactly {2} times, but was {4} times: {1}. - /// - internal static string NoMatchingCallsExactly { - get { - return ResourceManager.GetString("NoMatchingCallsExactly", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock should never have been performed, but was {4} times: {1}. - /// - internal static string NoMatchingCallsNever { - get { - return ResourceManager.GetString("NoMatchingCallsNever", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock once, but was {4} times: {1}. - /// - internal static string NoMatchingCallsOnce { - get { - return ResourceManager.GetString("NoMatchingCallsOnce", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to All invocations on the mock must have a corresponding setup.. - /// - internal static string NoSetup { - get { - return ResourceManager.GetString("NoSetup", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No setups configured.. - /// - internal static string NoSetupsConfigured { - get { - return ResourceManager.GetString("NoSetupsConfigured", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Object instance was not created by Moq.. - /// - internal static string ObjectInstanceNotMock { - get { - return ResourceManager.GetString("ObjectInstanceNotMock", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Out expression must evaluate to a constant value.. - /// - internal static string OutExpressionMustBeConstantValue { - get { - return ResourceManager.GetString("OutExpressionMustBeConstantValue", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Performed invocations: {0}. - /// - internal static string PerformedInvocations { - get { - return ResourceManager.GetString("PerformedInvocations", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Property {0}.{1} does not have a getter.. - /// - internal static string PropertyGetNotFound { - get { - return ResourceManager.GetString("PropertyGetNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Property {0}.{1} does not have a setter.. - /// - internal static string PropertySetNotFound { - get { - return ResourceManager.GetString("PropertySetNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type {0} does not have matching protected member: {1}. - /// - internal static string ProtectedMemberNotFound { - get { - return ResourceManager.GetString("ProtectedMemberNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot raise a mocked event unless it has been associated (attached) to a concrete event in a mocked object.. - /// - internal static string RaisedUnassociatedEvent { - get { - return ResourceManager.GetString("RaisedUnassociatedEvent", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ref expression must evaluate to a constant value.. - /// - internal static string RefExpressionMustBeConstantValue { - get { - return ResourceManager.GetString("RefExpressionMustBeConstantValue", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invocation needs to return a value and therefore must have a corresponding setup that provides it.. - /// - internal static string ReturnValueRequired { - get { - return ResourceManager.GetString("ReturnValueRequired", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expression is not a method invocation: {0}. - /// - internal static string SetupNotMethod { - get { - return ResourceManager.GetString("SetupNotMethod", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expression is not a property access: {0}. - /// - internal static string SetupNotProperty { - get { - return ResourceManager.GetString("SetupNotProperty", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expression is not a property setter invocation.. - /// - internal static string SetupNotSetter { - get { - return ResourceManager.GetString("SetupNotSetter", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid setup on an extension method: {0}. - /// - internal static string SetupOnExtensionMethod { - get { - return ResourceManager.GetString("SetupOnExtensionMethod", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid setup on a non-virtual (overridable in VB) member: {0}. - /// - internal static string SetupOnNonVirtualMember { - get { - return ResourceManager.GetString("SetupOnNonVirtualMember", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid setup on a static member: {0}. - /// - internal static string SetupOnStaticMember { - get { - return ResourceManager.GetString("SetupOnStaticMember", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type {0} does not implement required interface {1}. - /// - internal static string TypeNotImplementInterface { - get { - return ResourceManager.GetString("TypeNotImplementInterface", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type {0} does not from required type {1}. - /// - internal static string TypeNotInheritFromType { - get { - return ResourceManager.GetString("TypeNotInheritFromType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to To specify a setup for public property {0}.{1}, use the typed overloads, such as: - ///mock.Setup(x => x.{1}).Returns(value); - ///mock.SetupGet(x => x.{1}).Returns(value); //equivalent to previous one - ///mock.SetupSet(x => x.{1}).Callback(callbackDelegate); - ///. - /// - internal static string UnexpectedPublicProperty { - get { - return ResourceManager.GetString("UnexpectedPublicProperty", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unexpected translation of a member access: {0}. - /// - internal static string UnexpectedTranslationOfMemberAccess { - get { - return ResourceManager.GetString("UnexpectedTranslationOfMemberAccess", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unhandled binding type: {0}. - /// - internal static string UnhandledBindingType { - get { - return ResourceManager.GetString("UnhandledBindingType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unhandled expression type: {0}. - /// - internal static string UnhandledExpressionType { - get { - return ResourceManager.GetString("UnhandledExpressionType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The following setups on mock '{0}' were not matched: - ///{1}. - /// - internal static string UnmatchedSetups { - get { - return ResourceManager.GetString("UnmatchedSetups", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unsupported expression: {0}. - /// - internal static string UnsupportedExpression { - get { - return ResourceManager.GetString("UnsupportedExpression", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Member {0} is not supported for protected mocking.. - /// - internal static string UnsupportedMember { - get { - return ResourceManager.GetString("UnsupportedMember", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The following invocations were not verified: - ///{0}. - /// - internal static string UnverifiedInvocations { - get { - return ResourceManager.GetString("UnverifiedInvocations", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use ItExpr.IsNull<TValue> rather than a null argument value, as it prevents proper method lookup.. - /// - internal static string UseItExprIsNullRatherThanNullArgumentValue { - get { - return ResourceManager.GetString("UseItExprIsNullRatherThanNullArgumentValue", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid verify on an extension method: {0}. - /// - internal static string VerifyOnExtensionMethod { - get { - return ResourceManager.GetString("VerifyOnExtensionMethod", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid verify on a non-virtual (overridable in VB) member: {0}. - /// - internal static string VerifyOnNonVirtualMember { - get { - return ResourceManager.GetString("VerifyOnNonVirtualMember", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid verify on a static member: {0}. - /// - internal static string VerifyOnStaticMember { - get { - return ResourceManager.GetString("VerifyOnStaticMember", resourceCulture); - } - } - } + using System; + using System.Reflection; + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Moq.Properties.Resources", typeof(Resources).GetTypeInfo().Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Mock type has already been initialized by accessing its Object property. Adding interfaces must be done before that.. + /// + internal static string AlreadyInitialized { + get { + return ResourceManager.GetString("AlreadyInitialized", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value cannot be an empty string.. + /// + internal static string ArgumentCannotBeEmpty { + get { + return ResourceManager.GetString("ArgumentCannotBeEmpty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Can only add interfaces to the mock.. + /// + internal static string AsMustBeInterface { + get { + return ResourceManager.GetString("AsMustBeInterface", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to CallBase cannot be used to mock Delegate types.. + /// + internal static string CallBaseUsedOnDelegateException { + get { + return ResourceManager.GetString("CallBaseUsedOnDelegateException", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Can't set return value for void method {0}.. + /// + internal static string CantSetReturnValueForVoid { + get { + return ResourceManager.GetString("CantSetReturnValueForVoid", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Configured setups: {0}. + /// + internal static string ConfiguredSetups { + get { + return ResourceManager.GetString("ConfiguredSetups", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Constructor arguments cannot be passed for delegate mocks.. + /// + internal static string ConstructorArgsForDelegate { + get { + return ResourceManager.GetString("ConstructorArgsForDelegate", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Constructor arguments cannot be passed for interface mocks.. + /// + internal static string ConstructorArgsForInterface { + get { + return ResourceManager.GetString("ConstructorArgsForInterface", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A matching constructor for the given arguments was not found on the mocked type.. + /// + internal static string ConstructorNotFound { + get { + return ResourceManager.GetString("ConstructorNotFound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Delays have to be greater than zero to ensure an async callback is used.. + /// + internal static string DelaysMustBeGreaterThanZero { + get { + return ResourceManager.GetString("DelaysMustBeGreaterThanZero", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Could not locate event for attach or detach method {0}.. + /// + internal static string EventNotFound { + get { + return ResourceManager.GetString("EventNotFound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expression is not an event attach or detach, or the event is declared in a class but not marked virtual.. + /// + internal static string ExpressionIsNotEventAttachOrDetachOrIsNotVirtual { + get { + return ResourceManager.GetString("ExpressionIsNotEventAttachOrDetachOrIsNotVirtual", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expression {0} involves a field access, which is not supported. Use properties instead.. + /// + internal static string FieldsNotSupported { + get { + return ResourceManager.GetString("FieldsNotSupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid callback. This overload of the "Callback" method only accepts "void" (C#) or "Sub" (VB.NET) delegates with parameter types matching those of the set up method.. + /// + internal static string InvalidCallbackNotADelegateWithReturnTypeVoid { + get { + return ResourceManager.GetString("InvalidCallbackNotADelegateWithReturnTypeVoid", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid callback. Setup on method with {0} parameter(s) cannot invoke callback with different number of parameters ({1}).. + /// + internal static string InvalidCallbackParameterCountMismatch { + get { + return ResourceManager.GetString("InvalidCallbackParameterCountMismatch", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid callback. Setup on method with parameters ({0}) cannot invoke callback with parameters ({1}).. + /// + internal static string InvalidCallbackParameterMismatch { + get { + return ResourceManager.GetString("InvalidCallbackParameterMismatch", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid callback. Setup on method with return type ({0}) cannot invoke callback with return type ({1}).. + /// + internal static string InvalidCallbackReturnTypeMismatch { + get { + return ResourceManager.GetString("InvalidCallbackReturnTypeMismatch", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type to mock must be an interface or an abstract or non-sealed class. . + /// + internal static string InvalidMockClass { + get { + return ResourceManager.GetString("InvalidMockClass", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cannot retrieve a mock with the given object type {0} as it's not the main type of the mock or any of its additional interfaces. + ///Please cast the argument to one of the supported types: {1}. + ///Remember that there's no generics covariance in the CLR, so your object must be one of these types in order for the call to succeed.. + /// + internal static string InvalidMockGetType { + get { + return ResourceManager.GetString("InvalidMockGetType", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid callback. This overload of the "Returns" method only accepts non-"void" (C#) or "Function" (VB.NET) delegates with parameter types matching those of the set up method.. + /// + internal static string InvalidReturnsCallbackNotADelegateWithReturnType { + get { + return ResourceManager.GetString("InvalidReturnsCallbackNotADelegateWithReturnType", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The equals ("==" or "=" in VB) and the conditional 'and' ("&&" or "AndAlso" in VB) operators are the only ones supported in the query specification expression. Unsupported expression: {0}. + /// + internal static string LinqBinaryOperatorNotSupported { + get { + return ResourceManager.GetString("LinqBinaryOperatorNotSupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to LINQ method '{0}' not supported.. + /// + internal static string LinqMethodNotSupported { + get { + return ResourceManager.GetString("LinqMethodNotSupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expression contains a call to a method which is not virtual (overridable in VB) or abstract. Unsupported expression: {0}. + /// + internal static string LinqMethodNotVirtual { + get { + return ResourceManager.GetString("LinqMethodNotVirtual", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Member {0}.{1} does not exist.. + /// + internal static string MemberMissing { + get { + return ResourceManager.GetString("MemberMissing", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Method {0}.{1} is public. Use strong-typed Expect overload instead: + ///mock.Setup(x => x.{1}()); + ///. + /// + internal static string MethodIsPublic { + get { + return ResourceManager.GetString("MethodIsPublic", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cannot set up {0}.{1} because it is not accessible to the proxy generator used by Moq: + ///{2}. + /// + internal static string MethodNotVisibleToProxyFactory { + get { + return ResourceManager.GetString("MethodNotVisibleToProxyFactory", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Minimum delay has to be lower than maximum delay.. + /// + internal static string MinDelayMustBeLessThanMaxDelay { + get { + return ResourceManager.GetString("MinDelayMustBeLessThanMaxDelay", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} invocation failed with mock behavior {1}. + ///{2}. + /// + internal static string MockExceptionMessage { + get { + return ResourceManager.GetString("MockExceptionMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expected only {0} calls to {1}.. + /// + internal static string MoreThanNCalls { + get { + return ResourceManager.GetString("MoreThanNCalls", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expected only one call to {0}.. + /// + internal static string MoreThanOneCall { + get { + return ResourceManager.GetString("MoreThanOneCall", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No invocations performed.. + /// + internal static string NoInvocationsPerformed { + get { + return ResourceManager.GetString("NoInvocationsPerformed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock at least {2} times, but was {4} times: {1}. + /// + internal static string NoMatchingCallsAtLeast { + get { + return ResourceManager.GetString("NoMatchingCallsAtLeast", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock at least once, but was never performed: {1}. + /// + internal static string NoMatchingCallsAtLeastOnce { + get { + return ResourceManager.GetString("NoMatchingCallsAtLeastOnce", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock at most {3} times, but was {4} times: {1}. + /// + internal static string NoMatchingCallsAtMost { + get { + return ResourceManager.GetString("NoMatchingCallsAtMost", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock at most once, but was {4} times: {1}. + /// + internal static string NoMatchingCallsAtMostOnce { + get { + return ResourceManager.GetString("NoMatchingCallsAtMostOnce", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock between {2} and {3} times (Exclusive), but was {4} times: {1}. + /// + internal static string NoMatchingCallsBetweenExclusive { + get { + return ResourceManager.GetString("NoMatchingCallsBetweenExclusive", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock between {2} and {3} times (Inclusive), but was {4} times: {1}. + /// + internal static string NoMatchingCallsBetweenInclusive { + get { + return ResourceManager.GetString("NoMatchingCallsBetweenInclusive", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock exactly {2} times, but was {4} times: {1}. + /// + internal static string NoMatchingCallsExactly { + get { + return ResourceManager.GetString("NoMatchingCallsExactly", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock should never have been performed, but was {4} times: {1}. + /// + internal static string NoMatchingCallsNever { + get { + return ResourceManager.GetString("NoMatchingCallsNever", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock once, but was {4} times: {1}. + /// + internal static string NoMatchingCallsOnce { + get { + return ResourceManager.GetString("NoMatchingCallsOnce", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to All invocations on the mock must have a corresponding setup.. + /// + internal static string NoSetup { + get { + return ResourceManager.GetString("NoSetup", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No setups configured.. + /// + internal static string NoSetupsConfigured { + get { + return ResourceManager.GetString("NoSetupsConfigured", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Object instance was not created by Moq.. + /// + internal static string ObjectInstanceNotMock { + get { + return ResourceManager.GetString("ObjectInstanceNotMock", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Out expression must evaluate to a constant value.. + /// + internal static string OutExpressionMustBeConstantValue { + get { + return ResourceManager.GetString("OutExpressionMustBeConstantValue", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Performed invocations: {0}. + /// + internal static string PerformedInvocations { + get { + return ResourceManager.GetString("PerformedInvocations", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Property {0}.{1} does not have a getter.. + /// + internal static string PropertyGetNotFound { + get { + return ResourceManager.GetString("PropertyGetNotFound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Property {0}.{1} does not have a setter.. + /// + internal static string PropertySetNotFound { + get { + return ResourceManager.GetString("PropertySetNotFound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type {0} does not have matching protected member: {1}. + /// + internal static string ProtectedMemberNotFound { + get { + return ResourceManager.GetString("ProtectedMemberNotFound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cannot raise a mocked event unless it has been associated (attached) to a concrete event in a mocked object.. + /// + internal static string RaisedUnassociatedEvent { + get { + return ResourceManager.GetString("RaisedUnassociatedEvent", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Ref expression must evaluate to a constant value.. + /// + internal static string RefExpressionMustBeConstantValue { + get { + return ResourceManager.GetString("RefExpressionMustBeConstantValue", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invocation needs to return a value and therefore must have a corresponding setup that provides it.. + /// + internal static string ReturnValueRequired { + get { + return ResourceManager.GetString("ReturnValueRequired", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expression is not a method invocation: {0}. + /// + internal static string SetupNotMethod { + get { + return ResourceManager.GetString("SetupNotMethod", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expression is not a property access: {0}. + /// + internal static string SetupNotProperty { + get { + return ResourceManager.GetString("SetupNotProperty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expression is not a property setter invocation.. + /// + internal static string SetupNotSetter { + get { + return ResourceManager.GetString("SetupNotSetter", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid setup on an extension method: {0}. + /// + internal static string SetupOnExtensionMethod { + get { + return ResourceManager.GetString("SetupOnExtensionMethod", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid setup on a non-virtual (overridable in VB) member: {0}. + /// + internal static string SetupOnNonVirtualMember { + get { + return ResourceManager.GetString("SetupOnNonVirtualMember", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid setup on a static member: {0}. + /// + internal static string SetupOnStaticMember { + get { + return ResourceManager.GetString("SetupOnStaticMember", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type {0} does not implement required interface {1}. + /// + internal static string TypeNotImplementInterface { + get { + return ResourceManager.GetString("TypeNotImplementInterface", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type {0} does not from required type {1}. + /// + internal static string TypeNotInheritFromType { + get { + return ResourceManager.GetString("TypeNotInheritFromType", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to To specify a setup for public property {0}.{1}, use the typed overloads, such as: + ///mock.Setup(x => x.{1}).Returns(value); + ///mock.SetupGet(x => x.{1}).Returns(value); //equivalent to previous one + ///mock.SetupSet(x => x.{1}).Callback(callbackDelegate); + ///. + /// + internal static string UnexpectedPublicProperty { + get { + return ResourceManager.GetString("UnexpectedPublicProperty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unexpected translation of a member access: {0}. + /// + internal static string UnexpectedTranslationOfMemberAccess { + get { + return ResourceManager.GetString("UnexpectedTranslationOfMemberAccess", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unhandled binding type: {0}. + /// + internal static string UnhandledBindingType { + get { + return ResourceManager.GetString("UnhandledBindingType", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unhandled expression type: {0}. + /// + internal static string UnhandledExpressionType { + get { + return ResourceManager.GetString("UnhandledExpressionType", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The following setups on mock '{0}' were not matched: + ///{1}. + /// + internal static string UnmatchedSetups { + get { + return ResourceManager.GetString("UnmatchedSetups", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unsupported expression: {0}. + /// + internal static string UnsupportedExpression { + get { + return ResourceManager.GetString("UnsupportedExpression", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Member {0} is not supported for protected mocking.. + /// + internal static string UnsupportedMember { + get { + return ResourceManager.GetString("UnsupportedMember", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The following invocations were not verified: + ///{0}. + /// + internal static string UnverifiedInvocations { + get { + return ResourceManager.GetString("UnverifiedInvocations", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Use ItExpr.IsNull<TValue> rather than a null argument value, as it prevents proper method lookup.. + /// + internal static string UseItExprIsNullRatherThanNullArgumentValue { + get { + return ResourceManager.GetString("UseItExprIsNullRatherThanNullArgumentValue", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid verify on an extension method: {0}. + /// + internal static string VerifyOnExtensionMethod { + get { + return ResourceManager.GetString("VerifyOnExtensionMethod", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid verify on a non-virtual (overridable in VB) member: {0}. + /// + internal static string VerifyOnNonVirtualMember { + get { + return ResourceManager.GetString("VerifyOnNonVirtualMember", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid verify on a static member: {0}. + /// + internal static string VerifyOnStaticMember { + get { + return ResourceManager.GetString("VerifyOnStaticMember", resourceCulture); + } + } + } } diff --git a/src/Moq/Properties/Resources.resx b/src/Moq/Properties/Resources.resx index e2a1e4bc9..12b350e67 100644 --- a/src/Moq/Properties/Resources.resx +++ b/src/Moq/Properties/Resources.resx @@ -1,351 +1,354 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Expression {0} involves a field access, which is not supported. Use properties instead. - - - Type to mock must be an interface or an abstract or non-sealed class. - - - {0} invocation failed with mock behavior {1}. + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Expression {0} involves a field access, which is not supported. Use properties instead. + + + Type to mock must be an interface or an abstract or non-sealed class. + + + {0} invocation failed with mock behavior {1}. {2} - - - Unsupported expression: {0} - - - All invocations on the mock must have a corresponding setup. - - - Invocation needs to return a value and therefore must have a corresponding setup that provides it. - - - The following setups on mock '{0}' were not matched: + + + Unsupported expression: {0} + + + All invocations on the mock must have a corresponding setup. + + + Invocation needs to return a value and therefore must have a corresponding setup that provides it. + + + The following setups on mock '{0}' were not matched: {1} - - - Constructor arguments cannot be passed for interface mocks. - - - Constructor arguments cannot be passed for delegate mocks. - - - A matching constructor for the given arguments was not found on the mocked type. - - - Expected only one call to {0}. - - - Object instance was not created by Moq. - - - Expression is not a property access: {0} - - - Method {0}.{1} is public. Use strong-typed Expect overload instead: + + + Constructor arguments cannot be passed for interface mocks. + + + Constructor arguments cannot be passed for delegate mocks. + + + A matching constructor for the given arguments was not found on the mocked type. + + + Expected only one call to {0}. + + + Object instance was not created by Moq. + + + Expression is not a property access: {0} + + + Method {0}.{1} is public. Use strong-typed Expect overload instead: mock.Setup(x => x.{1}()); - - - Member {0}.{1} does not exist. - - - To specify a setup for public property {0}.{1}, use the typed overloads, such as: + + + Member {0}.{1} does not exist. + + + To specify a setup for public property {0}.{1}, use the typed overloads, such as: mock.Setup(x => x.{1}).Returns(value); mock.SetupGet(x => x.{1}).Returns(value); //equivalent to previous one mock.SetupSet(x => x.{1}).Callback(callbackDelegate); - - - Can't set return value for void method {0}. - - - Member {0} is not supported for protected mocking. - - - Cannot raise a mocked event unless it has been associated (attached) to a concrete event in a mocked object. - - - Expression is not a method invocation: {0} - - - {0} + + + Can't set return value for void method {0}. + + + Member {0} is not supported for protected mocking. + + + Cannot raise a mocked event unless it has been associated (attached) to a concrete event in a mocked object. + + + Expression is not a method invocation: {0} + + + {0} Expected invocation on the mock at least once, but was never performed: {1} - - - Mock type has already been initialized by accessing its Object property. Adding interfaces must be done before that. - - - Can only add interfaces to the mock. - - - Cannot retrieve a mock with the given object type {0} as it's not the main type of the mock or any of its additional interfaces. + + + Mock type has already been initialized by accessing its Object property. Adding interfaces must be done before that. + + + Can only add interfaces to the mock. + + + Cannot retrieve a mock with the given object type {0} as it's not the main type of the mock or any of its additional interfaces. Please cast the argument to one of the supported types: {1}. Remember that there's no generics covariance in the CLR, so your object must be one of these types in order for the call to succeed. - - - Expected only {0} calls to {1}. - - - Expression is not a property setter invocation. - - - Value cannot be an empty string. - - - Type {0} does not implement required interface {1} - - - Type {0} does not from required type {1} - - - {0} + + + Expected only {0} calls to {1}. + + + Expression is not a property setter invocation. + + + Value cannot be an empty string. + + + Type {0} does not implement required interface {1} + + + Type {0} does not from required type {1} + + + {0} Expected invocation on the mock at least {2} times, but was {4} times: {1} - - - {0} + + + {0} Expected invocation on the mock at most {3} times, but was {4} times: {1} - - - {0} + + + {0} Expected invocation on the mock at most once, but was {4} times: {1} - - - {0} + + + {0} Expected invocation on the mock between {2} and {3} times (Inclusive), but was {4} times: {1} - - - {0} + + + {0} Expected invocation on the mock exactly {2} times, but was {4} times: {1} - - - {0} + + + {0} Expected invocation on the mock should never have been performed, but was {4} times: {1} - - - {0} + + + {0} Expected invocation on the mock between {2} and {3} times (Exclusive), but was {4} times: {1} - - - {0} + + + {0} Expected invocation on the mock once, but was {4} times: {1} - - - Out expression must evaluate to a constant value. - - - Ref expression must evaluate to a constant value. - - - LINQ method '{0}' not supported. - - - Could not locate event for attach or detach method {0}. - - - The equals ("==" or "=" in VB) and the conditional 'and' ("&&" or "AndAlso" in VB) operators are the only ones supported in the query specification expression. Unsupported expression: {0} - - - Expression contains a call to a method which is not virtual (overridable in VB) or abstract. Unsupported expression: {0} - - - Property {0}.{1} does not have a setter. - - - Property {0}.{1} does not have a getter. - - - Invalid setup on a non-virtual (overridable in VB) member: {0} - - - Invalid verify on a non-virtual (overridable in VB) member: {0} - - - Invalid setup on a static member: {0} - - - Invalid verify on a static member: {0} - - - Invalid setup on an extension method: {0} - - - Invalid verify on an extension method: {0} - - - Unhandled binding type: {0} - - - Unhandled expression type: {0} - - - Configured setups: {0} - - - Delays have to be greater than zero to ensure an async callback is used. - - - Expression is not an event attach or detach, or the event is declared in a class but not marked virtual. - - - Invalid callback. Setup on method with parameters ({0}) cannot invoke callback with parameters ({1}). - - - Minimum delay has to be lower than maximum delay. - - - No invocations performed. - - - No setups configured. - - - Performed invocations: {0} - - - Unexpected translation of a member access: {0} - - - Use ItExpr.IsNull<TValue> rather than a null argument value, as it prevents proper method lookup. - - - Cannot set up {0}.{1} because it is not accessible to the proxy generator used by Moq: + + + Out expression must evaluate to a constant value. + + + Ref expression must evaluate to a constant value. + + + LINQ method '{0}' not supported. + + + Could not locate event for attach or detach method {0}. + + + The equals ("==" or "=" in VB) and the conditional 'and' ("&&" or "AndAlso" in VB) operators are the only ones supported in the query specification expression. Unsupported expression: {0} + + + Expression contains a call to a method which is not virtual (overridable in VB) or abstract. Unsupported expression: {0} + + + Property {0}.{1} does not have a setter. + + + Property {0}.{1} does not have a getter. + + + Invalid setup on a non-virtual (overridable in VB) member: {0} + + + Invalid verify on a non-virtual (overridable in VB) member: {0} + + + Invalid setup on a static member: {0} + + + Invalid verify on a static member: {0} + + + Invalid setup on an extension method: {0} + + + Invalid verify on an extension method: {0} + + + Unhandled binding type: {0} + + + Unhandled expression type: {0} + + + Configured setups: {0} + + + Delays have to be greater than zero to ensure an async callback is used. + + + Expression is not an event attach or detach, or the event is declared in a class but not marked virtual. + + + Invalid callback. Setup on method with parameters ({0}) cannot invoke callback with parameters ({1}). + + + Minimum delay has to be lower than maximum delay. + + + No invocations performed. + + + No setups configured. + + + Performed invocations: {0} + + + Unexpected translation of a member access: {0} + + + Use ItExpr.IsNull<TValue> rather than a null argument value, as it prevents proper method lookup. + + + Cannot set up {0}.{1} because it is not accessible to the proxy generator used by Moq: {2} - - - Invalid callback. This overload of the "Callback" method only accepts "void" (C#) or "Sub" (VB.NET) delegates with parameter types matching those of the set up method. - - - Invalid callback. This overload of the "Returns" method only accepts non-"void" (C#) or "Function" (VB.NET) delegates with parameter types matching those of the set up method. - - - Type {0} does not have matching protected member: {1} - - - Invalid callback. Setup on method with return type ({0}) cannot invoke callback with return type ({1}). - - - Invalid callback. Setup on method with {0} parameter(s) cannot invoke callback with different number of parameters ({1}). - - - The following invocations on mock '{0}' were not verified: + + + Invalid callback. This overload of the "Callback" method only accepts "void" (C#) or "Sub" (VB.NET) delegates with parameter types matching those of the set up method. + + + Invalid callback. This overload of the "Returns" method only accepts non-"void" (C#) or "Function" (VB.NET) delegates with parameter types matching those of the set up method. + + + Type {0} does not have matching protected member: {1} + + + Invalid callback. Setup on method with return type ({0}) cannot invoke callback with return type ({1}). + + + Invalid callback. Setup on method with {0} parameter(s) cannot invoke callback with different number of parameters ({1}). + + + The following invocations on mock '{0}' were not verified: {1} - + + + CallBase cannot be used to mock Delegate types. + \ No newline at end of file diff --git a/tests/Moq.Tests/Regressions/IssueReportsFixture.cs b/tests/Moq.Tests/Regressions/IssueReportsFixture.cs index f23dd1fa4..77ca8f58b 100644 --- a/tests/Moq.Tests/Regressions/IssueReportsFixture.cs +++ b/tests/Moq.Tests/Regressions/IssueReportsFixture.cs @@ -9,6 +9,7 @@ using System.Data.Entity.Core.EntityClient; #endif using System.ComponentModel; +using System.Globalization; using System.IO; using System.Linq; using System.Linq.Expressions; @@ -2020,7 +2021,7 @@ public void CallBase_should_not_be_allowed_for_delegate_mocks() Language.Flow.ISetup setup = mock.Setup(m => m()); Exception ex = Assert.Throws(() => setup.CallBase()); - Assert.Equal(ex.Message, "CallBase cannot be used to mock delegates."); + Assert.Equal(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseUsedOnDelegateException), ex.Message); } } From 3236003402df21cfd4d6233f7c5054fc08849c97 Mon Sep 17 00:00:00 2001 From: Michael Wildman Date: Tue, 16 Oct 2018 00:59:46 +1300 Subject: [PATCH 03/13] Add failing test for issue #706 setting CallBase property --- tests/Moq.Tests/Regressions/IssueReportsFixture.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/Moq.Tests/Regressions/IssueReportsFixture.cs b/tests/Moq.Tests/Regressions/IssueReportsFixture.cs index 77ca8f58b..af0a6da79 100644 --- a/tests/Moq.Tests/Regressions/IssueReportsFixture.cs +++ b/tests/Moq.Tests/Regressions/IssueReportsFixture.cs @@ -2023,6 +2023,15 @@ public void CallBase_should_not_be_allowed_for_delegate_mocks() Exception ex = Assert.Throws(() => setup.CallBase()); Assert.Equal(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseUsedOnDelegateException), ex.Message); } + + [Fact] + public void CallBase_property_should_not_be_allowed_for_delegate_mocks() + { + Mock mock = new Mock(); + + Exception ex = Assert.Throws(() => mock.CallBase = true); + Assert.Equal(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseUsedOnDelegateException), ex.Message); + } } #endregion From 1a4c5e22d9341560801a198f5f891a25ca6a0518 Mon Sep 17 00:00:00 2001 From: Michael Wildman Date: Tue, 16 Oct 2018 00:59:46 +1300 Subject: [PATCH 04/13] Throw a NotSupportedException when setting CallBase on a Delegate --- src/Moq/Mock.Generic.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Moq/Mock.Generic.cs b/src/Moq/Mock.Generic.cs index 9823ef6fd..45753204c 100644 --- a/src/Moq/Mock.Generic.cs +++ b/src/Moq/Mock.Generic.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.Linq; using System.Linq.Expressions; using System.Reflection; @@ -18,6 +19,7 @@ using Moq.Language; using Moq.Language.Flow; +using Moq.Properties; namespace Moq { @@ -164,7 +166,15 @@ private void CheckParameters() public override bool CallBase { get => this.callBase; - set => this.callBase = value; + set + { + if (typeof(Delegate).IsAssignableFrom(this.MockedType)) + { + throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseUsedOnDelegateException)); + } + + this.callBase = value; + } } internal override Dictionary ConfiguredDefaultValues => this.configuredDefaultValues; From b2fbc0c1b76eb80d1d75faefacae9ef6600f7a89 Mon Sep 17 00:00:00 2001 From: Michael Wildman Date: Tue, 16 Oct 2018 00:59:46 +1300 Subject: [PATCH 05/13] revert changes to resx --- src/Moq/Properties/Resources.Designer.cs | 1413 +++++++++++----------- src/Moq/Properties/Resources.resx | 655 +++++----- 2 files changed, 1028 insertions(+), 1040 deletions(-) diff --git a/src/Moq/Properties/Resources.Designer.cs b/src/Moq/Properties/Resources.Designer.cs index ed6a4bee6..23e17f0dc 100644 --- a/src/Moq/Properties/Resources.Designer.cs +++ b/src/Moq/Properties/Resources.Designer.cs @@ -9,715 +9,706 @@ //------------------------------------------------------------------------------ namespace Moq.Properties { - using System; - using System.Reflection; - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Moq.Properties.Resources", typeof(Resources).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Mock type has already been initialized by accessing its Object property. Adding interfaces must be done before that.. - /// - internal static string AlreadyInitialized { - get { - return ResourceManager.GetString("AlreadyInitialized", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Value cannot be an empty string.. - /// - internal static string ArgumentCannotBeEmpty { - get { - return ResourceManager.GetString("ArgumentCannotBeEmpty", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Can only add interfaces to the mock.. - /// - internal static string AsMustBeInterface { - get { - return ResourceManager.GetString("AsMustBeInterface", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to CallBase cannot be used to mock Delegate types.. - /// - internal static string CallBaseUsedOnDelegateException { - get { - return ResourceManager.GetString("CallBaseUsedOnDelegateException", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Can't set return value for void method {0}.. - /// - internal static string CantSetReturnValueForVoid { - get { - return ResourceManager.GetString("CantSetReturnValueForVoid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Configured setups: {0}. - /// - internal static string ConfiguredSetups { - get { - return ResourceManager.GetString("ConfiguredSetups", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Constructor arguments cannot be passed for delegate mocks.. - /// - internal static string ConstructorArgsForDelegate { - get { - return ResourceManager.GetString("ConstructorArgsForDelegate", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Constructor arguments cannot be passed for interface mocks.. - /// - internal static string ConstructorArgsForInterface { - get { - return ResourceManager.GetString("ConstructorArgsForInterface", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A matching constructor for the given arguments was not found on the mocked type.. - /// - internal static string ConstructorNotFound { - get { - return ResourceManager.GetString("ConstructorNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Delays have to be greater than zero to ensure an async callback is used.. - /// - internal static string DelaysMustBeGreaterThanZero { - get { - return ResourceManager.GetString("DelaysMustBeGreaterThanZero", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Could not locate event for attach or detach method {0}.. - /// - internal static string EventNotFound { - get { - return ResourceManager.GetString("EventNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expression is not an event attach or detach, or the event is declared in a class but not marked virtual.. - /// - internal static string ExpressionIsNotEventAttachOrDetachOrIsNotVirtual { - get { - return ResourceManager.GetString("ExpressionIsNotEventAttachOrDetachOrIsNotVirtual", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expression {0} involves a field access, which is not supported. Use properties instead.. - /// - internal static string FieldsNotSupported { - get { - return ResourceManager.GetString("FieldsNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid callback. This overload of the "Callback" method only accepts "void" (C#) or "Sub" (VB.NET) delegates with parameter types matching those of the set up method.. - /// - internal static string InvalidCallbackNotADelegateWithReturnTypeVoid { - get { - return ResourceManager.GetString("InvalidCallbackNotADelegateWithReturnTypeVoid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid callback. Setup on method with {0} parameter(s) cannot invoke callback with different number of parameters ({1}).. - /// - internal static string InvalidCallbackParameterCountMismatch { - get { - return ResourceManager.GetString("InvalidCallbackParameterCountMismatch", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid callback. Setup on method with parameters ({0}) cannot invoke callback with parameters ({1}).. - /// - internal static string InvalidCallbackParameterMismatch { - get { - return ResourceManager.GetString("InvalidCallbackParameterMismatch", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid callback. Setup on method with return type ({0}) cannot invoke callback with return type ({1}).. - /// - internal static string InvalidCallbackReturnTypeMismatch { - get { - return ResourceManager.GetString("InvalidCallbackReturnTypeMismatch", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type to mock must be an interface or an abstract or non-sealed class. . - /// - internal static string InvalidMockClass { - get { - return ResourceManager.GetString("InvalidMockClass", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot retrieve a mock with the given object type {0} as it's not the main type of the mock or any of its additional interfaces. - ///Please cast the argument to one of the supported types: {1}. - ///Remember that there's no generics covariance in the CLR, so your object must be one of these types in order for the call to succeed.. - /// - internal static string InvalidMockGetType { - get { - return ResourceManager.GetString("InvalidMockGetType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid callback. This overload of the "Returns" method only accepts non-"void" (C#) or "Function" (VB.NET) delegates with parameter types matching those of the set up method.. - /// - internal static string InvalidReturnsCallbackNotADelegateWithReturnType { - get { - return ResourceManager.GetString("InvalidReturnsCallbackNotADelegateWithReturnType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The equals ("==" or "=" in VB) and the conditional 'and' ("&&" or "AndAlso" in VB) operators are the only ones supported in the query specification expression. Unsupported expression: {0}. - /// - internal static string LinqBinaryOperatorNotSupported { - get { - return ResourceManager.GetString("LinqBinaryOperatorNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to LINQ method '{0}' not supported.. - /// - internal static string LinqMethodNotSupported { - get { - return ResourceManager.GetString("LinqMethodNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expression contains a call to a method which is not virtual (overridable in VB) or abstract. Unsupported expression: {0}. - /// - internal static string LinqMethodNotVirtual { - get { - return ResourceManager.GetString("LinqMethodNotVirtual", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Member {0}.{1} does not exist.. - /// - internal static string MemberMissing { - get { - return ResourceManager.GetString("MemberMissing", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Method {0}.{1} is public. Use strong-typed Expect overload instead: - ///mock.Setup(x => x.{1}()); - ///. - /// - internal static string MethodIsPublic { - get { - return ResourceManager.GetString("MethodIsPublic", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot set up {0}.{1} because it is not accessible to the proxy generator used by Moq: - ///{2}. - /// - internal static string MethodNotVisibleToProxyFactory { - get { - return ResourceManager.GetString("MethodNotVisibleToProxyFactory", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Minimum delay has to be lower than maximum delay.. - /// - internal static string MinDelayMustBeLessThanMaxDelay { - get { - return ResourceManager.GetString("MinDelayMustBeLessThanMaxDelay", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} invocation failed with mock behavior {1}. - ///{2}. - /// - internal static string MockExceptionMessage { - get { - return ResourceManager.GetString("MockExceptionMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expected only {0} calls to {1}.. - /// - internal static string MoreThanNCalls { - get { - return ResourceManager.GetString("MoreThanNCalls", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expected only one call to {0}.. - /// - internal static string MoreThanOneCall { - get { - return ResourceManager.GetString("MoreThanOneCall", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No invocations performed.. - /// - internal static string NoInvocationsPerformed { - get { - return ResourceManager.GetString("NoInvocationsPerformed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock at least {2} times, but was {4} times: {1}. - /// - internal static string NoMatchingCallsAtLeast { - get { - return ResourceManager.GetString("NoMatchingCallsAtLeast", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock at least once, but was never performed: {1}. - /// - internal static string NoMatchingCallsAtLeastOnce { - get { - return ResourceManager.GetString("NoMatchingCallsAtLeastOnce", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock at most {3} times, but was {4} times: {1}. - /// - internal static string NoMatchingCallsAtMost { - get { - return ResourceManager.GetString("NoMatchingCallsAtMost", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock at most once, but was {4} times: {1}. - /// - internal static string NoMatchingCallsAtMostOnce { - get { - return ResourceManager.GetString("NoMatchingCallsAtMostOnce", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock between {2} and {3} times (Exclusive), but was {4} times: {1}. - /// - internal static string NoMatchingCallsBetweenExclusive { - get { - return ResourceManager.GetString("NoMatchingCallsBetweenExclusive", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock between {2} and {3} times (Inclusive), but was {4} times: {1}. - /// - internal static string NoMatchingCallsBetweenInclusive { - get { - return ResourceManager.GetString("NoMatchingCallsBetweenInclusive", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock exactly {2} times, but was {4} times: {1}. - /// - internal static string NoMatchingCallsExactly { - get { - return ResourceManager.GetString("NoMatchingCallsExactly", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock should never have been performed, but was {4} times: {1}. - /// - internal static string NoMatchingCallsNever { - get { - return ResourceManager.GetString("NoMatchingCallsNever", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} - ///Expected invocation on the mock once, but was {4} times: {1}. - /// - internal static string NoMatchingCallsOnce { - get { - return ResourceManager.GetString("NoMatchingCallsOnce", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to All invocations on the mock must have a corresponding setup.. - /// - internal static string NoSetup { - get { - return ResourceManager.GetString("NoSetup", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No setups configured.. - /// - internal static string NoSetupsConfigured { - get { - return ResourceManager.GetString("NoSetupsConfigured", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Object instance was not created by Moq.. - /// - internal static string ObjectInstanceNotMock { - get { - return ResourceManager.GetString("ObjectInstanceNotMock", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Out expression must evaluate to a constant value.. - /// - internal static string OutExpressionMustBeConstantValue { - get { - return ResourceManager.GetString("OutExpressionMustBeConstantValue", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Performed invocations: {0}. - /// - internal static string PerformedInvocations { - get { - return ResourceManager.GetString("PerformedInvocations", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Property {0}.{1} does not have a getter.. - /// - internal static string PropertyGetNotFound { - get { - return ResourceManager.GetString("PropertyGetNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Property {0}.{1} does not have a setter.. - /// - internal static string PropertySetNotFound { - get { - return ResourceManager.GetString("PropertySetNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type {0} does not have matching protected member: {1}. - /// - internal static string ProtectedMemberNotFound { - get { - return ResourceManager.GetString("ProtectedMemberNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot raise a mocked event unless it has been associated (attached) to a concrete event in a mocked object.. - /// - internal static string RaisedUnassociatedEvent { - get { - return ResourceManager.GetString("RaisedUnassociatedEvent", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ref expression must evaluate to a constant value.. - /// - internal static string RefExpressionMustBeConstantValue { - get { - return ResourceManager.GetString("RefExpressionMustBeConstantValue", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invocation needs to return a value and therefore must have a corresponding setup that provides it.. - /// - internal static string ReturnValueRequired { - get { - return ResourceManager.GetString("ReturnValueRequired", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expression is not a method invocation: {0}. - /// - internal static string SetupNotMethod { - get { - return ResourceManager.GetString("SetupNotMethod", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expression is not a property access: {0}. - /// - internal static string SetupNotProperty { - get { - return ResourceManager.GetString("SetupNotProperty", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expression is not a property setter invocation.. - /// - internal static string SetupNotSetter { - get { - return ResourceManager.GetString("SetupNotSetter", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid setup on an extension method: {0}. - /// - internal static string SetupOnExtensionMethod { - get { - return ResourceManager.GetString("SetupOnExtensionMethod", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid setup on a non-virtual (overridable in VB) member: {0}. - /// - internal static string SetupOnNonVirtualMember { - get { - return ResourceManager.GetString("SetupOnNonVirtualMember", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid setup on a static member: {0}. - /// - internal static string SetupOnStaticMember { - get { - return ResourceManager.GetString("SetupOnStaticMember", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type {0} does not implement required interface {1}. - /// - internal static string TypeNotImplementInterface { - get { - return ResourceManager.GetString("TypeNotImplementInterface", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type {0} does not from required type {1}. - /// - internal static string TypeNotInheritFromType { - get { - return ResourceManager.GetString("TypeNotInheritFromType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to To specify a setup for public property {0}.{1}, use the typed overloads, such as: - ///mock.Setup(x => x.{1}).Returns(value); - ///mock.SetupGet(x => x.{1}).Returns(value); //equivalent to previous one - ///mock.SetupSet(x => x.{1}).Callback(callbackDelegate); - ///. - /// - internal static string UnexpectedPublicProperty { - get { - return ResourceManager.GetString("UnexpectedPublicProperty", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unexpected translation of a member access: {0}. - /// - internal static string UnexpectedTranslationOfMemberAccess { - get { - return ResourceManager.GetString("UnexpectedTranslationOfMemberAccess", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unhandled binding type: {0}. - /// - internal static string UnhandledBindingType { - get { - return ResourceManager.GetString("UnhandledBindingType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unhandled expression type: {0}. - /// - internal static string UnhandledExpressionType { - get { - return ResourceManager.GetString("UnhandledExpressionType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The following setups on mock '{0}' were not matched: - ///{1}. - /// - internal static string UnmatchedSetups { - get { - return ResourceManager.GetString("UnmatchedSetups", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unsupported expression: {0}. - /// - internal static string UnsupportedExpression { - get { - return ResourceManager.GetString("UnsupportedExpression", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Member {0} is not supported for protected mocking.. - /// - internal static string UnsupportedMember { - get { - return ResourceManager.GetString("UnsupportedMember", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The following invocations were not verified: - ///{0}. - /// - internal static string UnverifiedInvocations { - get { - return ResourceManager.GetString("UnverifiedInvocations", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use ItExpr.IsNull<TValue> rather than a null argument value, as it prevents proper method lookup.. - /// - internal static string UseItExprIsNullRatherThanNullArgumentValue { - get { - return ResourceManager.GetString("UseItExprIsNullRatherThanNullArgumentValue", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid verify on an extension method: {0}. - /// - internal static string VerifyOnExtensionMethod { - get { - return ResourceManager.GetString("VerifyOnExtensionMethod", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid verify on a non-virtual (overridable in VB) member: {0}. - /// - internal static string VerifyOnNonVirtualMember { - get { - return ResourceManager.GetString("VerifyOnNonVirtualMember", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid verify on a static member: {0}. - /// - internal static string VerifyOnStaticMember { - get { - return ResourceManager.GetString("VerifyOnStaticMember", resourceCulture); - } - } - } + using System; + using System.Reflection; + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Moq.Properties.Resources", typeof(Resources).GetTypeInfo().Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Mock type has already been initialized by accessing its Object property. Adding interfaces must be done before that.. + /// + internal static string AlreadyInitialized { + get { + return ResourceManager.GetString("AlreadyInitialized", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value cannot be an empty string.. + /// + internal static string ArgumentCannotBeEmpty { + get { + return ResourceManager.GetString("ArgumentCannotBeEmpty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Can only add interfaces to the mock.. + /// + internal static string AsMustBeInterface { + get { + return ResourceManager.GetString("AsMustBeInterface", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Can't set return value for void method {0}.. + /// + internal static string CantSetReturnValueForVoid { + get { + return ResourceManager.GetString("CantSetReturnValueForVoid", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Configured setups: {0}. + /// + internal static string ConfiguredSetups { + get { + return ResourceManager.GetString("ConfiguredSetups", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Constructor arguments cannot be passed for delegate mocks.. + /// + internal static string ConstructorArgsForDelegate { + get { + return ResourceManager.GetString("ConstructorArgsForDelegate", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Constructor arguments cannot be passed for interface mocks.. + /// + internal static string ConstructorArgsForInterface { + get { + return ResourceManager.GetString("ConstructorArgsForInterface", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A matching constructor for the given arguments was not found on the mocked type.. + /// + internal static string ConstructorNotFound { + get { + return ResourceManager.GetString("ConstructorNotFound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Delays have to be greater than zero to ensure an async callback is used.. + /// + internal static string DelaysMustBeGreaterThanZero { + get { + return ResourceManager.GetString("DelaysMustBeGreaterThanZero", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Could not locate event for attach or detach method {0}.. + /// + internal static string EventNotFound { + get { + return ResourceManager.GetString("EventNotFound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expression is not an event attach or detach, or the event is declared in a class but not marked virtual.. + /// + internal static string ExpressionIsNotEventAttachOrDetachOrIsNotVirtual { + get { + return ResourceManager.GetString("ExpressionIsNotEventAttachOrDetachOrIsNotVirtual", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expression {0} involves a field access, which is not supported. Use properties instead.. + /// + internal static string FieldsNotSupported { + get { + return ResourceManager.GetString("FieldsNotSupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid callback. This overload of the "Callback" method only accepts "void" (C#) or "Sub" (VB.NET) delegates with parameter types matching those of the set up method.. + /// + internal static string InvalidCallbackNotADelegateWithReturnTypeVoid { + get { + return ResourceManager.GetString("InvalidCallbackNotADelegateWithReturnTypeVoid", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid callback. Setup on method with {0} parameter(s) cannot invoke callback with different number of parameters ({1}).. + /// + internal static string InvalidCallbackParameterCountMismatch { + get { + return ResourceManager.GetString("InvalidCallbackParameterCountMismatch", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid callback. Setup on method with parameters ({0}) cannot invoke callback with parameters ({1}).. + /// + internal static string InvalidCallbackParameterMismatch { + get { + return ResourceManager.GetString("InvalidCallbackParameterMismatch", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid callback. Setup on method with return type ({0}) cannot invoke callback with return type ({1}).. + /// + internal static string InvalidCallbackReturnTypeMismatch { + get { + return ResourceManager.GetString("InvalidCallbackReturnTypeMismatch", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type to mock must be an interface or an abstract or non-sealed class. . + /// + internal static string InvalidMockClass { + get { + return ResourceManager.GetString("InvalidMockClass", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cannot retrieve a mock with the given object type {0} as it's not the main type of the mock or any of its additional interfaces. + ///Please cast the argument to one of the supported types: {1}. + ///Remember that there's no generics covariance in the CLR, so your object must be one of these types in order for the call to succeed.. + /// + internal static string InvalidMockGetType { + get { + return ResourceManager.GetString("InvalidMockGetType", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid callback. This overload of the "Returns" method only accepts non-"void" (C#) or "Function" (VB.NET) delegates with parameter types matching those of the set up method.. + /// + internal static string InvalidReturnsCallbackNotADelegateWithReturnType { + get { + return ResourceManager.GetString("InvalidReturnsCallbackNotADelegateWithReturnType", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The equals ("==" or "=" in VB) and the conditional 'and' ("&&" or "AndAlso" in VB) operators are the only ones supported in the query specification expression. Unsupported expression: {0}. + /// + internal static string LinqBinaryOperatorNotSupported { + get { + return ResourceManager.GetString("LinqBinaryOperatorNotSupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to LINQ method '{0}' not supported.. + /// + internal static string LinqMethodNotSupported { + get { + return ResourceManager.GetString("LinqMethodNotSupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expression contains a call to a method which is not virtual (overridable in VB) or abstract. Unsupported expression: {0}. + /// + internal static string LinqMethodNotVirtual { + get { + return ResourceManager.GetString("LinqMethodNotVirtual", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Member {0}.{1} does not exist.. + /// + internal static string MemberMissing { + get { + return ResourceManager.GetString("MemberMissing", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Method {0}.{1} is public. Use strong-typed Expect overload instead: + ///mock.Setup(x => x.{1}()); + ///. + /// + internal static string MethodIsPublic { + get { + return ResourceManager.GetString("MethodIsPublic", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cannot set up {0}.{1} because it is not accessible to the proxy generator used by Moq: + ///{2}. + /// + internal static string MethodNotVisibleToProxyFactory { + get { + return ResourceManager.GetString("MethodNotVisibleToProxyFactory", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Minimum delay has to be lower than maximum delay.. + /// + internal static string MinDelayMustBeLessThanMaxDelay { + get { + return ResourceManager.GetString("MinDelayMustBeLessThanMaxDelay", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} invocation failed with mock behavior {1}. + ///{2}. + /// + internal static string MockExceptionMessage { + get { + return ResourceManager.GetString("MockExceptionMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expected only {0} calls to {1}.. + /// + internal static string MoreThanNCalls { + get { + return ResourceManager.GetString("MoreThanNCalls", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expected only one call to {0}.. + /// + internal static string MoreThanOneCall { + get { + return ResourceManager.GetString("MoreThanOneCall", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No invocations performed.. + /// + internal static string NoInvocationsPerformed { + get { + return ResourceManager.GetString("NoInvocationsPerformed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock at least {2} times, but was {4} times: {1}. + /// + internal static string NoMatchingCallsAtLeast { + get { + return ResourceManager.GetString("NoMatchingCallsAtLeast", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock at least once, but was never performed: {1}. + /// + internal static string NoMatchingCallsAtLeastOnce { + get { + return ResourceManager.GetString("NoMatchingCallsAtLeastOnce", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock at most {3} times, but was {4} times: {1}. + /// + internal static string NoMatchingCallsAtMost { + get { + return ResourceManager.GetString("NoMatchingCallsAtMost", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock at most once, but was {4} times: {1}. + /// + internal static string NoMatchingCallsAtMostOnce { + get { + return ResourceManager.GetString("NoMatchingCallsAtMostOnce", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock between {2} and {3} times (Exclusive), but was {4} times: {1}. + /// + internal static string NoMatchingCallsBetweenExclusive { + get { + return ResourceManager.GetString("NoMatchingCallsBetweenExclusive", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock between {2} and {3} times (Inclusive), but was {4} times: {1}. + /// + internal static string NoMatchingCallsBetweenInclusive { + get { + return ResourceManager.GetString("NoMatchingCallsBetweenInclusive", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock exactly {2} times, but was {4} times: {1}. + /// + internal static string NoMatchingCallsExactly { + get { + return ResourceManager.GetString("NoMatchingCallsExactly", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock should never have been performed, but was {4} times: {1}. + /// + internal static string NoMatchingCallsNever { + get { + return ResourceManager.GetString("NoMatchingCallsNever", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} + ///Expected invocation on the mock once, but was {4} times: {1}. + /// + internal static string NoMatchingCallsOnce { + get { + return ResourceManager.GetString("NoMatchingCallsOnce", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to All invocations on the mock must have a corresponding setup.. + /// + internal static string NoSetup { + get { + return ResourceManager.GetString("NoSetup", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No setups configured.. + /// + internal static string NoSetupsConfigured { + get { + return ResourceManager.GetString("NoSetupsConfigured", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Object instance was not created by Moq.. + /// + internal static string ObjectInstanceNotMock { + get { + return ResourceManager.GetString("ObjectInstanceNotMock", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Out expression must evaluate to a constant value.. + /// + internal static string OutExpressionMustBeConstantValue { + get { + return ResourceManager.GetString("OutExpressionMustBeConstantValue", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Performed invocations: {0}. + /// + internal static string PerformedInvocations { + get { + return ResourceManager.GetString("PerformedInvocations", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Property {0}.{1} does not have a getter.. + /// + internal static string PropertyGetNotFound { + get { + return ResourceManager.GetString("PropertyGetNotFound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Property {0}.{1} does not have a setter.. + /// + internal static string PropertySetNotFound { + get { + return ResourceManager.GetString("PropertySetNotFound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type {0} does not have matching protected member: {1}. + /// + internal static string ProtectedMemberNotFound { + get { + return ResourceManager.GetString("ProtectedMemberNotFound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cannot raise a mocked event unless it has been associated (attached) to a concrete event in a mocked object.. + /// + internal static string RaisedUnassociatedEvent { + get { + return ResourceManager.GetString("RaisedUnassociatedEvent", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Ref expression must evaluate to a constant value.. + /// + internal static string RefExpressionMustBeConstantValue { + get { + return ResourceManager.GetString("RefExpressionMustBeConstantValue", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invocation needs to return a value and therefore must have a corresponding setup that provides it.. + /// + internal static string ReturnValueRequired { + get { + return ResourceManager.GetString("ReturnValueRequired", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expression is not a method invocation: {0}. + /// + internal static string SetupNotMethod { + get { + return ResourceManager.GetString("SetupNotMethod", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expression is not a property access: {0}. + /// + internal static string SetupNotProperty { + get { + return ResourceManager.GetString("SetupNotProperty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expression is not a property setter invocation.. + /// + internal static string SetupNotSetter { + get { + return ResourceManager.GetString("SetupNotSetter", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid setup on an extension method: {0}. + /// + internal static string SetupOnExtensionMethod { + get { + return ResourceManager.GetString("SetupOnExtensionMethod", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid setup on a non-virtual (overridable in VB) member: {0}. + /// + internal static string SetupOnNonVirtualMember { + get { + return ResourceManager.GetString("SetupOnNonVirtualMember", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid setup on a static member: {0}. + /// + internal static string SetupOnStaticMember { + get { + return ResourceManager.GetString("SetupOnStaticMember", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type {0} does not implement required interface {1}. + /// + internal static string TypeNotImplementInterface { + get { + return ResourceManager.GetString("TypeNotImplementInterface", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type {0} does not from required type {1}. + /// + internal static string TypeNotInheritFromType { + get { + return ResourceManager.GetString("TypeNotInheritFromType", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to To specify a setup for public property {0}.{1}, use the typed overloads, such as: + ///mock.Setup(x => x.{1}).Returns(value); + ///mock.SetupGet(x => x.{1}).Returns(value); //equivalent to previous one + ///mock.SetupSet(x => x.{1}).Callback(callbackDelegate); + ///. + /// + internal static string UnexpectedPublicProperty { + get { + return ResourceManager.GetString("UnexpectedPublicProperty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unexpected translation of a member access: {0}. + /// + internal static string UnexpectedTranslationOfMemberAccess { + get { + return ResourceManager.GetString("UnexpectedTranslationOfMemberAccess", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unhandled binding type: {0}. + /// + internal static string UnhandledBindingType { + get { + return ResourceManager.GetString("UnhandledBindingType", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unhandled expression type: {0}. + /// + internal static string UnhandledExpressionType { + get { + return ResourceManager.GetString("UnhandledExpressionType", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The following setups on mock '{0}' were not matched: + ///{1}. + /// + internal static string UnmatchedSetups { + get { + return ResourceManager.GetString("UnmatchedSetups", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unsupported expression: {0}. + /// + internal static string UnsupportedExpression { + get { + return ResourceManager.GetString("UnsupportedExpression", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Member {0} is not supported for protected mocking.. + /// + internal static string UnsupportedMember { + get { + return ResourceManager.GetString("UnsupportedMember", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The following invocations were not verified: + ///{0}. + /// + internal static string UnverifiedInvocations { + get { + return ResourceManager.GetString("UnverifiedInvocations", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Use ItExpr.IsNull<TValue> rather than a null argument value, as it prevents proper method lookup.. + /// + internal static string UseItExprIsNullRatherThanNullArgumentValue { + get { + return ResourceManager.GetString("UseItExprIsNullRatherThanNullArgumentValue", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid verify on an extension method: {0}. + /// + internal static string VerifyOnExtensionMethod { + get { + return ResourceManager.GetString("VerifyOnExtensionMethod", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid verify on a non-virtual (overridable in VB) member: {0}. + /// + internal static string VerifyOnNonVirtualMember { + get { + return ResourceManager.GetString("VerifyOnNonVirtualMember", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid verify on a static member: {0}. + /// + internal static string VerifyOnStaticMember { + get { + return ResourceManager.GetString("VerifyOnStaticMember", resourceCulture); + } + } + } } diff --git a/src/Moq/Properties/Resources.resx b/src/Moq/Properties/Resources.resx index 12b350e67..e2a1e4bc9 100644 --- a/src/Moq/Properties/Resources.resx +++ b/src/Moq/Properties/Resources.resx @@ -1,354 +1,351 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Expression {0} involves a field access, which is not supported. Use properties instead. - - - Type to mock must be an interface or an abstract or non-sealed class. - - - {0} invocation failed with mock behavior {1}. + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Expression {0} involves a field access, which is not supported. Use properties instead. + + + Type to mock must be an interface or an abstract or non-sealed class. + + + {0} invocation failed with mock behavior {1}. {2} - - - Unsupported expression: {0} - - - All invocations on the mock must have a corresponding setup. - - - Invocation needs to return a value and therefore must have a corresponding setup that provides it. - - - The following setups on mock '{0}' were not matched: + + + Unsupported expression: {0} + + + All invocations on the mock must have a corresponding setup. + + + Invocation needs to return a value and therefore must have a corresponding setup that provides it. + + + The following setups on mock '{0}' were not matched: {1} - - - Constructor arguments cannot be passed for interface mocks. - - - Constructor arguments cannot be passed for delegate mocks. - - - A matching constructor for the given arguments was not found on the mocked type. - - - Expected only one call to {0}. - - - Object instance was not created by Moq. - - - Expression is not a property access: {0} - - - Method {0}.{1} is public. Use strong-typed Expect overload instead: + + + Constructor arguments cannot be passed for interface mocks. + + + Constructor arguments cannot be passed for delegate mocks. + + + A matching constructor for the given arguments was not found on the mocked type. + + + Expected only one call to {0}. + + + Object instance was not created by Moq. + + + Expression is not a property access: {0} + + + Method {0}.{1} is public. Use strong-typed Expect overload instead: mock.Setup(x => x.{1}()); - - - Member {0}.{1} does not exist. - - - To specify a setup for public property {0}.{1}, use the typed overloads, such as: + + + Member {0}.{1} does not exist. + + + To specify a setup for public property {0}.{1}, use the typed overloads, such as: mock.Setup(x => x.{1}).Returns(value); mock.SetupGet(x => x.{1}).Returns(value); //equivalent to previous one mock.SetupSet(x => x.{1}).Callback(callbackDelegate); - - - Can't set return value for void method {0}. - - - Member {0} is not supported for protected mocking. - - - Cannot raise a mocked event unless it has been associated (attached) to a concrete event in a mocked object. - - - Expression is not a method invocation: {0} - - - {0} + + + Can't set return value for void method {0}. + + + Member {0} is not supported for protected mocking. + + + Cannot raise a mocked event unless it has been associated (attached) to a concrete event in a mocked object. + + + Expression is not a method invocation: {0} + + + {0} Expected invocation on the mock at least once, but was never performed: {1} - - - Mock type has already been initialized by accessing its Object property. Adding interfaces must be done before that. - - - Can only add interfaces to the mock. - - - Cannot retrieve a mock with the given object type {0} as it's not the main type of the mock or any of its additional interfaces. + + + Mock type has already been initialized by accessing its Object property. Adding interfaces must be done before that. + + + Can only add interfaces to the mock. + + + Cannot retrieve a mock with the given object type {0} as it's not the main type of the mock or any of its additional interfaces. Please cast the argument to one of the supported types: {1}. Remember that there's no generics covariance in the CLR, so your object must be one of these types in order for the call to succeed. - - - Expected only {0} calls to {1}. - - - Expression is not a property setter invocation. - - - Value cannot be an empty string. - - - Type {0} does not implement required interface {1} - - - Type {0} does not from required type {1} - - - {0} + + + Expected only {0} calls to {1}. + + + Expression is not a property setter invocation. + + + Value cannot be an empty string. + + + Type {0} does not implement required interface {1} + + + Type {0} does not from required type {1} + + + {0} Expected invocation on the mock at least {2} times, but was {4} times: {1} - - - {0} + + + {0} Expected invocation on the mock at most {3} times, but was {4} times: {1} - - - {0} + + + {0} Expected invocation on the mock at most once, but was {4} times: {1} - - - {0} + + + {0} Expected invocation on the mock between {2} and {3} times (Inclusive), but was {4} times: {1} - - - {0} + + + {0} Expected invocation on the mock exactly {2} times, but was {4} times: {1} - - - {0} + + + {0} Expected invocation on the mock should never have been performed, but was {4} times: {1} - - - {0} + + + {0} Expected invocation on the mock between {2} and {3} times (Exclusive), but was {4} times: {1} - - - {0} + + + {0} Expected invocation on the mock once, but was {4} times: {1} - - - Out expression must evaluate to a constant value. - - - Ref expression must evaluate to a constant value. - - - LINQ method '{0}' not supported. - - - Could not locate event for attach or detach method {0}. - - - The equals ("==" or "=" in VB) and the conditional 'and' ("&&" or "AndAlso" in VB) operators are the only ones supported in the query specification expression. Unsupported expression: {0} - - - Expression contains a call to a method which is not virtual (overridable in VB) or abstract. Unsupported expression: {0} - - - Property {0}.{1} does not have a setter. - - - Property {0}.{1} does not have a getter. - - - Invalid setup on a non-virtual (overridable in VB) member: {0} - - - Invalid verify on a non-virtual (overridable in VB) member: {0} - - - Invalid setup on a static member: {0} - - - Invalid verify on a static member: {0} - - - Invalid setup on an extension method: {0} - - - Invalid verify on an extension method: {0} - - - Unhandled binding type: {0} - - - Unhandled expression type: {0} - - - Configured setups: {0} - - - Delays have to be greater than zero to ensure an async callback is used. - - - Expression is not an event attach or detach, or the event is declared in a class but not marked virtual. - - - Invalid callback. Setup on method with parameters ({0}) cannot invoke callback with parameters ({1}). - - - Minimum delay has to be lower than maximum delay. - - - No invocations performed. - - - No setups configured. - - - Performed invocations: {0} - - - Unexpected translation of a member access: {0} - - - Use ItExpr.IsNull<TValue> rather than a null argument value, as it prevents proper method lookup. - - - Cannot set up {0}.{1} because it is not accessible to the proxy generator used by Moq: + + + Out expression must evaluate to a constant value. + + + Ref expression must evaluate to a constant value. + + + LINQ method '{0}' not supported. + + + Could not locate event for attach or detach method {0}. + + + The equals ("==" or "=" in VB) and the conditional 'and' ("&&" or "AndAlso" in VB) operators are the only ones supported in the query specification expression. Unsupported expression: {0} + + + Expression contains a call to a method which is not virtual (overridable in VB) or abstract. Unsupported expression: {0} + + + Property {0}.{1} does not have a setter. + + + Property {0}.{1} does not have a getter. + + + Invalid setup on a non-virtual (overridable in VB) member: {0} + + + Invalid verify on a non-virtual (overridable in VB) member: {0} + + + Invalid setup on a static member: {0} + + + Invalid verify on a static member: {0} + + + Invalid setup on an extension method: {0} + + + Invalid verify on an extension method: {0} + + + Unhandled binding type: {0} + + + Unhandled expression type: {0} + + + Configured setups: {0} + + + Delays have to be greater than zero to ensure an async callback is used. + + + Expression is not an event attach or detach, or the event is declared in a class but not marked virtual. + + + Invalid callback. Setup on method with parameters ({0}) cannot invoke callback with parameters ({1}). + + + Minimum delay has to be lower than maximum delay. + + + No invocations performed. + + + No setups configured. + + + Performed invocations: {0} + + + Unexpected translation of a member access: {0} + + + Use ItExpr.IsNull<TValue> rather than a null argument value, as it prevents proper method lookup. + + + Cannot set up {0}.{1} because it is not accessible to the proxy generator used by Moq: {2} - - - Invalid callback. This overload of the "Callback" method only accepts "void" (C#) or "Sub" (VB.NET) delegates with parameter types matching those of the set up method. - - - Invalid callback. This overload of the "Returns" method only accepts non-"void" (C#) or "Function" (VB.NET) delegates with parameter types matching those of the set up method. - - - Type {0} does not have matching protected member: {1} - - - Invalid callback. Setup on method with return type ({0}) cannot invoke callback with return type ({1}). - - - Invalid callback. Setup on method with {0} parameter(s) cannot invoke callback with different number of parameters ({1}). - - - The following invocations on mock '{0}' were not verified: + + + Invalid callback. This overload of the "Callback" method only accepts "void" (C#) or "Sub" (VB.NET) delegates with parameter types matching those of the set up method. + + + Invalid callback. This overload of the "Returns" method only accepts non-"void" (C#) or "Function" (VB.NET) delegates with parameter types matching those of the set up method. + + + Type {0} does not have matching protected member: {1} + + + Invalid callback. Setup on method with return type ({0}) cannot invoke callback with return type ({1}). + + + Invalid callback. Setup on method with {0} parameter(s) cannot invoke callback with different number of parameters ({1}). + + + The following invocations on mock '{0}' were not verified: {1} - - - CallBase cannot be used to mock Delegate types. - + \ No newline at end of file From 8943347cb8170f44cc76398cfc690b88b7b07ec9 Mon Sep 17 00:00:00 2001 From: Michael Wildman Date: Tue, 16 Oct 2018 01:02:19 +1300 Subject: [PATCH 06/13] Manually edit Resources.Designer.cs to avoid large diff --- src/Moq/Properties/Resources.Designer.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Moq/Properties/Resources.Designer.cs b/src/Moq/Properties/Resources.Designer.cs index 23e17f0dc..e8b1f5a4a 100644 --- a/src/Moq/Properties/Resources.Designer.cs +++ b/src/Moq/Properties/Resources.Designer.cs @@ -87,6 +87,15 @@ internal static string AsMustBeInterface { } } + /// + /// Looks up a localized string similar to CallBase cannot be used to mock Delegate types.. + /// + internal static string CallBaseUsedOnDelegateException { + get { + return ResourceManager.GetString("CallBaseUsedOnDelegateException", resourceCulture); + } + } + /// /// Looks up a localized string similar to Can't set return value for void method {0}.. /// From c5cee2a9bbcda000daf78c3d06fb9bf5c6ac443a Mon Sep 17 00:00:00 2001 From: Michael Wildman Date: Tue, 16 Oct 2018 01:03:30 +1300 Subject: [PATCH 07/13] Manually edit Resources.resx to avoid large diff --- src/Moq/Properties/Resources.resx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Moq/Properties/Resources.resx b/src/Moq/Properties/Resources.resx index e2a1e4bc9..620502a3a 100644 --- a/src/Moq/Properties/Resources.resx +++ b/src/Moq/Properties/Resources.resx @@ -348,4 +348,7 @@ Expected invocation on the mock once, but was {4} times: {1} The following invocations on mock '{0}' were not verified: {1} - \ No newline at end of file + + CallBase cannot be used to mock Delegate types. + + From 69d6e0c1548beffbc4053883d330a943244b3782 Mon Sep 17 00:00:00 2001 From: Michael Wildman Date: Tue, 16 Oct 2018 01:06:31 +1300 Subject: [PATCH 08/13] add missing line break --- tests/Moq.Tests/Regressions/IssueReportsFixture.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Moq.Tests/Regressions/IssueReportsFixture.cs b/tests/Moq.Tests/Regressions/IssueReportsFixture.cs index af0a6da79..b3d1b15f4 100644 --- a/tests/Moq.Tests/Regressions/IssueReportsFixture.cs +++ b/tests/Moq.Tests/Regressions/IssueReportsFixture.cs @@ -2012,6 +2012,7 @@ public interface IMyInterface #endregion #region 706 + public class Issue706 { [Fact] From 26d7253476d809b5a46214d269ba6a2f38603219 Mon Sep 17 00:00:00 2001 From: Michael Wildman Date: Tue, 16 Oct 2018 09:14:30 +1300 Subject: [PATCH 09/13] Resolve PR Comments #708 * Update CHANGELOG * Use .IsDelegate() extension * Only throw if CallBase == true * Fix whitespace (spaces to tabs) * Fix CallBase error name and description --- CHANGELOG.md | 1 + src/Moq/MethodCall.cs | 4 ++-- src/Moq/Mock.Generic.cs | 4 ++-- src/Moq/Properties/Resources.Designer.cs | 14 +++++++------- src/Moq/Properties/Resources.resx | 4 ++-- .../Moq.Tests/Regressions/IssueReportsFixture.cs | 15 ++++++++++++--- 6 files changed, 26 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a300eba9..d98bf676e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1 #### Fixed * `NullReferenceException` when using `SetupSet` on indexers with multiple parameters (@idigra, #694) +* `CallBase` should not be allowed for delegate mocks (@tehmantra, #706) ## 4.10.0 (2018-09-08) diff --git a/src/Moq/MethodCall.cs b/src/Moq/MethodCall.cs index 811518db0..eb0a03e36 100644 --- a/src/Moq/MethodCall.cs +++ b/src/Moq/MethodCall.cs @@ -123,9 +123,9 @@ public override void Execute(Invocation invocation) public virtual void SetCallBaseResponse() { - if (typeof(Delegate).IsAssignableFrom(this.Mock.TargetType)) + if (this.Mock.TargetType.IsDelegate()) { - throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseUsedOnDelegateException)); + throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseCannotBeUsedWithDelegateMocks)); } this.callBase = true; diff --git a/src/Moq/Mock.Generic.cs b/src/Moq/Mock.Generic.cs index 45753204c..2516aad91 100644 --- a/src/Moq/Mock.Generic.cs +++ b/src/Moq/Mock.Generic.cs @@ -168,9 +168,9 @@ public override bool CallBase get => this.callBase; set { - if (typeof(Delegate).IsAssignableFrom(this.MockedType)) + if (value && this.MockedType.IsDelegate()) { - throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseUsedOnDelegateException)); + throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseCannotBeUsedWithDelegateMocks)); } this.callBase = value; diff --git a/src/Moq/Properties/Resources.Designer.cs b/src/Moq/Properties/Resources.Designer.cs index e8b1f5a4a..7a65a6058 100644 --- a/src/Moq/Properties/Resources.Designer.cs +++ b/src/Moq/Properties/Resources.Designer.cs @@ -88,13 +88,13 @@ internal static string AsMustBeInterface { } /// - /// Looks up a localized string similar to CallBase cannot be used to mock Delegate types.. - /// - internal static string CallBaseUsedOnDelegateException { - get { - return ResourceManager.GetString("CallBaseUsedOnDelegateException", resourceCulture); - } - } + /// Looks up a localized string similar to CallBase cannot be used to mock Delegate types.. + /// + internal static string CallBaseCannotBeUsedWithDelegateMocks { + get { + return ResourceManager.GetString("CallBaseUsedOnDelegateException", resourceCulture); + } + } /// /// Looks up a localized string similar to Can't set return value for void method {0}.. diff --git a/src/Moq/Properties/Resources.resx b/src/Moq/Properties/Resources.resx index 620502a3a..4445c8799 100644 --- a/src/Moq/Properties/Resources.resx +++ b/src/Moq/Properties/Resources.resx @@ -349,6 +349,6 @@ Expected invocation on the mock once, but was {4} times: {1} {1} - CallBase cannot be used to mock Delegate types. - + CallBase cannot be used with Delegate mocks. + diff --git a/tests/Moq.Tests/Regressions/IssueReportsFixture.cs b/tests/Moq.Tests/Regressions/IssueReportsFixture.cs index b3d1b15f4..cbd44775b 100644 --- a/tests/Moq.Tests/Regressions/IssueReportsFixture.cs +++ b/tests/Moq.Tests/Regressions/IssueReportsFixture.cs @@ -2022,16 +2022,25 @@ public void CallBase_should_not_be_allowed_for_delegate_mocks() Language.Flow.ISetup setup = mock.Setup(m => m()); Exception ex = Assert.Throws(() => setup.CallBase()); - Assert.Equal(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseUsedOnDelegateException), ex.Message); + Assert.Equal(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseCannotBeUsedWithDelegateMocks), ex.Message); } [Fact] - public void CallBase_property_should_not_be_allowed_for_delegate_mocks() + public void CallBase_property_should_not_be_allowed_true_for_delegate_mocks() { Mock mock = new Mock(); Exception ex = Assert.Throws(() => mock.CallBase = true); - Assert.Equal(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseUsedOnDelegateException), ex.Message); + Assert.Equal(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseCannotBeUsedWithDelegateMocks), ex.Message); + } + + [Fact] + public void CallBase_property_should_be_allowed_false_for_delegate_mocks() + { + Mock mock = new Mock(); + mock.CallBase = false; + + Assert.Equal(false, mock.CallBase); } } From 4b4709b97f52b578555044825896a99fb1b4ff0b Mon Sep 17 00:00:00 2001 From: Michael Wildman Date: Tue, 16 Oct 2018 09:17:20 +1300 Subject: [PATCH 10/13] Fix name of callbase error in Resources.resx --- src/Moq/Properties/Resources.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Moq/Properties/Resources.resx b/src/Moq/Properties/Resources.resx index 4445c8799..6732fa30f 100644 --- a/src/Moq/Properties/Resources.resx +++ b/src/Moq/Properties/Resources.resx @@ -348,7 +348,7 @@ Expected invocation on the mock once, but was {4} times: {1} The following invocations on mock '{0}' were not verified: {1} - + CallBase cannot be used with Delegate mocks. From cdbb99918eefc4a485727f88f52973cbc008f722 Mon Sep 17 00:00:00 2001 From: Michael Wildman Date: Tue, 16 Oct 2018 09:19:21 +1300 Subject: [PATCH 11/13] Update comment on CallBase error in Resources.Designer.cs --- src/Moq/Properties/Resources.Designer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Moq/Properties/Resources.Designer.cs b/src/Moq/Properties/Resources.Designer.cs index 7a65a6058..caef0a690 100644 --- a/src/Moq/Properties/Resources.Designer.cs +++ b/src/Moq/Properties/Resources.Designer.cs @@ -88,7 +88,7 @@ internal static string AsMustBeInterface { } /// - /// Looks up a localized string similar to CallBase cannot be used to mock Delegate types.. + /// Looks up a localized string similar to CallBase cannot be used with Delegate mocks.. /// internal static string CallBaseCannotBeUsedWithDelegateMocks { get { From c49654c96fd9db3aa45d47d0cf5d9d3b8cb9dc33 Mon Sep 17 00:00:00 2001 From: Michael Wildman Date: Tue, 16 Oct 2018 09:20:03 +1300 Subject: [PATCH 12/13] Lookup correct string from the Resources file! --- src/Moq/Properties/Resources.Designer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Moq/Properties/Resources.Designer.cs b/src/Moq/Properties/Resources.Designer.cs index caef0a690..099bcce05 100644 --- a/src/Moq/Properties/Resources.Designer.cs +++ b/src/Moq/Properties/Resources.Designer.cs @@ -92,7 +92,7 @@ internal static string AsMustBeInterface { /// internal static string CallBaseCannotBeUsedWithDelegateMocks { get { - return ResourceManager.GetString("CallBaseUsedOnDelegateException", resourceCulture); + return ResourceManager.GetString("CallBaseCannotBeUsedWithDelegateMocks", resourceCulture); } } From 589c8530c176b4d559ccce32a3f35871ccd9922e Mon Sep 17 00:00:00 2001 From: Michael Wildman Date: Tue, 16 Oct 2018 11:56:03 +1300 Subject: [PATCH 13/13] Also check for non-void return delegate mocks --- src/Moq/MethodCallReturn.cs | 5 +++++ tests/Moq.Tests/Regressions/IssueReportsFixture.cs | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Moq/MethodCallReturn.cs b/src/Moq/MethodCallReturn.cs index e130c3b18..b30186029 100644 --- a/src/Moq/MethodCallReturn.cs +++ b/src/Moq/MethodCallReturn.cs @@ -58,6 +58,11 @@ public override void SetCallbackResponse(Delegate callback) public override void SetCallBaseResponse() { + if (this.Mock.TargetType.IsDelegate()) + { + throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseCannotBeUsedWithDelegateMocks)); + } + this.returnValueKind = ReturnValueKind.CallBase; } diff --git a/tests/Moq.Tests/Regressions/IssueReportsFixture.cs b/tests/Moq.Tests/Regressions/IssueReportsFixture.cs index cbd44775b..e857fe99a 100644 --- a/tests/Moq.Tests/Regressions/IssueReportsFixture.cs +++ b/tests/Moq.Tests/Regressions/IssueReportsFixture.cs @@ -2016,7 +2016,7 @@ public interface IMyInterface public class Issue706 { [Fact] - public void CallBase_should_not_be_allowed_for_delegate_mocks() + public void CallBase_should_not_be_allowed_for_void_delegate_mocks() { Mock mock = new Mock(); Language.Flow.ISetup setup = mock.Setup(m => m()); @@ -2024,6 +2024,16 @@ public void CallBase_should_not_be_allowed_for_delegate_mocks() Exception ex = Assert.Throws(() => setup.CallBase()); Assert.Equal(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseCannotBeUsedWithDelegateMocks), ex.Message); } + + [Fact] + public void CallBase_should_not_be_allowed_for_non_void_delegate_mocks() + { + Mock> mock = new Mock>(); + Language.Flow.ISetup, bool> setup = mock.Setup(m => m()); + + Exception ex = Assert.Throws(() => setup.CallBase()); + Assert.Equal(string.Format(CultureInfo.CurrentCulture, Resources.CallBaseCannotBeUsedWithDelegateMocks), ex.Message); + } [Fact] public void CallBase_property_should_not_be_allowed_true_for_delegate_mocks()