Xaml
<ToolTipService.ToolTip>
<TextBlock x:Name="ToolTip" Text="Click me!"></TextBlock>
</ToolTipService.ToolTip>
</Button>
C#
ToolTipService.SetToolTip( MyButton, new TextBlock() { Text = "Click me!" } );
你也可以用其它的控件替换TextBlock,比如图片控件或者方形控件。
Xaml
<ToolTipService.ToolTip>
<TextBlock x:Name="ToolTip" Text="Click me!"></TextBlock>
</ToolTipService.ToolTip>
</Button>
C#
ToolTipService.SetToolTip( MyButton, new TextBlock() { Text = "Click me!" } );
Visual Studio’s unit testing framework isn’t widely covered in books or in other places, and this makes it tougher for teams to adopt strict test guidelines for their developers. At the end of the day, if you aren’t unit testing from day one of your project, you’re in for a world of hurt down the line.
If you’ve new to Visual Studio unit testing, or just wanting to learn about Silverlight unit testing, you may feel a little lost. Here’s some information that just scratches the surface of the Visual Studio unit testing world.
So here are some of the questions people may have, let me know if there are others that you have! If you’re already familiar with unit testing this will all be redundant.
Most unit tests are simple class libraries written in your language of choice. They reference your production application’s projects or built assemblies, and also the unit test framework.
Metadata decorates the tests, and the tests themselves typically include calls to the test framework’s assertion classes.
Must-read resources:
Patterns and examples:
Videos:
For testing desktop applications, class libraries, and other code built for the full .NET framework, you’re in for a treat: Visual Studio 2008 Professional and other SKUs put great built in unit test support right inside your development environment. You’ll always be a click away from running a test or seeing where you stand.
There are integration tests, end-to-end tests, performance and stress tests, and many, many more. But at Microsoft I like to think of tests in 3 sets. In some cases it is possible for all the tests in a product to build upon a ‘unit test framework’.
Unit: “True” unit tests. Quick, small, efficient, very useful to always run. Independent.
Developer: Unit tests plus tests that exercise simple scenarios and conditions, such as the control framework in WPF, or performing a super simple request. Often these reach outside of the typical “unit test boundaries,” but are still quick to run and useful.
Developers are typically required to run all of the developer tests on their machine when preparing a check-in to validate the state of the code.
All tests: The set of all developer tests and everything that the test development team has created. Sometimes reaches into the tens of thousands of scenarios and cases at the end of a product cycle once a matrix of platforms and configurations is taken into consideration.
Developers and testers work together to make sure that all tests are run regularly, and especially when working on approaching a major product milestone, release, or servicing activity.
When building out the Silverlight unit test system that runs tests inside of your web browser, we made the call to reuse Visual Studio’s unit test framework metadata. This is a great win, for a few reasons:
Make sure that your unit tests are actually small, independent, simple, and not dependent on the web browser, Silverlight itself, or the more advanced “beyond unit testing” capabilities that are also present in Microsoft.Silverlight.Testing. If you inherit from the “SilverlightTest” base class, you probably have a test that won’t port to the desktop .NET framework.
We’ve worked hard to provide a subset of the full Visual Studio unit test metadata, but here’s a quick guide for you:
OK to use in both worlds:
Desktop features that will not work with the Silverlight test framework today (or are no-ops):
Silverlight test features that will not port to the desktop:
Hope this helps get some of you started!
What are some good XML specifications to get acquainted with? Here are the ones I find myself referring people to the most.
And there you go. File them away in a little "XML" folder in your favorites, and see how often to go back to them when you're working with XML-centric projects.
Enjoy!
A brief Introduction to the ASP.NET MVC Framework by Scott Guthrie:
An excellent Screencast by Scott Hanselman.
The MVC (Model-View-Controller) is a popular pattern to develop UI-centric applications based on a simple concept: divide the implementation into three logical components:
The ASP.NET MVC Framework is an implementation of the MVC pattern, and has built-in support for developing web applications. Let's take a quick look at these three components.
The ASP.NET MVC Framework is an alternate and better way to develop web applications, comparing to the regular web form model. It provides us with:
In regular ASP.NET web form applications, URLs are usually mapped to physical disk files. When a URL is requested, the code of the associated file gets executed, which generates the HTML. However, in the ASP.NET MVC Framework the URLs are tied with the Controllers rather than the disk file. The component that is responsible to map the URL with the Controller is the Routing Handler. When the application starts, it is required to register the URL Routing Rules, which the Routing Handler uses to map the controller when the request arrives. Let's take a quick view of how a request is carried in different layers of the ASP.NET MVC Framework: