コード例 #1
0
        public void Initialize()
        {
            var context = new Mock<IContextAware>();

            var view = new Mock<IFeedbackView>();
            {
                view.SetupSet(v => v.Model = It.IsAny<FeedbackModel>())
                    .Verifiable();
            }

            var parameter = new FeedbackParameter(context.Object);

            var container = new Mock<IDependencyInjectionProxy>();
            {
                container.Setup(c => c.Resolve<IContextAware>())
                    .Returns(context.Object);
                container.Setup(c => c.Resolve<SendFeedbackReportCommand>())
                    .Returns(new SendFeedbackReportCommand(new Mock<ISendFeedbackReports>().Object));
                container.Setup(c => c.Resolve<IBuildReports>())
                    .Returns(new Mock<IBuildReports>().Object);
            }

            var presenter = new FeedbackPresenter(container.Object);
            ((IPresenter)presenter).Initialize(view.Object, parameter);

            Assert.AreSame(view.Object, presenter.View);
            Assert.AreSame(parameter, presenter.Parameter);
            view.VerifySet(v => v.Model = It.IsAny<FeedbackModel>(), Times.Once());
        }
コード例 #2
0
        public void Initialize()
        {
            var context = new Mock <IContextAware>();

            var view = new Mock <IFeedbackView>();
            {
                view.SetupSet(v => v.Model = It.IsAny <FeedbackModel>())
                .Verifiable();
            }

            var parameter = new FeedbackParameter(context.Object);

            var container = new Mock <IDependencyInjectionProxy>();
            {
                container.Setup(c => c.Resolve <IContextAware>())
                .Returns(context.Object);
                container.Setup(c => c.Resolve <SendFeedbackReportCommand>())
                .Returns(new SendFeedbackReportCommand(new Mock <ISendFeedbackReports>().Object));
                container.Setup(c => c.Resolve <IBuildReports>())
                .Returns(new Mock <IBuildReports>().Object);
            }

            var presenter = new FeedbackPresenter(container.Object);

            ((IPresenter)presenter).Initialize(view.Object, parameter);

            Assert.AreSame(view.Object, presenter.View);
            Assert.AreSame(parameter, presenter.Parameter);
            view.VerifySet(v => v.Model = It.IsAny <FeedbackModel>(), Times.Once());
        }