public void CreateKeysWithDebugStateExpectedKeysCreatedWhenNoWorkspaceID()
        {
            var resId    = Guid.NewGuid();
            var serverId = Guid.NewGuid();


            var debugState = new Mock <IDebugState>();

            debugState.Setup(c => c.OriginatingResourceID).Returns(resId);
            debugState.Setup(c => c.ServerID).Returns(serverId);
            debugState.Setup(c => c.WorkspaceID).Returns(Guid.Empty);

            var key1 = WorkSurfaceKeyFactory.CreateKey(debugState.Object);


            var debugState2 = new Mock <IDebugState>();

            debugState2.Setup(c => c.OriginatingResourceID).Returns(resId);
            debugState2.Setup(c => c.ServerID).Returns(serverId);
            debugState2.Setup(c => c.WorkspaceID).Returns(Guid.Empty);

            var key2 = WorkSurfaceKeyFactory.CreateKey(debugState2.Object);

            Assert.IsTrue(WorkSurfaceKeyEqualityComparer.Current.Equals(key1, key2), "keys should be equal");
        }
Exemplo n.º 2
0
        public void CreateShowDependencyKeysExpectedKeysCreated()
        {
            var resId    = Guid.NewGuid();
            var serverId = Guid.NewGuid();
            var enviroId = Guid.NewGuid();

            WorkSurfaceKey key1 = WorkSurfaceKeyFactory.CreateKey(WorkSurfaceContext.DependencyVisualiser) as WorkSurfaceKey;

            Assert.IsNotNull(key1);
            key1.EnvironmentID = enviroId;
            key1.ResourceID    = resId;
            key1.ServerID      = serverId;

            var resource2 = Dev2MockFactory.SetupResourceModelMock();

            resource2.Setup(c => c.ID).Returns(resId);
            resource2.Setup(c => c.ServerID).Returns(serverId);
            resource2.Setup(c => c.Environment.EnvironmentID).Returns(enviroId);

            var key2 = WorkSurfaceKeyFactory.CreateKey(resource2.Object);

            if (WorkSurfaceKeyEqualityComparerWithContextKey.Current.Equals(key1, key2))
            {
                Assert.Fail("The WorkSurfaceContext should not be the same.");
            }
        }
        public void CreateKeysExpectedKeysCreated()
        {
            var resId    = Guid.NewGuid();
            var serverId = Guid.NewGuid();
            var enviroId = Guid.NewGuid();

            var resource1 = Dev2MockFactory.SetupResourceModelMock();

            resource1.Setup(c => c.ID).Returns(resId);
            resource1.Setup(c => c.ServerID).Returns(serverId);
            resource1.Setup(c => c.Environment.ID).Returns(enviroId);

            var key1 = WorkSurfaceKeyFactory.CreateKey(resource1.Object);

            var enviroId2 = Guid.NewGuid();

            var resource2 = Dev2MockFactory.SetupResourceModelMock();

            resource2.Setup(c => c.ID).Returns(resId);
            resource2.Setup(c => c.ServerID).Returns(serverId);
            resource2.Setup(c => c.Environment.ID).Returns(enviroId2);

            var key2 = WorkSurfaceKeyFactory.CreateKey(resource2.Object);

            if (WorkSurfaceKeyEqualityComparer.Current.Equals(key1, key2))
            {
                Assert.Fail("The keys should not be the same as they are from two different environments.");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates the work surface context view model, only use for surfaces that are unique per server.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="vm">The vm.</param>
        /// <param name="workSurfaceContext">The work surface context.</param>
        /// <param name="serverID">The server ID.</param>
        /// <returns></returns>
        /// <date>3/6/2013</date>
        /// <author>
        /// Jurie.smit
        /// </author>
        public static WorkSurfaceContextViewModel CreateWorkSurfaceContextViewModelForServer <T>
            (T vm, WorkSurfaceContext workSurfaceContext, Guid serverID)
            where T : IWorkSurfaceViewModel
        {
            var key = WorkSurfaceKeyFactory.CreateKey(workSurfaceContext, serverID);

            return(CreateWorkSurfaceContextViewModel(vm, workSurfaceContext, key));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates the work surface context view model, only use for surfaces that are unique per context.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="vm">The vm.</param>
        /// <param name="workSurfaceContext">The work surface context.</param>
        /// <returns></returns>
        /// <author>Jurie.smit</author>
        /// <date>3/6/2013</date>
        public static WorkSurfaceContextViewModel CreateUniqueWorkSurfaceContextViewModel <T>
            (T vm, WorkSurfaceContext workSurfaceContext)
            where T : IWorkSurfaceViewModel
        {
            var key = WorkSurfaceKeyFactory.CreateKey(workSurfaceContext);

            return(CreateWorkSurfaceContextViewModel(vm, workSurfaceContext, key));
        }
        public void CreateKeysWithDebugStateExpectedKeysCreatedWhenHasWorkspaceID()
        {
            var resId     = Guid.NewGuid();
            var serverId  = Guid.NewGuid();
            var enviroId  = Guid.NewGuid();
            var enviroId2 = Guid.NewGuid();

            var serverRepo = new Mock <IServerRepository>();

            CustomContainer.DeRegister <IServerRepository>();
            CustomContainer.Register(serverRepo.Object);
            var source           = new Mock <IServer>();
            var sourceConnection = new Mock <IEnvironmentConnection>();

            sourceConnection.Setup(connection => connection.WorkspaceID).Returns(Guid.NewGuid);
            source.Setup(model => model.Connection).Returns(sourceConnection.Object);
            var e1 = new Mock <IServer>();

            e1.Setup(model => model.EnvironmentID).Returns(Guid.NewGuid);
            //serverRepo.Setup(repository => repository.FindSingle(server => ))
            //    .Returns(source.Object);
            var connection1 = new Mock <IEnvironmentConnection>();

            connection1.Setup(connection => connection.WorkspaceID).Returns(enviroId);
            e1.Setup(model => model.Connection).Returns(connection1.Object);
            var e2 = new Mock <IServer>();

            e2.Setup(model => model.EnvironmentID).Returns(Guid.NewGuid);
            var connection2 = new Mock <IEnvironmentConnection>();

            connection2.Setup(connection => connection.WorkspaceID).Returns(enviroId2);
            e2.Setup(model => model.Connection).Returns(connection2.Object);
            var repo = new TestLoadServerRespository(source.Object, e1.Object, e2.Object);

            new ServerRepository(repo);

            var debugState = new Mock <IDebugState>();

            debugState.Setup(c => c.OriginatingResourceID).Returns(resId);
            debugState.Setup(c => c.ServerID).Returns(serverId);
            debugState.Setup(c => c.WorkspaceID).Returns(enviroId);
            serverRepo.Setup(repository => repository.FindSingle(It.IsAny <Expression <Func <IServer, bool> > >()))
            .Returns(e1.Object);
            var key1 = WorkSurfaceKeyFactory.CreateKey(debugState.Object);



            var debugState2 = new Mock <IDebugState>();

            debugState2.Setup(c => c.OriginatingResourceID).Returns(resId);
            debugState2.Setup(c => c.ServerID).Returns(serverId);
            debugState2.Setup(c => c.WorkspaceID).Returns(enviroId2);

            var key2 = WorkSurfaceKeyFactory.CreateKey(debugState2.Object);

            Assert.IsFalse(WorkSurfaceKeyEqualityComparer.Current.Equals(key1, key2), "keys should not be equal");
        }
Exemplo n.º 7
0
        public void WorksurfaceKeyFactory_Create_OdbcSource_NewGuid_Expected()
        {
            //------------Setup for test--------------------------
            var worksurfaceKey = WorkSurfaceKeyFactory.CreateKey(WorkSurfaceContext.OdbcSource);


            //------------Execute Test---------------------------

            //------------Assert Results-------------------------
            Assert.AreNotEqual(worksurfaceKey.ResourceID, Guid.Empty);
        }
Exemplo n.º 8
0
        public static WorkSurfaceContextViewModel CreateResourceViewModel(IContextualResourceModel resourceModel, bool createDesigner = true)
        {
            var key = WorkSurfaceKeyFactory.CreateKey(resourceModel);

            var workSurfaceVm = new WorkflowDesignerViewModel(resourceModel, createDesigner);

            var contextVm = new WorkSurfaceContextViewModel(key, workSurfaceVm)
            {
                DataListViewModel = DataListViewModelFactory.CreateDataListViewModel(resourceModel)
            };

            return(contextVm);
        }
Exemplo n.º 9
0
        public static WorkSurfaceContextViewModel CreateResourceViewModel(IContextualResourceModel resourceModel, bool createDesigner, IPopupController popupController, IAsyncWorker asyncWorker)
        {
            var key = WorkSurfaceKeyFactory.CreateKey(resourceModel);

            var workSurfaceVm = new WorkflowDesignerViewModel(EventPublishers.Aggregator, resourceModel, new WorkflowHelper(), popupController, asyncWorker, createDesigner);

            var contextVm = new WorkSurfaceContextViewModel(key, workSurfaceVm)
            {
                DataListViewModel = DataListViewModelFactory.CreateDataListViewModel(resourceModel)
            };

            return(contextVm);
        }
        public void CreateKeysWithDebugStateExpectedKeysCreatedWhenHasWorkspaceID()
        {
            var resId     = Guid.NewGuid();
            var serverId  = Guid.NewGuid();
            var enviroId  = Guid.NewGuid();
            var enviroId2 = Guid.NewGuid();

            var source           = new Mock <IEnvironmentModel>();
            var sourceConnection = new Mock <IEnvironmentConnection>();

            sourceConnection.Setup(connection => connection.WorkspaceID).Returns(Guid.NewGuid);
            source.Setup(model => model.Connection).Returns(sourceConnection.Object);
            var e1 = new Mock <IEnvironmentModel>();

            e1.Setup(model => model.ID).Returns(Guid.NewGuid);
            var connection1 = new Mock <IEnvironmentConnection>();

            connection1.Setup(connection => connection.WorkspaceID).Returns(enviroId);
            e1.Setup(model => model.Connection).Returns(connection1.Object);
            var e2 = new Mock <IEnvironmentModel>();

            e2.Setup(model => model.ID).Returns(Guid.NewGuid);
            var connection2 = new Mock <IEnvironmentConnection>();

            connection2.Setup(connection => connection.WorkspaceID).Returns(enviroId2);
            e2.Setup(model => model.Connection).Returns(connection2.Object);
            var repo = new TestLoadEnvironmentRespository(source.Object, e1.Object, e2.Object);

            // ReSharper disable ObjectCreationAsStatement
            new EnvironmentRepository(repo);
            // ReSharper restore ObjectCreationAsStatement
            var debugState = new Mock <IDebugState>();

            debugState.Setup(c => c.OriginatingResourceID).Returns(resId);
            debugState.Setup(c => c.ServerID).Returns(serverId);
            debugState.Setup(c => c.WorkspaceID).Returns(enviroId);

            var key1 = WorkSurfaceKeyFactory.CreateKey(debugState.Object);



            var debugState2 = new Mock <IDebugState>();

            debugState2.Setup(c => c.OriginatingResourceID).Returns(resId);
            debugState2.Setup(c => c.ServerID).Returns(serverId);
            debugState2.Setup(c => c.WorkspaceID).Returns(enviroId2);

            var key2 = WorkSurfaceKeyFactory.CreateKey(debugState2.Object);

            Assert.IsFalse(WorkSurfaceKeyEqualityComparer.Current.Equals(key1, key2), "keys should not be equal");
        }
Exemplo n.º 11
0
        /// <summary>
        /// Creates the work surface context view model, only use for surfaces that are unique per context.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="vm">The vm.</param>
        /// <param name="workSurfaceContext">The work surface context.</param>
        /// <returns></returns>
        /// <author>Jurie.smit</author>
        /// <date>3/6/2013</date>
        static WorkSurfaceContextViewModel CreateUniqueWorkSurfaceContextViewModel <T>
            (T vm, WorkSurfaceContext workSurfaceContext)
            where T : IWorkSurfaceViewModel
        {
            var key = WorkSurfaceKeyFactory.CreateKey(workSurfaceContext) as WorkSurfaceKey;

            if (vm is HelpViewModel && key != null)
            {
                key.ResourceID = Guid.Empty;
            }
            if (vm is TriggersViewModel || vm is SettingsViewModel)
            {
                key = WorkSurfaceKeyFactory.CreateEnvKey(workSurfaceContext, CustomContainer.Get <IShellViewModel>().ActiveServer.EnvironmentID) as WorkSurfaceKey;
            }

            return(CreateWorkSurfaceContextViewModel(vm, workSurfaceContext, key));
        }