コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // This is using our IoC container to create our presenter (and its dependencies) for us
            _presenter = ServiceLocator.Get<ISubscriberFormView, SubscriberFormPresenter>(this);

            // Alternative to using IoC container, we would end up creating our own presenter factory
            // but ultimately would end up having to manually new up all our dependencies
            //_presenter = new SubscriberFormPresenter(this, new SubscriberService(new SubscriberRepository()));
        }
コード例 #2
0
        public void CanSaveSubscriber()
        {
            // Arrange
            var view = A.Fake<ISubscriberFormView>();
            var service = A.Fake<ISubscriberService>();

            var presenter = new SubscriberFormPresenter(view, service);

            // Act
            presenter.SaveSubscriber();

            // Assert
            A.CallTo(() => service.SaveSubscriber(view.Name, view.Email)).MustHaveHappened();
        }