1

I have a question related to unit tests. I have MVC controller in which i have different actions and i want to write unit tests on all actions.I have written unit tests on classes/functions using NUnit and VS Unit Test framework but Can you recommend any framework to write unit tests on controller actions?

3
  • The same combo should be good enough for your scenario, too Commented Jul 6, 2016 at 13:13
  • Creating Unit Tests for ASP.NET MVC Applications Commented Jul 6, 2016 at 13:14
  • Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. Commented Jul 6, 2016 at 14:02

1 Answer 1

0

Referencing Creating Unit Tests for ASP.NET MVC Applications (C#)

From what you have already stated you should be able to use the tools that you already have NUnit and VS Unit Test framework

For example

[Test]
public void TestDetailsViewData()
{
    var controller = new ProductController();
    var result = controller.Details(2) as ViewResult;
    var product = (Product) result.ViewData.Model;
    Assert.AreEqual("Laptop", product.Name);
}
Sign up to request clarification or add additional context in comments.

1 Comment

Let me check it, Thanks Nkosi

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.