コード例 #1
0
        public void CreateInstance_WhenParametersAreValid()
        {
            var viewMock            = new Mock <IFootballPlayerView>();
            var footballServiceMock = new Mock <IFootballPlayerService>();

            FootballPlayerPresenter presenter = new FootballPlayerPresenter(viewMock.Object, footballServiceMock.Object);

            Assert.IsInstanceOf <FootballPlayerPresenter>(presenter);
        }
コード例 #2
0
        public void SetFootballPlayerToViewModel_WhenOnGetFootballPlayerByIdIsRaised()
        {
            var viewMock            = new Mock <IFootballPlayerView>();
            var footballServiceMock = new Mock <IFootballPlayerService>();

            FootballPlayer footballPlayer = new FootballPlayer();

            footballServiceMock.Setup(x => x.GetFootballPlayerById(It.IsAny <int>())).Returns(footballPlayer);

            FootballPlayerViewModel model = new FootballPlayerViewModel();

            viewMock.Setup(x => x.Model).Returns(model);

            FootballPlayerPresenter presenter = new FootballPlayerPresenter(viewMock.Object, footballServiceMock.Object);

            viewMock.Raise(x => x.OnGetFootballPlayerById += null, new IdEventArgs(8));

            Assert.AreEqual(footballPlayer, viewMock.Object.Model.FootballPlayer);
        }