c# - What am I doing wrong this time with Moq? -


I'm having trouble with smiles and I'm not sure what I did wrong at the moment.

Although the debugger is going through step by step and I set it in my counterfeit

ResetPassword "O do not seem to do this to return

< P> My unit is part of the test:

  var membership mock = new fake & lt; subscription provider & gt; (); var user = new fake & lt; membership user & gt; () ; User.SetupGet (x = & gt; x.email). Return ("Email" Return ("O"); Subscription Mark. Setup (m => m.getUser ("chobo2", false)) User (Reset) (user) Authentication authentication provider = membership Mock.Object; // Act var real = authentication. Password recovery phase 2 ("chobo2", "2z");  

My Code

  membership user name = provider.Getuser (user, incorrect); string newPassword = userN ame.ResetPassword (securityAnswer); Mail.To = userName.Email;  

The provider is such a property that is set up with the counterfeit object and you will see the email part just fine, just reset the password back What does it return? It just give me zero.

Thanks

If "2z" is your security answer is "o" back Because it is setup to return only "O" for string inputs that match "test", it works perfectly for me for the following:

  public class authenticationahlper { Read Only User Provider _provider; Public Authentication Helper (Subscription Provider) {_provider = Provider; } Public string passwordquerystep2 (string username, string recovery order) {member user user = _provider.getUser (username, falls); String newPassword = user.ResetPassword (Recovery Ender); Return new password; }}  

Which test passes ...

  [TestFixture] Public class orthalmer tests {fake & lt; Subscription Provider & gt; MemberShipProvider; Fake & lt; MembershipUser & gt; the user; [Set Up] Public Zero Init () {memberShipProvider = New Fake & lt; Subscription Provider & gt; (); User = new fake & lt; Subscriptions user & gt; (); User.SetupGet (u = & gt; u.Email) Returns ("test@test.com"); User.Setup (u = & gt; u.ResetPassword ("secret")). Returns ("test2"); MemberShipProvider .setup (pro = & gt; prov.GetUser ("test", incorrect)). Return (user.Object); } [Test] Public Cancel Willreset Passwords BygoingProvider () {var assistant = New authentication helper (Membership Provider. Object); String newPassword = helper.PasswordRecoveryStep2 ("test", "secret"); Assure. First ("test2", new password); Membership Provider Verify (P = & gt; p.GetUser ("test", incorrect)); User.Verify (u = & gt; u.ResetPassword ("secret")); }}  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -