In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to analyze the Visual Studio 2010 Automobile class, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
Visual Studio 2010 after a long period of development, many users are very familiar with the Visual Studio 2010 Automobile class. Here I would like to publish my personal understanding and discuss it with you. In our requirements analysis, we assume that Automobile has two properties, Model and TopSpeed, which should be initialized to "Not specified" and-1, respectively, in the default constructor of the Visual Studio 2010 Automobile class. We can add the following statement to the test function to test whether these two properties are initialized correctly:
Assert.IsTrue (myAuto.Model = = "Not specified" & & myAuto.TopSpeed = =-1)
Similarly, when we finished typing the above code, red wavy lines appeared quickly under Model and TopSpeed, and we were prompted that the Visual Studio 2010 Automobile class did not have these two attributes. Following the "out-of-the-box" principle, we can create these two properties immediately for the Visual Studio 2010 Automobile class.
The constructor of the test class
In the test project, we create a new test method, AutomobileWithModelNameCanStart, in which we create a new Automobile object with the specified model and topspeed.
Public void AutomobileWithModelNameCanStart () {string model = "550Barchetta"; int topSpeed = 1999; Automobile myAuto = new Automobile (model, topSpeed);}
Similarly, we use the "out-of-the-box" feature to generate new constructors for the Visual Studio 2010 Automobile class. Here we can find that the "out-of-the-box" function is very "smart". It automatically checks the type of the parameter according to the usage of the constructor, and then selects the appropriate attribute to store the data of the parameter according to the name of the parameter. For example, in the Visual Studio 2010 Automobile class, it selects the two properties we added earlier, Model and TopSpeed, to store the two parameters of the constructor.
Public Automobile (string model, int topSpeed) {/ / TODO: Complete member initialization this.Model = model; this.TopSpeed = topSpeed;}
At this time, we noticed that when the new constructor is added, the original default constructor is meaningless, in the DefaultAutomobileIsInitializedCorrectly test method we used the default constructor, then there will be a red wavy prompt, but it does not matter, we can use "out of the box" to immediately create a default constructor for it.
Test the member function of a class
In the requirements analysis, our Visual Studio 2010 Automobile class should have a member function Start () and a property IsRunning to start our Automobile and determine whether it is running or not, respectively. The test program we wrote for the Start () function and the IsRunning property is as follows:
MyAuto.Start (); Assert.IsTrue (myAuto.IsRunning = = true)
Because both of these are not implemented in the Visual Studio 2010 Automobile class, we benefit from the out-of-the-box feature by adding the member function Start () and the property IsRunning to the Visual Studio 2010 Automobile class.
At this point, all our test programs have been written, and at the same time, our target class Automobile has also built a framework and is beginning to take shape. And, more importantly, the creation of the Visual Studio 2010 Automobile class is based entirely on its usage, which avoids modifying the design of the class later in development because the test fails.
After reading the above, do you have any further understanding of how to analyze the Visual Studio 2010 Automobile class? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.