In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "ASP.NET MVC Web Application Engineering How to Realize". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
Not all unit tests are good TDD tests. To apply unit tests in test-driven development, you must be able to execute unit tests at a very fast rate. However, not all unit tests meet this requirement.
For example, Visual Studio provides a specific type of unit test support for ASP.NET Web sites. You must execute this type of unit test in the IIS or development web server context. However, when you do test-driven development, this is not an appropriate type of unit test because it is too slow.
In this article, I want to show you the detailed process of building unit tests for test-driven development. I'll describe to you in detail the details of using the Visual Studio 2008 Unit Testing Framework. In addition, I'll cover a number of advanced topics, such as testing private methods and how to execute tests from the command line.
Quickly create an ASP.NET MVC Web application engineering example
First, let's create a new ASP.NET MVC Web application project and create a corresponding test project. This step is very easy. When you create a new ASP.NET MVC Web application project, you will then be prompted whether to create a new Visual Studio test project, as shown in Figure 1. As long as you keep the radio button at the top of Figure 1 (the default option), you'll see a new test project automatically added to your solution.
Now the question is: since you have a test project, how do you use it?
When you create a new ASP.NET MVC application, the project includes a controller named HomeController. This controller has two default methods named Index() and About(). Corresponding to this HomeController project, a test project named HomeControllerTest is provided. This test file contains two test methods, Index() and About().
By default, Index() and About() are empty (Figure 2). Next, you can add your test logic to these methods.
Suppose we want to build an online storage system. For example, you want to create a Details page that displays detailed information about a particular product. Then, you pass a query string containing ProductId to the Details page, retrieve product details from the database, and display this information on the page.
In good test-driven development practice, you first need to write a test before you can actually code it. Instead of writing any application code first, you write tests that correspond to that code first. In order to create a successful Details page, the following test requirements must be met:
(1) If a ProductId is not passed to the page, an exception should be thrown
(2) This ProductId should be used to retrieve a product from the database.
If a matching product cannot be retrieved from the database, an exception should be thrown.
(4) Details view should be able to be generated smoothly
(5) Product data should be assigned to the ViewData structure of the Details view
"ASP.NET MVC Web application project how to achieve" the content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.