Skip to content

how to test Controller  #6

@qqqzhch

Description

@qqqzhch

public class HomeController : Controller
{
public DataRepository.IO.Iquestion QuestionRY { get; set; }
public DataRepository.IO.Iuserinfo UserinfoRY { get; set; }
public DataRepository.IO.Itag TagRY { get; set; }

    public ActionResult Index()
    {
        ViewBag.Message = "欢迎使用 ASP.NET MVC!";
        homeindex test = new homeindex(QuestionRY,UserinfoRY,TagRY);

        var T1 = test.GetHomequestion(1, 30);
        var T2 = test.SetQuestionForList(T1);
        return View();
    }

    public ActionResult About()
    {
        return View();
    }
}

and the Iquestion Iuserinfo Itag is Installed by

public class DataRepositoriesInstaller : IWindsorInstaller
{

    public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
    {

        container.Register(
           Component.For<DataRepository.IO.Iquestion>()
           .ImplementedBy<DataRepository.DO.questionR>()
           .LifestyleSingleton()
                    );
        container.Register(
               Component.For<DataRepository.IO.Ianswer>()
               .ImplementedBy<DataRepository.DO.answerR>()
               .LifestyleSingleton()
                        );
        container.Register(
                     Component.For<DataRepository.IO.Iquestiontag>()
                     .ImplementedBy<DataRepository.DO.questiontagR>()
                     .LifestyleSingleton()
                              );
        container.Register(
                               Component.For<DataRepository.IO.Itag>()
                               .ImplementedBy<DataRepository.DO.tagR>()
                               .LifestyleSingleton()
                                        );
        container.Register(
                                       Component.For<DataRepository.IO.Iurlinfo>()
                                       .ImplementedBy<DataRepository.DO.urlinfoR>()
                                       .LifestyleSingleton()
                                                );

        container.Register(
                                    Component.For<DataRepository.IO.Iuserinfo>()
                                    .ImplementedBy<DataRepository.DO.userinfoR>()
                                    .LifestyleSingleton()
                                             );


    }
}

i whant to test Index()
so how to do it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions