单元测试返回一个名为castle.proxies的东西

时间:2015-04-09 11:27:11

标签: asp.net unit-testing

我的单元测试返回一些我无法通过其被调用的对象 Castle.Proxies.IFeedbackRepository'proxy”。

这是我的单元测试代码:

私有AuthController控制器;

[TestInitialize]
public void Initialize() {
    Mock<iFeedbackRepository<Feedback>> mFeedRepo = new Mock<iFeedbackRepository<Feedback>>();
    Mock<iMovieRepository<Viewings>> mViewingRepo = new Mock<iMovieRepository<Viewings>>();
    Mock<iNewsLetterRepository<NewsLetter>> mNewsRepo = new Mock<iNewsLetterRepository<NewsLetter>>();
    Mock<iQuestionAnswerRepository<QuestionAnswers>> mQuestionAnswerRepo = new Mock<iQuestionAnswerRepository<QuestionAnswers>>();
    Mock<iTrueMovieRepository<Movies>> mMoviesRepo = new Mock<iTrueMovieRepository<Movies>>();
    Mock<iUserRepository<Users>> mUserRepo = new Mock<iUserRepository<Users>>();
    Mock<iQuestionRepository<Questions>> mQuestionRepo = new Mock<iQuestionRepository<Questions>>();
    List<Users> users = new List<Users> { 
        new Users { userID = 100, UserName = "Frans", UserPassword = "Spijkerman", userRights = 1 },
        new Users { userID = 200, UserName = "Jan", UserPassword = "Wintermans", userRights = 2}
    };

    foreach (Users user in users) {
        mUserRepo.Setup(m => m.AddUser(user));
    }

    List<Feedback> reviews = new List<Feedback> {
        new Feedback { FeedbackID = 1, UserName = "Frans", ReviewText = "The dark lord was a pretadfas", AcceptedReview = false},
        new Feedback { FeedbackID = 2, UserName = "Tu Boi", ReviewText = "The awesomenadfsasdfas", AcceptedReview = true}
    };

    foreach (Feedback review in reviews) {
        mFeedRepo.Setup(m => m.AddFeedback(review));
    }

    var UserRepo = mUserRepo.Object;
    var FeedbackRepo = mFeedRepo.Object;
    var ViewingRepo = mViewingRepo.Object;
    var MoviesRepo = mMoviesRepo.Object;
    var NewsRepo = mNewsRepo.Object;
    var QuestionRepo = mQuestionRepo.Object;
    var QuestionAnswerRepo = mQuestionAnswerRepo.Object;

    controller = new AuthController(UserRepo, FeedbackRepo, ViewingRepo, MoviesRepo, NewsRepo, QuestionRepo, QuestionAnswerRepo);
}

[TestMethod]
public void LoginTest() {
   //var user = new LogInModel { Gebruikersnaam = "Frans", Wachtwoord = "Spijkerman" };
   //var viewResult = controller.LogIn(user);
   //Assert.AreEqual("LogIn", viewResult);
   //Assert.IsInstanceOfType(viewResult, typeof(ViewResult));
}

任何人都知道出了什么问题?

这是一张照片

http://postimg.org/image/otyphh97j/

0 个答案:

没有答案