c# - How do I setup this (Moq Setup) -


I want to test part of my code that gives user password questions. So I've made a mockup using the muq subscription provider.

I do not think I need to just test part of it to show you the actual code.

  // Organize various membership opportunities = new fake & lt; Subscription Provider & gt; (); Subscription mock .setup (m = & gt; m.GetUser ("test", incorrect). Password). Returns ("password"); Authenticate. Authenticate. Provider = Membership Mock.Object; // Act var = true authentication Password recovery phase 1 (this.IIAAAIT & lt; string & gt; ()); // must emphasize. That (real, is aquyme ("password"));  

I get this when I run this Nunit:

  Test.Controllers.AuthenticationControllerTest.Test_If_Password_Recovery_Setp1_Returns_Users_PasswordQuestion: System.NotSupportedException: only supported property access Intermediate invitation unsupported expression on a setup m.GetUser ("test", incorrect). On Moq.Mock.AutoMockPropertiesVisitor.VisitMethodCall (MethodCallExpression M) at Moq.ExpressionVisitor. Member at Moq.Mock.AutoMockPropertiesVisitor.VisitMemberAccess (Expressions M). Exxonition Visitor Vocabulary (Expression XP) on Moq.Mock.Moto. AutomokeProperties Visitor .SetupMocks (Expression Expression) is on Moq.Mock.GetInterceptor (LambdaExpression Lambda, Fake Fake) on Moq.Mock. & Gt; C__DisplayClass15`2. & Lt; SetupGet & gt; b__14 () on Moq.PexProtector.Invoke [T] (Func. Moq.Mock.SetupGet [t 1, TProperty] (imitation, Expression`1 expression) `1 function is Moq.Mock & lt); & Gt; C__DisplayClass12`2. & Lt; Setup & gt; B__11 () Moq.PexProtector.Invoke [T] on Test.Controllers Moq.Mock.Setup [T1, TResult] (fake fake, Expression`1 expression) on Moq.Mock`1.Setup [TResult] (Expression` 1 expression) to (Func`1 function) .AuthenticationControllerTest.Test_If_Password_Recovery_Setp1_Returns_Users_PasswordQuestion (D): \ MvcApplication9 \ Test \ controllers \ AuthenticationControllerTest.cs: line I am putting 186  

so I guess Because of the property, I have something because I am trying to reach them. I'm not sure that it is how to set I'm not very good with lambdas (and have not been able to find yet another tutorial on them) so I'm not sure if I can do it differently It can not be arranged to work.

Or if I just missed the mark completely

in the answer exception message is.

... Only asset access are supported in the intermediate invitation on a setup ...

Try this:

 < Code> user = new fake & lt; MemberShipUser & gt; (); User.SetupGet (x = & gt; x.PasswordQuestion). Returns ("password"); Membership Make. Setup (M => M. Gateuser ("Exam", Incorrect)). Return (user.Object);  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -