Beispiel #1
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)
        }
Beispiel #2
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>();
        }
Beispiel #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);
        }
Beispiel #4
0
        public void FetchExplorerItems_HandlesType_ExpectName()
        {
            //------------Setup for test--------------------------
            var fetchExplorerItems = new FetchExplorerItems();


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

            //------------Assert Results-------------------------
            Assert.AreEqual("FetchExplorerItemsService", fetchExplorerItems.HandlesType());
        }
Beispiel #5
0
        public void GetAuthorizationContextForService_ShouldReturnContext()
        {
            //------------Setup for test--------------------------
            var fetchExplorerItems = new FetchExplorerItems();

            //------------Execute Test---------------------------
            var resId = fetchExplorerItems.GetAuthorizationContextForService();

            //------------Assert Results-------------------------
            Assert.AreEqual(AuthorizationContext.Any, resId);
        }
Beispiel #6
0
        public void GetResourceID_ShouldReturnEmptyGuid()
        {
            //------------Setup for test--------------------------
            var fetchExplorerItems = new FetchExplorerItems();

            //------------Execute Test---------------------------
            var resId = fetchExplorerItems.GetResourceID(new Dictionary <string, StringBuilder>());

            //------------Assert Results-------------------------
            Assert.AreEqual(Guid.Empty, resId);
        }
Beispiel #7
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);
        }
Beispiel #8
0
        public void FetchExplorerItems_CreateServiceEntry_ExpectProperlyFormedDynamicService()
        {
            //------------Setup for test--------------------------
            var fetchExplorerItems = new FetchExplorerItems();


            //------------Execute Test---------------------------
            var a = fetchExplorerItems.CreateServiceEntry();
            //------------Assert Results-------------------------
            var b = a.DataListSpecification.ToString();

            Assert.AreEqual("<DataList><ResourceType ColumnIODirection=\"Input\"/><Roles ColumnIODirection=\"Input\"/><ResourceName ColumnIODirection=\"Input\"/><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>", b);
        }
Beispiel #9
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);
        }