1

I have a controller with the Authorize attribute:

public CustomerController:Controller  
{
    [Authorize]  
    public ActionResult GetCustomer(int id)  
    {  
        var model=db.Customers.where(c=>c.id==id);
        return View(model);   
    }
}

My question is, how can I test a controller with the Authorize attribute?

Do we need to get user information like username and password before testing from HttpContext?

Are mocks, dependency injection, and inversion of control related to unit testing? If so, can you guys suggest some websites or documents for learning these topics?

0

1 Answer 1

1

Here's some good examples of testing with mocks, DI, IoC, MVC @

http://code.google.com/p/sutekishop/source/browse/trunk/Suteki.Shop/Suteki.Shop.Tests/#Suteki.Shop.Tests%2FControllers

The author doesn't use the Authorize attribute but uses custom action filters and roles based security I believe.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.