Inheritance: Dev2.Webs.Callbacks.ServiceCallbackHandler
        public void ServiceCallbackHandlerSaveWithValidArgsExpectedPublishesUpdateResourceMessage()
        {
            Guid resourceId = Guid.NewGuid();

            var showDependencyProvider = new Mock<IShowDependencyProvider>();

            var resourceModel = new Mock<IResourceModel>();
            resourceModel.Setup(r => r.ResourceName).Returns("Some Testing Display Name");
            resourceModel.Setup(r => r.ID).Returns(resourceId);

            var resourceRepo = new Mock<IResourceRepository>();
            resourceRepo.Setup(r => r.ReloadResource(It.IsAny<Guid>(), It.IsAny<ResourceType>(), It.IsAny<IEqualityComparer<IResourceModel>>(), true))
                .Returns(new List<IResourceModel> { resourceModel.Object });

            var envModel = new Mock<IEnvironmentModel>();
            envModel.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object);

            var aggregator = new Mock<IEventAggregator>();
            var envRepo = new Mock<IEnvironmentRepository>();
            var handler = new ServiceCallbackHandlerMock(aggregator.Object, envRepo.Object, showDependencyProvider.Object);

            aggregator.Setup(e => e.Publish(It.IsAny<UpdateResourceMessage>()))
                .Callback<Object>(m =>
                {
                    var msg = (UpdateResourceMessage)m;
                    Assert.AreEqual(resourceId, msg.ResourceModel.ID);
                })
                .Verifiable();

            var jsonObj = JObject.Parse("{ 'ResourceID': '" + resourceId + "','ResourceType':'Service'}");
            handler.TestSave(envModel.Object, jsonObj);

            aggregator.Verify(e => e.Publish(It.IsAny<UpdateResourceMessage>()), Times.Once());
        }
Exemple #2
0
        public void ServiceCallbackHandler_Save_ManyDependants_ShowDependancyViewer()
        {
            //------------------------------Setup-------------------------------------------------
            Mock <IShowDependencyProvider> showDependencyProvider;
            Mock <IResourceRepository>     resourceRepo;
            Guid resourceId = Guid.NewGuid();

            SetupObjects(out showDependencyProvider, out resourceRepo, resourceId);

            var compileMessageTos = new List <ICompileMessageTO> {
                new CompileMessageTO()
            };

            var envConnection = SetupConnectionWithCompileMessageList(compileMessageTos, new List <string> {
                "Unsaved 1", "Another Testing Dependant"
            });

            var envModel = new Mock <IEnvironmentModel>();

            envModel.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object);
            envModel.Setup(e => e.Connection).Returns(envConnection.Object);

            var aggregator = new Mock <IEventAggregator>();
            var envRepo    = new Mock <IEnvironmentRepository>();
            var handler    = new ServiceCallbackHandlerMock(aggregator.Object, envRepo.Object, showDependencyProvider.Object);

            var jsonObj = JObject.Parse("{ 'ResourceID': '" + resourceId + "','ResourceType':'Service'}");

            //------------------------------Execute -------------------------------------------------
            handler.TestSave(envModel.Object, jsonObj);
            //------------------------------Assert Result -------------------------------------------------
            showDependencyProvider.Verify(provider => provider.ShowDependencyViewer(It.IsAny <IContextualResourceModel>(), It.IsAny <IList <string> >()), Times.Once());
        }
Exemple #3
0
        public void ServiceCallbackHandler_CheckForServerMessages_OnlyDependantIsInWorkspaceItemRepo_DontShowDependancyViewer()
        {
            //------------------------------Setup-------------------------------------------------
            Mock <IShowDependencyProvider> showDependencyProvider;
            Mock <IResourceRepository>     resourceRepo;
            Guid resourceId = Guid.NewGuid();

            SetupObjects(out showDependencyProvider, out resourceRepo, resourceId);

            var compileMessageTos = new List <ICompileMessageTO> {
                new CompileMessageTO()
            };

            var envConnection = SetupConnectionWithCompileMessageList(compileMessageTos, new List <string> {
                "Unsaved 1"
            });

            var envModel = new Mock <IEnvironmentModel>();

            envModel.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object);
            envModel.Setup(e => e.Connection).Returns(envConnection.Object);

            var aggregator = new Mock <IEventAggregator>();
            var envRepo    = new Mock <IEnvironmentRepository>();
            var handler    = new ServiceCallbackHandlerMock(aggregator.Object, envRepo.Object, showDependencyProvider.Object);

            var workspace     = new Mock <IWorkspaceItemRepository>();
            var workspaceItem = new WorkspaceItem(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <Guid>())
            {
                ServiceName = "Unsaved 1"
            };

            workspace.Setup(c => c.WorkspaceItems).Returns(new List <IWorkspaceItem> {
                workspaceItem
            });

            //------------------------------Execute -------------------------------------------------
            handler.TestCheckForServerMessages(envModel.Object, resourceId, workspace.Object);
            //------------------------------Assert Result -------------------------------------------------
            showDependencyProvider.Verify(provider => provider.ShowDependencyViewer(It.IsAny <IContextualResourceModel>(), new List <string> {
                ""
            }), Times.Never());
        }
