Пример #1
0
        public void FetchExplorerItems_ExecuteReloadTrueWithExecutionManager_ExpectCallsStartAndStopRefresh()
        {
            //------------Setup for test--------------------------
            var fetchExplorerItems = new FetchExplorerItems();
            var exeManager         = new Mock <IExecutionManager>();

            CustomContainer.Register(exeManager.Object);
            var item = new ServerExplorerItem("a", Guid.NewGuid(), "Folder", null, Permissions.DeployFrom, "");

            Assert.IsNotNull(item);
            var repo = new Mock <IExplorerServerResourceRepository>();
            var ws   = new Mock <IWorkspace>();

            repo.Setup(a => a.Load(GlobalConstants.ServerWorkspaceID, true))
            .Returns(item).Verifiable();
            var serializer = new Dev2JsonSerializer();

            ws.Setup(a => a.ID).Returns(Guid.Empty);
            fetchExplorerItems.ServerExplorerRepo = repo.Object;
            //------------Execute Test---------------------------
            var execute = fetchExplorerItems.Execute(new Dictionary <string, StringBuilder> {
                { "ReloadResourceCatalogue", new StringBuilder("true") }
            }, ws.Object);

            //------------Assert Results-------------------------
            repo.Verify(a => a.Load(GlobalConstants.ServerWorkspaceID, true));
            var message = serializer.Deserialize <CompressedExecuteMessage>(execute);

            Assert.AreEqual(serializer.Deserialize <IExplorerItem>(message.GetDecompressedMessage()).ResourceId, item.ResourceId);
            exeManager.Verify(manager => manager.StartRefresh(), Times.Once);
            exeManager.Verify(manager => manager.StopRefresh(), Times.AtLeastOnce());
            CustomContainer.DeRegister <IExecutionManager>();
        }
Пример #2
0
        public void FetchExplorerItems_Execute_NoRefresh()
        {
            //------------Setup for test--------------------------
            var fetchExplorerItems = new FetchExplorerItems();

            var item = new ServerExplorerItem("a", Guid.NewGuid(), "Folder", null, Permissions.DeployFrom, "");

            Assert.IsNotNull(item);
            var repo = new Mock <IExplorerServerResourceRepository>();
            var ws   = new Mock <IWorkspace>();

            repo.Setup(a => a.Load(GlobalConstants.ServerWorkspaceID, true))
            .Returns(item).Verifiable();
            var serializer = new Dev2JsonSerializer();

            ws.Setup(a => a.ID).Returns(Guid.Empty);
            fetchExplorerItems.ServerExplorerRepo = repo.Object;
            //------------Execute Test---------------------------
            var jsonResult = fetchExplorerItems.Execute(new Dictionary <string, StringBuilder> {
                { "ReloadResourceCatalogue", new StringBuilder("ddd") }
            }, ws.Object);
            var result = serializer.Deserialize <CompressedExecuteMessage>(jsonResult);
            //------------Assert Results-------------------------
            //Assert.AreEqual(ExecStatus.Fail, result.Status)
        }
Пример #3
0
        public void FetchExplorerItems_Execute_ExpectName()
        {
            //------------Setup for test--------------------------
            var fetchExplorerItems = new FetchExplorerItems();

            var item = new ServerExplorerItem("a", Guid.NewGuid(), "Folder", null, Permissions.DeployFrom, "");

            Assert.IsNotNull(item);
            var repo = new Mock <IExplorerServerResourceRepository>();
            var ws   = new Mock <IWorkspace>();

            repo.Setup(a => a.Load(GlobalConstants.ServerWorkspaceID, false))
            .Returns(item).Verifiable();
            var serializer = new Dev2JsonSerializer();

            ws.Setup(a => a.ID).Returns(Guid.Empty);
            fetchExplorerItems.ServerExplorerRepo = repo.Object;
            //------------Execute Test---------------------------
            var execute = fetchExplorerItems.Execute(new Dictionary <string, StringBuilder>(), ws.Object);

            //------------Assert Results-------------------------
            repo.Verify(a => a.Load(GlobalConstants.ServerWorkspaceID, false));
            var message = serializer.Deserialize <CompressedExecuteMessage>(execute);

            Assert.AreEqual(serializer.Deserialize <IExplorerItem>(message.GetDecompressedMessage()).ResourceId, item.ResourceId);
        }
Пример #4
0
        public void FetchExplorerItems_Execute_NullValuesParameter_ErrorResult()
        {
            //------------Setup for test--------------------------
            var fetchExplorerItems = new FetchExplorerItems();
            var serializer         = new Dev2JsonSerializer();
            //------------Execute Test---------------------------
            StringBuilder             jsonResult = fetchExplorerItems.Execute(null, null);
            IExplorerRepositoryResult result     = serializer.Deserialize <IExplorerRepositoryResult>(jsonResult);

            //------------Assert Results-------------------------
            Assert.AreEqual(ExecStatus.Fail, result.Status);
        }
Пример #5
0
        public void FetchExplorerItems_Execute_ExpectName()
        {
            //------------Setup for test--------------------------
            var fetchExplorerItems = new FetchExplorerItems();

            ServerExplorerItem item = new ServerExplorerItem("a", Guid.NewGuid(), ResourceType.Folder, null, Permissions.DeployFrom, "");
            var repo = new Mock <IExplorerServerResourceRepository>();
            var ws   = new Mock <IWorkspace>();

            repo.Setup(a => a.Load(It.IsAny <Guid>())).Returns(item).Verifiable();
            var serializer = new Dev2JsonSerializer();

            ws.Setup(a => a.ID).Returns(Guid.Empty);
            fetchExplorerItems.ServerExplorerRepo = repo.Object;
            //------------Execute Test---------------------------
            var ax = fetchExplorerItems.Execute(new Dictionary <string, StringBuilder>(), ws.Object);

            //------------Assert Results-------------------------
            repo.Verify(a => a.Load(It.IsAny <Guid>()));
            Assert.AreEqual(serializer.Deserialize <IExplorerItem>(ax.ToString()).ResourceId, item.ResourceId);
        }