I am trying to learn TDD by creating a copy of an existing MVC app I have but I am creating a copy of it from scratch using TDD.
In my existing app I have an Application_AuthenticateRequest method as shown below.
This is protected. Am I right in thinking that these methods should not be tested - ie you should only test public methods and not private and protected ones. If this is true then would I just code away my protected method below without writing any tests for it?
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
StaticDataSeeder.Seed();
}
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
HttpCookie authCookie = Context.Request.Cookies[FormsAuthentication.FormsCookieName];
if (authCookie == null) return;
var authTicket = FormsAuthentication.Decrypt(authCookie.Value);
if (authTicket == null) return;
var userData = new UserDataModel(authTicket.UserData);
var userPrincipal = new PaxiumPrincipal(new GenericIdentity(authTicket.Name), null)
{
Email = userData.Email,
Menu = userData.Menu,
RememberMe = userData.RememberMe
};
Context.User = userPrincipal;
}
}