Extreme ASP.NET Makeover: Mr. Escher, Your Software is Ready - Dependency
- Posted: Sep 11, 2009 at 11:17 AM
- 12,074 Views
Download
How do I download the videos?
- To download, right click the file type you would like and pick “Save target as…” or “Save link as…”
Why should I download videos from Channel9?
- It's an easy way to save the videos you like locally.
- You can save the videos in order to watch them offline.
- If all you want is to hear the audio, you can download the MP3!
Which version should I choose?
- If you want to view the video on your PC, Xbox or Media Center, download the High Quality WMV file (this is the highest quality version we have available).
- If you'd like a lower bitrate version, to reduce the download time or cost, then choose the Medium Quality WMV file.
- If you have a Zune, WP7, iPhone, iPad, or iPod device, choose the low or medium MP4 file.
- If you just want to hear the audio of the video, choose the MP3 file.
Right click “Save as…”
- High Quality WMV (PC, Xbox, MCE)
- MP3 (Audio only)
- MP4 (iPod, Zune HD)
- Mid Quality WMV (Lo-band, Mobile)
- WMV (WMV Video)
Extreme ASP.NET Makeover: Mr. Escher, Your Software is Ready –Dependency
As we saw, the Host class delegates to a whole host of Singletons (bad pun intended), including Settings, Users, Pages, Snippets, NavigationPaths, and AuthWriter. Each of these Singletons refers to other Singletons, creating a morass of dependencies. Before we start refactoring Host, we need some tests in place to ensure that we are not breaking anything. Configuration of the application and infrastructure is done by the ApplicationBootstrapper, which we introduced in Part 8. Our tests are going to execute ApplicationBootstrapper.Configure, as shown in Figure 2, and then verify that IHostV30 can be resolved from the IoC container as well as that various Singletons are still configured properly. Note that the IoC is initialized to null after every test to ensure that the tests don’t interfere with one another.
Figure 2 Tests Execute ApplicationBootstrapper.Configure
[TestFixture]
public class AfterTheApplicationBootstraperIsExecuted {
[Test]
public void IHostCanBeResolvedFromTheContainer() {
IoC.Resolve<IHostV30>();
}
[Test]
public void CacheInstanceIsInitialized() {
Assert.That(Cache.Instance, Is.Not.Null);
}
public void SettingsInstanceIsInitialized() {
Assert.That(Settings.Instance, Is.Not.Null);
}
[Test]
public void AuthReaderInstanceIsInitialized() {
Assert.That(AuthReader.Instance, Is.Not.Null);
}
[Test]
public void AuthWriterInstanceIsInitialized() {
Assert.That(AuthWriter.Instance, Is.Not.Null);
}
[SetUp]
public void SetUp() {
new ApplicationBootstrapper().Configure();
}
[TearDown]
public void TearDown() {
IoC.Initialize(null);
}
}
With these tests in place, let’s start refactoring Host to expose its dependency problems.
Other videos from this article
Read the full article at http://msdn.microsoft.com/magazine/ee470637.aspx
Comments Closed
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.