Databases Reference
In-Depth Information
static Product()
{
TypeDescriptor.AddProviderTransparent(
new AssociatedMetadataTypeTypeDescriptionProvider(typeof(Product)),
typeof(Product));
}
Figure 8.4 shows where the text template was modified. Notice the WriteStaticConstructor
method call that was added to the template code responsible for generation of entity type
declarations. This method is implemented in the end of this method in the Northwind.tt
file in the sample solution.
FIGURE 8.4
Generating static constructor in the text template.
Automated Testing
Due to its importance and relatively low rate of change, business logic in general and the
validation logic in particular are good candidates for automated testing. Encapsulating the
business logic in the context and entity classes partially generated by the Entity
Framework enables focused testing directly at the business level. Unlike testing through
the user interface, which depends on a particular presentation layer, such as the ASP.NET
WebForms, and often requires manual testing or use of specialized tools, testing at the
business level can be done through the application's internal APIs with general-purpose
frameworks, such as NUnit or the Visual Studio unit-testing framework.
Automated testing is one of the most powerful tools you can use to improve and main-
tain the quality of your application. However, like many expensive and powerful tools,
 
 
Search WWH ::




Custom Search