Skip to content

Instantly share code, notes, and snippets.

@davybrion
Created September 9, 2012 12:24
Show Gist options
  • Select an option

  • Save davybrion/3684070 to your computer and use it in GitHub Desktop.

Select an option

Save davybrion/3684070 to your computer and use it in GitHub Desktop.
code snippets for "How To Write Testable ASP.NET UserControls", part II
public class DummyViewPartController : PartController<IDummyViewPart>, IDummyViewPartController
{
public DummyViewPartController(IDummyViewPart viewPart) : base(viewPart) {}
public override void AddInitialRequests()
{
// add some initial requests to the IDispatcher
}
public override void GetInitialResponses()
{
// retrieve the responses for the initial requests from the IDispatcher
}
public void SomeSpecificOperationForTheDummyViewPart()
{
// do something specific to the IDummyViewPart
}
}
public interface IDummyView : IView
{
IDummyViewPart DummyPart { get; }
}
public partial class DummyPage : Page<DummyController>, IDummyView
{
protected void Page_Load(object sender, EventArgs e)
{
Controller.Load();
}
public IDummyViewPart DummyPart
{
get { return dummyPart; }
}
}
public class DummyController : Controller<IDummyView>
{
private IDummyViewPartController partController;
public DummyController(IDummyView view) : base(view)
{
}
public void Load()
{
partController = View.DummyPart.GetPartController(Dispatcher);
if (!View.IsPostBack)
{
partController.AddInitialRequests();
SendOurOwnRequestsAndGetTheResponses();
partController.GetInitialResponses();
}
}
private void SendOurOwnRequestsAndGetTheResponses()
{
// this method would send some requests through the IDispatcher and
// retrieve the responses
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment