Using Rhino Mocks to mock an out parameter, which is created within the method I am testing

Try the “OutRef” option. It accepts a params object[] that defines the result for each out parameter. Since you’ve only got one, you only need one result. Here’s a quick mock-up of what I tried that should work in your situation: var foo = MockRepository.GenerateStub<IFoo>(); var viewModel = new LoginViewModel(); User temp; foo.Stub(f => f.IsLoginValid(viewModel, … Read more

How to Construct IdentityResult With Success == true

Would the static IdentityResult.Success property work? http://msdn.microsoft.com/en-us/library/microsoft.aspnet.identity.identityresult.success(v=vs.108).aspx Edit: To add some more detail, it seems what you want to do is get your mocked CreateAsync to return an IdentityResult where Suceeded is true. For that I would just return IdentityResult.Success from your mock. There’s shouldn’t be a need to mock the IdentityResult itself. Example: How … Read more

How do I mock IQueryable

I usually do exactly what you ended up doing in your test. When writing my tests I assume that the .Net library classes work correctly and don’t contain bugs, so I can use them in the tests. When I need a test list, collection, queryable, dictionary, etc. I just create the real thing and populate … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)