protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType) { //var customerRepository = new CustomerRepository(@"C:\hola.txt"); //var customerService = new CustomerService(customerRepository); //return controllerType == typeof(HomeController) ? //new HomeController(customerService) : base.GetControllerInstance(requestContext, controllerType); var txtaddressRespository = new AddressRepository(@"C:\hola.txt"); var sqladdressRespository = new sqlAddressRepository(@"C:\hola.txt"); var addressService = new AddressService(sqladdressRespository); return controllerType == typeof(HomeController) ? new HomeController(addressService) : base.GetControllerInstance(requestContext, controllerType); }
public void SiHomeDaComoRespuestaUnViewBag() { // Arrange var addressRep = new sqlAddressRepository(@"C:\hola.txt"); var adreesService = new AddressService(addressRep); HomeController controller = new HomeController(adreesService); // Act ViewResult result = controller.Index() as ViewResult; // Assert ViewDataDictionary viewData = result.ViewData; Assert.AreEqual("Modify this template to jump-start your ASP.NET MVC application.", viewData["Message"]); }