Exemple #4
0
        public void ServiceCallbackHandlerSaveWithValidArgsExpectedPublishesUpdateResourceMessage()
        {
            Guid resourceId = Guid.NewGuid();

            var showDependencyProvider = new Mock <IShowDependencyProvider>();

            var resourceModel = new Mock <IResourceModel>();

            resourceModel.Setup(r => r.ResourceName).Returns("Some Testing Display Name");
            resourceModel.Setup(r => r.ID).Returns(resourceId);

            var resourceRepo = new Mock <IResourceRepository>();

            resourceRepo.Setup(r => r.ReloadResource(It.IsAny <Guid>(), It.IsAny <ResourceType>(), It.IsAny <IEqualityComparer <IResourceModel> >(), true))
            .Returns(new List <IResourceModel> {
                resourceModel.Object
            });

            var envModel = new Mock <IEnvironmentModel>();

            envModel.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object);

            var aggregator = new Mock <IEventAggregator>();
            var envRepo    = new Mock <IEnvironmentRepository>();
            var handler    = new ServiceCallbackHandlerMock(aggregator.Object, envRepo.Object, showDependencyProvider.Object);

            aggregator.Setup(e => e.Publish(It.IsAny <UpdateResourceMessage>()))
            .Callback <Object>(m =>
            {
                var msg = (UpdateResourceMessage)m;
                Assert.AreEqual(resourceId, msg.ResourceModel.ID);
            })
            .Verifiable();

            var jsonObj = JObject.Parse("{ 'ResourceID': '" + resourceId + "','ResourceType':'Service'}");

            handler.TestSave(envModel.Object, jsonObj);

            aggregator.Verify(e => e.Publish(It.IsAny <UpdateResourceMessage>()), Times.Once());
        }
        public void ServiceCallbackHandlerSaveWithValidArgsWithMessages()
        {
            //------------------------------Setup-------------------------------------------------
            Mock<IShowDependencyProvider> showDependencyProvider;
            Mock<IResourceRepository> resourceRepo;
            Guid resourceId = Guid.NewGuid();
            SetupObjects(out showDependencyProvider, out resourceRepo, resourceId);

            var compileMessageTos = new List<ICompileMessageTO> { new CompileMessageTO() };

            var envConnection = SetupConnectionWithCompileMessageList(compileMessageTos, new List<string> { "Some Testing Dependant" });

            var envModel = new Mock<IEnvironmentModel>();
            envModel.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object);
            envModel.Setup(e => e.Connection).Returns(envConnection.Object);

            var aggregator = new Mock<IEventAggregator>();
            var envRepo = new Mock<IEnvironmentRepository>();
            var handler = new ServiceCallbackHandlerMock(aggregator.Object, envRepo.Object, showDependencyProvider.Object);

            var jsonObj = JObject.Parse("{ 'ResourceID': '" + resourceId + "','ResourceType':'Service'}");
            //------------------------------Execute -------------------------------------------------
            handler.TestSave(envModel.Object, jsonObj);
            //------------------------------Assert Result -------------------------------------------------
            showDependencyProvider.Verify(provider => provider.ShowDependencyViewer(It.IsAny<IContextualResourceModel>(), It.IsAny<IList<string>>()), Times.Once());
        }
        public void ServiceCallbackHandler_CheckForServerMessages_WebSource_DoNotShowDependancyViewer()
        {
            //------------------------------Setup-------------------------------------------------
            Mock<IShowDependencyProvider> showDependencyProvider;
            Mock<IResourceRepository> resourceRepo;
            Guid resourceId = Guid.NewGuid();
            SetupObjects(out showDependencyProvider, out resourceRepo, resourceId, ResourceType.Source);
            showDependencyProvider.Setup(
                c => c.ShowDependencyViewer(It.IsAny<IContextualResourceModel>(), new List<string> { "" }));

            var compileMessageTos = new List<ICompileMessageTO> { new CompileMessageTO() };

            var envConnection = SetupConnectionWithCompileMessageList(compileMessageTos, new List<string> { "CheckForServerMessages 1", "Another Testing Dependant" });

            var envModel = new Mock<IEnvironmentModel>();
            envModel.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object);
            envModel.Setup(e => e.Connection).Returns(envConnection.Object);

            var aggregator = new Mock<IEventAggregator>();
            var envRepo = new Mock<IEnvironmentRepository>();
            var handler = new ServiceCallbackHandlerMock(aggregator.Object, envRepo.Object, showDependencyProvider.Object);

            var workspace = new Mock<IWorkspaceItemRepository>();
            workspace.Setup(c => c.WorkspaceItems).Returns(new List<IWorkspaceItem>());

            //------------------------------Execute -------------------------------------------------
            handler.TestCheckForServerMessages(envModel.Object, resourceId, workspace.Object);
            //------------------------------Assert Result -------------------------------------------------
            showDependencyProvider.Verify(provider => provider.ShowDependencyViewer(It.IsAny<IContextualResourceModel>(), new List<string> { "" }), Times.Never());
        }