public void CreateNewProject()
        {
            var project = new Mock<IProject>();

            var service = new Mock<IUserInterfaceService>();
            {
                service.Setup(s => s.Contains(It.IsAny<CommandId>()))
                    .Returns(true);

                service.Setup(s => s.Invoke(It.IsAny<CommandId>(), It.IsAny<ICommandContext>()))
                    .Callback<CommandId, ICommandContext>(
                        (id, context) =>
                        {
                            CreateProjectContext createContext = context as CreateProjectContext;
                            createContext.Result = Task<IProject>.Factory.StartNew(
                                () => project.Object,
                                new CancellationToken(),
                                TaskCreationOptions.None,
                                new CurrentThreadTaskScheduler());
                        })
                    .Verifiable();
            }

            var facade = new ProjectHubForScripts(new ProjectHub(service.Object));
            facade.NewProject();

            Assert.IsTrue(facade.HasActiveProject());
            service.Verify(s => s.Invoke(It.IsAny<CommandId>(), It.IsAny<CreateProjectContext>()), Times.Exactly(1));
        }
Exemplo n.º 2
0
        public void UnloadProjectWithoutCurrentProject()
        {
            var service = new Mock <IUserInterfaceService>();
            var facade  = new ProjectHubForScripts(new ProjectHub(service.Object));

            Assert.Throws <CannotUnloadProjectException>(() => facade.UnloadProject());
        }
Exemplo n.º 3
0
        public void CreateNewProject()
        {
            var project = new Mock <IProject>();

            var service = new Mock <IUserInterfaceService>();
            {
                service.Setup(s => s.Contains(It.IsAny <CommandId>()))
                .Returns(true);

                service.Setup(s => s.Invoke(It.IsAny <CommandId>(), It.IsAny <ICommandContext>()))
                .Callback <CommandId, ICommandContext>(
                    (id, context) =>
                {
                    CreateProjectContext createContext = context as CreateProjectContext;
                    createContext.Result = Task <IProject> .Factory.StartNew(
                        () => project.Object,
                        new CancellationToken(),
                        TaskCreationOptions.None,
                        new CurrentThreadTaskScheduler());
                })
                .Verifiable();
            }

            var facade = new ProjectHubForScripts(new ProjectHub(service.Object));

            facade.NewProject();

            Assert.IsTrue(facade.HasActiveProject());
            service.Verify(s => s.Invoke(It.IsAny <CommandId>(), It.IsAny <CreateProjectContext>()), Times.Exactly(1));
        }
        public void CreateNewProjectWithLoadingFailure()
        {
            var service = new Mock<IUserInterfaceService>();
            {
                service.Setup(s => s.Contains(It.IsAny<CommandId>()))
                    .Returns(true);

                service.Setup(s => s.Invoke(It.IsAny<CommandId>(), It.IsAny<ICommandContext>()))
                    .Callback<CommandId, ICommandContext>(
                        (id, context) =>
                        {
                            CreateProjectContext createContext = context as CreateProjectContext;
                            createContext.Result = null;
                        })
                    .Verifiable();
            }

            var facade = new ProjectHubForScripts(new ProjectHub(service.Object));
            Assert.Throws<FailedToCreateProjectException>(() => facade.NewProject());
            service.Verify(s => s.Invoke(It.IsAny<CommandId>(), It.IsAny<CreateProjectContext>()), Times.Exactly(1));
        }
Exemplo n.º 5
0
        public void CreateNewProjectWithLoadingFailure()
        {
            var service = new Mock <IUserInterfaceService>();
            {
                service.Setup(s => s.Contains(It.IsAny <CommandId>()))
                .Returns(true);

                service.Setup(s => s.Invoke(It.IsAny <CommandId>(), It.IsAny <ICommandContext>()))
                .Callback <CommandId, ICommandContext>(
                    (id, context) =>
                {
                    CreateProjectContext createContext = context as CreateProjectContext;
                    createContext.Result = null;
                })
                .Verifiable();
            }

            var facade = new ProjectHubForScripts(new ProjectHub(service.Object));

            Assert.Throws <FailedToCreateProjectException>(() => facade.NewProject());
            service.Verify(s => s.Invoke(It.IsAny <CommandId>(), It.IsAny <CreateProjectContext>()), Times.Exactly(1));
        }
 public void UnloadProjectWithoutCurrentProject()
 {
     var service = new Mock<IUserInterfaceService>();
     var facade = new ProjectHubForScripts(new ProjectHub(service.Object));
     Assert.Throws<CannotUnloadProjectException>(() => facade.UnloadProject());
 }