Battle of the framework: Testing a Webpart
Time to see the difference between Moles and Isolator code. Let’s start with the code under test (a webpart): public class NewMessagesCountWebPart : WebPart{ private Label lblNewMessages; protected void CreateChildControls(int i) { CreateChildControls(); } protected override void CreateChildControls() { lblNewMessages = new Label(); lblNewMessages.Text = GetMessageNumberText(); this.Controls.Add(lblNewMessages); base.CreateChildControls(); } private string GetMessageNumberText() { using (SPSite site = new SPSite(“http://sharepoint.typemock.com”)) { using (SPWeb web