Exemplo n.º 1
0
        public void Initialize()
        {
            var context = new Mock<IContextAware>();

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

            var parameter = new ProjectParameter(context.Object);

            var projectLink = new Mock<ILinkToProjects>();
            Func<string, IDisposable> func = s => new MockDisposable();

            var command = new CloseProjectCommand(projectLink.Object, func);
            var container = new Mock<IDependencyInjectionProxy>();
            {
                container.Setup(c => c.Resolve<IContextAware>())
                    .Returns(context.Object);
                container.Setup(c => c.Resolve<CloseProjectCommand>())
                    .Returns(command);
            }

            var presenter = new ProjectPresenter(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<ProjectModel>(), Times.Once());
        }
Exemplo n.º 2
0
        public void Initialize()
        {
            var context = new Mock <IContextAware>();

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

            var parameter = new ProjectParameter(context.Object);

            var projectLink = new Mock <ILinkToProjects>();
            Func <string, IDisposable> func = s => new MockDisposable();

            var command   = new CloseProjectCommand(projectLink.Object, func);
            var container = new Mock <IDependencyInjectionProxy>();
            {
                container.Setup(c => c.Resolve <IContextAware>())
                .Returns(context.Object);
                container.Setup(c => c.Resolve <CloseProjectCommand>())
                .Returns(command);
            }

            var presenter = new ProjectPresenter(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 <ProjectModel>(), Times.Once());
        }