Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am new to Unit Testing.. first of all i want to know how we do unit testing in ASP.NET MVC.
In My project i am using MVC5 and Web API2. I want to implement unit testing within my project.
can anyone of you tell me how to start and provide me some links to approach?
Check this:
http://www.developerhandbook.com/2013/08/30/csharp-writing-unit-tests-with-nunit-and-moq/
-It is good introduction to mocking and AAA approach.
You can use NSubstitute instead of Moq if you want - it is more popular and you can find more examples about NSubstitute.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
If whole of my codes only distribute data to database or get data from database, how can I use Unit Test for that?
While on https://codeutopia.net/blog/2015/03/01/unit-testing-tdd-and-bdd/ says :
A Unit Test should be isolated from dependencies – for example, no network access and no database access.
Stub out only the calls to DB or any other external resource. then all your code block will get covered. If there are codes which shouldn't be part of unit test then exclude them from code coverage using a Run Setting file
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am new to unit testing and i need to use dependency injection pattern.
Dependency injection for testing is not really a requirement, but it will really help in unit testing with providing some facilities like the injection of mocks but you could do it manually, it help use of interfaces, no new(), and no singletons etc ...
please see the detailed example in this link
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have 2 separation solutions. One is done using MVC (Solutions 1) and the other is done using Web Forms (Solution 2). I have a class in one of the solutions (MVC one) that I like to use in the Web Forms solution. How would I reference the class in Solution 1 through Solution 2?
It depends on where the class is located. Ideally you would move your class out into its own project so that you can add the project to the other solution. You could also add an existing item from your MVC solution but this can lead to all kinds of dependency problems and shouldn't be done.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have built my app putting the logic in the views code behind. Is there a way to create a unit test project and test something like this? I cannot find any tutorials on the Internet?
Unit tests are not related to MVVM nor specific to Windows Phone, you can test anything.
MVVM is only a design pattern that one of it's advantages is that it makes unit testing easier because it separates the coding layers
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
A bit of background: I've been mostly developing in Java and Javascript for the past years and recently i've been moved to a C# project and tasked with implementing a Data Access Layer for this project. As far as i understood it this DAL will call only stored procedures (so no simple sql queries) and return some value if the stored procedure asks for it.
I apologize if this question has been answered before but i was not able to find anything useful.
What would be the best way to test that a DAL is actually calling these stored procedures and returning the results I am expecting? In Java we used Arquillian for integration tests against the DB and it worked great, however i have not been able to find anything like that for C#.
Any help will be appreciated.
Write unit tests for your DAL using something like nunit. This can then test that the results are as expected.