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.");
            }
        }
        public void FinshFeedback_Expected_RecordingStoppedAndEmailFeedbackInvoked()
        {
            Mock <IFeedBackRecorder> feedbackRecorder = new Mock <IFeedBackRecorder>();

            feedbackRecorder.Setup(r => r.StopRecording()).Verifiable();
            Mock <IFeedbackInvoker> feedbackInvoker = new Mock <IFeedbackInvoker>();

            feedbackInvoker.Setup(r => r.InvokeFeedback(It.IsAny <IFeedbackAction>())).Verifiable();
            Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes);

            CustomContainer.Register <IFeedBackRecorder>(feedbackRecorder.Object);
            CustomContainer.Register <IFeedbackInvoker>(feedbackInvoker.Object);
            CustomContainer.Register <IWindowManager>(new Mock <IWindowManager>().Object);
            CustomContainer.Register <IPopupController>(popup.Object);

            RecorderFeedbackAction        recorderFeedbackAction = new RecorderFeedbackAction();
            Mock <IEnvironmentModel>      mockEnvironment        = Dev2MockFactory.SetupEnvironmentModel();
            Mock <IEnvironmentConnection> mockConn = Dev2MockFactory.SetupIEnvironmentConnection(new Exception());

            mockConn.Setup(mock => mock.ExecuteCommand(It.IsAny <StringBuilder>(), It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(new StringBuilder(@"""2013/06/07 02:23:22 PM :: ERROR -> Procedure or function 'fn_Greeting' expects parameter '@Name', which was not supplied.\r\n   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)\r\n   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)\r\n   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)\r\n   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()\r\n   at System.Data.SqlClient.SqlDataReader.get_MetaData()\r\n   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)\r\n   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite)\r\n   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)\r\n   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)\r\n   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)\r\n   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)\r\n   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)\r\n   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)\r\n   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)\r\n   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)\r\n   at Dev2.Runtime.ServiceModel.Esb.Brokers.MsSqlBroker.ExecuteSelect(IDbCommand command) in c:\\Development\\DEV2 SCRUM Project\\Branches\\BUG_9598\\Dev2.Runtime.Services\\ServiceModel\\Esb\\Brokers\\MsSqlBroker.cs:line 105\r\n   at Dev2.Runtime.ServiceModel.Esb.Brokers.AbstractDatabaseBroker.TestService(DbService dbService) in c:\\Development\\DEV2 SCRUM Project\\Branches\\BUG_9598\\Dev2.Runtime.Services\\ServiceModel\\Esb\\Brokers\\AbstractDatabaseBroker.cs:line 94\r\n2013/06/07 02:23:22 PM :: INFO -> Error retrieving shape from service output.\r\n2013/06/07 02:23:22 PM :: INFO -> Error retrieving shape from service output. Stacktrace : Error retrieving shape from service output.\r\n2013/06/07 02:23:25 PM :: ERROR -> Transactional Error : This SqlTransaction has completed; it is no longer usable.\r\n   at System.Data.SqlClient.SqlTransaction.ZombieCheck()\r\n   at System.Data.SqlClient.SqlTransaction.Rollback()\r\n   at Dev2.Runtime.ServiceModel.Esb.Brokers.AbstractDatabaseBroker.TestService(DbService dbService) in c:\\Development\\DEV2 SCRUM Project\\Branches\\BUG_9598\\Dev2.Runtime.Services\\ServiceModel\\Esb\\Brokers\\AbstractDatabaseBroker.cs:line 121\r\n2013/06/07 04:14:38 PM :: INFO -> Preloading assemblies...  \r\n2013/06/07 04:14:38 PM :: INFO -> done.\r\n2013/06/07 04:14:38 PM :: INFO -> SLM garbage collection manager disabled.\r\n2013/06/07 04:14:38 PM :: INFO -> Starting DataList Server...  \r\n2013/06/07 04:14:38 PM :: INFO -> done.\r\n2013/06/07 04:14:38 PM :: INFO -> \r\n2013/06/07 04:14:38 PM :: INFO -> Loading resource catalog...  \r\n2013/06/07 04:14:39 PM :: ERROR -> Resource 'Cities Database' from file 'C:\\Development\\DEV2 SCRUM Project\\Branches\\BUG_9598\\Dev2.Server\\bin\\Debug\\Sources\\Cities Database.xml' wasn't loaded because a resource with the same name has already been loaded from file 'Cities Database'.\r\n2013/06/07 04:14:39 PM :: ERROR -> Resource 'EndPointInterrogator' from file 'C:\\Development\\DEV2 SCRUM Project\\Branches\\BUG_9598\\Dev2.Server\\bin\\Debug\\Services\\EndPointInterrogator.xml' wasn't loaded because a resource with the same name has already been loaded from file 'EndPointInterrogator'.\r\n2013/06/07 04:14:39 PM :: ERROR -> Resource 'Dev2HorizontialLinkMenu' from file 'C:\\Development\\DEV2 SCRUM Project\\Branches\\BUG_9598\\Dev2.Server\\bin\\Debug\\Services\\Dev2HorizontialMenu.xml' wasn't loaded because a resource with the same name has already been loaded from file 'Dev2HorizontialLinkMenu'.\r\n2013/06/07 04:14:39 PM :: ERROR -> Resource 'Textbox.wiz' from file 'C:\\Development\\DEV2 SCRUM Project\\Branches\\BUG_9598\\Dev2.Server\\bin\\Debug\\Services\\Textbox.wiz.xml' wasn't loaded because a resource with the same name has already been loaded from file 'Textbox.wiz'.\r\n2013/06/07 04:14:41 PM :: INFO -> done.\r\n2013/06/07 04:14:41 PM :: INFO -> Loading server workspace...  \r\n2013/06/07 04:14:41 PM :: INFO -> done.\r\n2013/06/07 04:14:41 PM :: INFO -> Opening Execution Channel...  \r\n2013/06/07 04:14:41 PM :: INFO -> done.\r\n2013/06/07 04:14:41 PM :: INFO -> \r\n2013/06/07 04:14:41 PM :: INFO -> Opening DataList Channel...  \r\n2013/06/07 04:14:41 PM :: INFO -> done.\r\n2013/06/07 04:14:41 PM :: INFO -> \r\n2013/06/07 04:14:41 PM :: INFO -> Studio Server listening on 127.0.0.1:77\r\n2013/06/07 04:14:41 PM :: INFO -> Studio Server listening on 192.168.104.25:77\r\n2013/06/07 04:14:41 PM :: INFO -> \r\nWeb Server Started\r\n2013/06/07 04:14:41 PM :: INFO -> Web server listening at http://*:1234/\r\n2013/06/07 04:14:41 PM :: INFO -> Web server listening at https://*:1236/\r\n2013/06/07 04:14:41 PM :: INFO -> Loading settings provider...  \r\n2013/06/07 04:14:41 PM :: INFO -> done.\r\n2013/06/07 04:14:41 PM :: INFO -> Configure logging...  \r\n2013/06/07 04:14:41 PM :: INFO -> done.\r\n2013/06/07 04:14:41 PM :: INFO -> Press <ENTER> to terminate service and/or web server if started\r\n2013/06/07 04:14:54 PM :: ERROR -> Resource 'Cities Database' from file 'C:\\Development\\DEV2 SCRUM Project\\Branches\\BUG_9598\\Dev2.Server\\bin\\Debug\\Workspaces\\c65db9c9-fb35-4468-aefd-4c5c48fe3b49\\Sources\\Cities Database.xml' wasn't loaded because a resource with the same name has already been loaded from file 'Cities Database'.\r\n2013/06/07 04:14:54 PM :: ERROR -> Resource 'Dev2HorizontialLinkMenu' from file 'C:\\Development\\DEV2 SCRUM Project\\Branches\\BUG_9598\\Dev2.Server\\bin\\Debug\\Workspaces\\c65db9c9-fb35-4468-aefd-4c5c48fe3b49\\Services\\Dev2HorizontialMenu.xml' wasn't loaded because a resource with the same name has already been loaded from file 'Dev2HorizontialLinkMenu'.\r\n2013/06/07 04:14:54 PM :: ERROR -> Resource 'EndPointInterrogator' from file 'C:\\Development\\DEV2 SCRUM Project\\Branches\\BUG_9598\\Dev2.Server\\bin\\Debug\\Workspaces\\c65db9c9-fb35-4468-aefd-4c5c48fe3b49\\Services\\EndPointInterrogator.xml' wasn't loaded because a resource with the same name has already been loaded from file 'EndPointInterrogator'.\r\n2013/06/07 04:14:54 PM :: ERROR -> Resource 'Textbox.wiz' from file 'C:\\Development\\DEV2 SCRUM Project\\Branches\\BUG_9598\\Dev2.Server\\bin\\Debug\\Workspaces\\c65db9c9-fb35-4468-aefd-4c5c48fe3b49\\Services\\Textbox.wiz.xml' wasn't loaded because a resource with the same name has already been loaded from file 'Textbox.wiz'.\r\n2013/06/07 04:14:57 PM :: ERROR -> fileTest -> Cache MISS\r\n2013/06/07 04:14:57 PM :: ERROR -> Resource 'Cities Database' from file 'C:\\Development\\DEV2 SCRUM Project\\Branches\\BUG_9598\\Dev2.Server\\bin\\Debug\\Workspaces\\c65db9c9-fb35-4468-aefd-4c5c48fe3b49\\Sources\\Cities Database.xml' wasn't loaded because a resource with the same name has already been loaded from file 'Cities Database'.\r\n2013/06/07 04:14:57 PM :: ERROR -> Resource 'EndPointInterrogator' from file 'C:\\Development\\DEV2 SCRUM Project\\Branches\\BUG_9598\\Dev2.Server\\bin\\Debug\\Workspaces\\c65db9c9-fb35-4468-aefd-4c5c48fe3b49\\Services\\EndPointInterrogator.xml' wasn't loaded because a resource with the same name has already been loaded from file 'EndPointInterrogator'.\r\n2013/06/07 04:14:57 PM :: ERROR -> Resource 'Dev2HorizontialLinkMenu' from file 'C:\\Development\\DEV2 SCRUM Project\\Branches\\BUG_9598\\Dev2.Server\\bin\\Debug\\Workspaces\\c65db9c9-fb35-4468-aefd-4c5c48fe3b49\\Services\\Dev2HorizontialMenu.xml' wasn't loaded because a resource with the same name has already been loaded from file 'Dev2HorizontialLinkMenu'.\r\n2013/06/07 04:14:57 PM :: ERROR -> Resource 'Textbox.wiz' from file 'C:\\Development\\DEV2 SCRUM Project\\Branches\\BUG_9598\\Dev2.Server\\bin\\Debug\\Workspaces\\c65db9c9-fb35-4468-aefd-4c5c48fe3b49\\Services\\Textbox.wiz.xml' wasn't loaded because a resource with the same name has already been loaded from file 'Textbox.wiz'.\r\n"""));
            mockEnvironment.Setup(mock => mock.Connection).Returns(mockConn.Object);

            recorderFeedbackAction.FinishFeedBack(mockEnvironment.Object);

            feedbackRecorder.Verify(r => r.StopRecording(), Times.Exactly(1));
            feedbackInvoker.Verify(r => r.InvokeFeedback(It.IsAny <EmailFeedbackAction>()), Times.Exactly(1));
        }
Ejemplo n.º 3
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.");
            }
        }
Ejemplo n.º 4
0
        public void InvokeAsyncFeedback_Where_FeedbackAlreadyInProgressAndUserOptsToCancelInprogressFeedBack_Expected_PromptAndFeedbackStarted()
        {
            Mock <IAsyncFeedbackAction> feedbackAction = new Mock <IAsyncFeedbackAction>();

            feedbackAction.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction.Setup(f => f.StartFeedback(It.IsAny <Action <Exception> >())).Verifiable();
            feedbackAction.Setup(f => f.CancelFeedback()).Verifiable();

            Mock <IAsyncFeedbackAction> feedbackAction1 = new Mock <IAsyncFeedbackAction>();

            feedbackAction1.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction1.Setup(f => f.StartFeedback(It.IsAny <Action <Exception> >())).Verifiable();

            Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes);

            CustomContainer.Register <IPopupController>(popup.Object);
            FeedbackInvoker feedbackInvoker = new FeedbackInvoker();

            feedbackInvoker.InvokeFeedback(feedbackAction.Object);
            feedbackInvoker.InvokeFeedback(feedbackAction1.Object);

            popup.Verify(p => p.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>()), Times.Exactly(1));
            feedbackAction.Verify(f => f.StartFeedback(It.IsAny <Action <Exception> >()), Times.Exactly(1));
            feedbackAction.Verify(f => f.CancelFeedback(), Times.Exactly(1));
            feedbackAction1.Verify(f => f.StartFeedback(It.IsAny <Action <Exception> >()), Times.Exactly(1));
            Assert.AreEqual(feedbackAction1.Object, feedbackInvoker.CurrentAction);
        }
Ejemplo n.º 5
0
        public void ActivityDesignerViewModel_Collapse_HelpButtonGetsRemovedOnCollapse()
        {
            //------------Setup for test--------------------------
            var mockModelItem          = GenerateMockModelItem();
            var setupResourceModelMock = Dev2MockFactory.SetupResourceModelMock();
            var errorInfo = new ErrorInfo {
                InstanceID = new Guid()
            };

            var envRepo = new Mock <IServerRepository>();

            envRepo.Setup(e => e.ActiveServer).Returns(setupResourceModelMock.Object.Environment);

            IObservableReadOnlyList <IErrorInfo> testErrors = new ObservableReadOnlyList <IErrorInfo> {
                errorInfo
            };

            setupResourceModelMock.Setup(c => c.Errors).Returns(testErrors);
            setupResourceModelMock.Setup(c => c.GetErrors(It.IsAny <Guid>())).Returns(new List <IErrorInfo> {
                errorInfo
            });
            var viewModel = new ServiceDesignerViewModel(mockModelItem.Object, setupResourceModelMock.Object, envRepo.Object, new Mock <IEventAggregator>().Object, new SynchronousAsyncWorker());

            Assert.AreEqual(1, viewModel.TitleBarToggles.Count);

            viewModel.ShowLarge = true;

            Assert.AreEqual(1, viewModel.TitleBarToggles.Count);

            //------------Execute Test---------------------------
            viewModel.Collapse();

            //------------Assert Results-------------------------
            Assert.AreEqual(1, viewModel.TitleBarToggles.Count);
        }
Ejemplo n.º 6
0
        public void GetDataList_GivenEmptyResourceModel_ShouldReturnReturnEmpty()
        {
            //------------Setup for test--------------------------
            var adapter = new Mock <IApplicationAdaptor>();

            adapter.Setup(p => p.TryFindResource(It.IsAny <object>())).Returns(new object());
            CustomContainer.Register(adapter.Object);
            var node = new Mock <IConflictTreeNode>();
            var contextualResource = new Mock <IContextualResourceModel>();
            var value      = new DsfMultiAssignActivity();
            var assignStep = new FlowStep
            {
                Action = value
            };

            node.Setup(p => p.Activity).Returns(value);
            var assignExample        = XML.XmlResource.Fetch("AssignOutput");
            var jsonSerializer       = new Dev2JsonSerializer();
            var currentResourceModel = Dev2MockFactory.SetupResourceModelMock();
            var assignExampleBuilder = new StringBuilder(assignExample.ToString(System.Xml.Linq.SaveOptions.DisableFormatting));

            currentResourceModel.Setup(resModel => resModel.WorkflowXaml).Returns(assignExampleBuilder);
            currentResourceModel.Setup(resModel => resModel.DisplayName).Returns("Hello World");
            currentResourceModel.Setup(resModel => resModel.DataList).Returns("");
            var toolConflictItem = new ToolConflictItem(new ViewModels.Merge.Utils.ConflictRowList(new Mock <IConflictModelFactory>().Object, new Mock <IConflictModelFactory>().Object, new List <ConflictTreeNode>(), new List <ConflictTreeNode>()), ViewModels.Merge.Utils.ConflictRowList.Column.Current);
            //------------Execute Test---------------------------
            var completeConflict = new ConflictModelFactory(toolConflictItem, contextualResource.Object, node.Object);

            //------------Assert Results-------------------------
            Assert.IsNotNull(completeConflict);
            completeConflict.GetDataList(currentResourceModel.Object);

            Assert.AreEqual(2, completeConflict.DataListViewModel.DataList.Count);
        }
Ejemplo n.º 7
0
        public void ConflictModelFactory_GivenServiceConflictNode_NullResourceID()
        {
            //------------Setup for test--------------------------
            var adapter   = new Mock <IApplicationAdaptor>();
            var severRepo = new Mock <IServerRepository>();

            severRepo.Setup(p => p.ActiveServer).Returns(new Mock <IServer>().Object);
            CustomContainer.Register(severRepo.Object);
            adapter.Setup(p => p.TryFindResource(It.IsAny <object>())).Returns(new object());
            CustomContainer.Register(adapter.Object);
            var node = new Mock <IConflictTreeNode>();
            var contextualResource = new Mock <IContextualResourceModel>();
            var value      = new DsfActivity();
            var assignStep = new FlowStep
            {
                Action = value
            };
            var currentResourceModel = Dev2MockFactory.SetupResourceModelMock();

            node.Setup(p => p.Activity).Returns(value);
            contextualResource.Setup(r => r.Environment.ResourceRepository.LoadContextualResourceModel(Guid.Empty)).Returns((IContextualResourceModel)null);
            var toolConflictItem = new ToolConflictItem(new ViewModels.Merge.Utils.ConflictRowList(new Mock <IConflictModelFactory>().Object, new Mock <IConflictModelFactory>().Object, new List <ConflictTreeNode>(), new List <ConflictTreeNode>()), ViewModels.Merge.Utils.ConflictRowList.Column.Current);
            //------------Execute Test---------------------------

            var completeConflict = new ConflictModelFactory(toolConflictItem, contextualResource.Object, node.Object);

            //------------Assert Results-------------------------
            Assert.IsNotNull(completeConflict);
            adapter.Verify(p => p.TryFindResource(It.IsAny <object>()));
            var mergeToolModel = completeConflict.CreateModelItem(toolConflictItem, node.Object);

            Assert.AreEqual("DsfActivity", mergeToolModel.MergeDescription);
            Assert.AreEqual(typeof(ServiceDesignerViewModel).FullName, ((ToolConflictItem)mergeToolModel).ActivityDesignerViewModel.GetType().FullName);
        }
        protected static StudioResourceRepository CreateModels(bool isChecked, IEnvironmentModel environmentModel, out IExplorerItemModel resourceVm)
        {
            Mock <IContextualResourceModel> resourceModel = Dev2MockFactory.SetupResourceModelMock(ResourceType.WorkflowService, Guid.NewGuid());
            var serverItemModel = new ExplorerItemModel {
                DisplayName = "localhost", ResourceType = Common.Interfaces.Data.ResourceType.Server, EnvironmentId = environmentModel.ID, ResourceId = Guid.NewGuid(), ResourcePath = ""
            };

            ExplorerItemModel workflowsFolder = new ExplorerItemModel {
                DisplayName = "WORKFLOWS", ResourceType = Common.Interfaces.Data.ResourceType.Folder, ResourcePath = "WORKFLOWS", ResourceId = Guid.NewGuid(), EnvironmentId = environmentModel.ID
            };

            serverItemModel.Children.Add(workflowsFolder);

            var studioResourceRepository = new StudioResourceRepository(serverItemModel, Invoke);

            resourceModel.Setup(model => model.Category).Returns("WORKFLOWS\\" + resourceModel.Object.DisplayName);
            resourceModel.Setup(a => a.ServerID).Returns(environmentModel.ID);
            var env = new Mock <IEnvironmentModel>();

            resourceModel.Setup(a => a.Environment).Returns(env.Object);
            env.Setup(a => a.ID).Returns(environmentModel.ID);
            TestEnvironmentRespository testEnvironmentRespository = new TestEnvironmentRespository(environmentModel);

            // ReSharper disable ObjectCreationAsStatement
            new EnvironmentRepository(testEnvironmentRespository);
            // ReSharper restore ObjectCreationAsStatement
            IEnvironmentModel internalEnvironmentModel = environmentModel;

            studioResourceRepository.GetCurrentEnvironment = () => internalEnvironmentModel.ID;
            studioResourceRepository.AddResouceItem(resourceModel.Object);
            resourceVm           = workflowsFolder.Children[0];
            resourceVm.IsChecked = isChecked;
            return(studioResourceRepository);
        }
        public void EmailFeedbackAction_DisplayFeedbackWindow_NullEnvionment_ServerLogFileAttached()
        {
            var expected = new Dictionary <string, string> {
                { "ServerLog", "ExpectedServerLogFilePath" }
            };
            string actual = null;

            var windowManager = new Mock <IWindowManager>();

            windowManager.Setup(c => c.ShowWindow(It.IsAny <Object>(), It.IsAny <Object>(), It.IsAny <IDictionary <string, Object> >())).Callback((Object vm, Object obj, IDictionary <string, Object> dictionary) =>
            {
                actual = (vm is FeedbackViewModel) ? (vm as FeedbackViewModel).ServerLogAttachmentPath : null;
            });

            CustomContainer.Register(Dev2MockFactory.CreateIPopup(MessageBoxResult.OK).Object);
            CustomContainer.Register(new Mock <IFeedbackInvoker>().Object);
            CustomContainer.Register(windowManager.Object);
            var mockSysInfoService = new Mock <ISystemInfoService>();

            mockSysInfoService.Setup(service => service.GetSystemInfo()).Returns(new SystemInfoTO());
            CustomContainer.Register(mockSysInfoService.Object);

            var connection  = new Mock <IEnvironmentConnection>();
            var environment = new Mock <IEnvironmentModel>();

            environment.Setup(env => env.Connection).Returns(connection.Object);
            var emailFeedbackAction = new EmailFeedbackAction(expected, environment.Object);

            //------------Execute Test---------------------------
            emailFeedbackAction.DisplayFeedbackWindow();

            //------------Assert Server Log File Attached--------
            Assert.AreEqual(expected.Where(f => f.Key.Equals("ServerLog", StringComparison.CurrentCulture)).Select(v => v.Value).SingleOrDefault(), actual, "No log file attached");
        }
Ejemplo n.º 10
0
        public void InvokeFeedback_Where_EmailAndRecorderActionsProvidedAndUserAnswersCancelToRecordingPrompt_Expected_NoActionInvoked()
        {
            Mock <IFeedbackAction> feedbackAction1 = new Mock <IFeedbackAction>();

            feedbackAction1.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction1.Setup(f => f.Priority).Returns(2);
            feedbackAction1.Setup(f => f.StartFeedback()).Verifiable();

            Mock <IAsyncFeedbackAction> feedbackAction2 = new Mock <IAsyncFeedbackAction>();

            feedbackAction2.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction2.Setup(f => f.Priority).Returns(1);
            feedbackAction2.Setup(f => f.StartFeedback(It.IsAny <Action <Exception> >())).Verifiable();

            Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Cancel);

            CustomContainer.Register <IPopupController>(popup.Object);
            FeedbackInvoker feedbackInvoker = new FeedbackInvoker();

            feedbackInvoker.InvokeFeedback(feedbackAction1.Object, feedbackAction2.Object);

            popup.Verify(p => p.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>()), Times.Exactly(1));
            feedbackAction2.Verify(f => f.StartFeedback(It.IsAny <Action <Exception> >()), Times.Exactly(0));
            feedbackAction1.Verify(f => f.StartFeedback(), Times.Exactly(0));
            Assert.AreEqual(null, feedbackInvoker.CurrentAction);
        }
Ejemplo n.º 11
0
        public void InvokeFeedback_Where_ActionIsNull_Expected_ArgumentNullException()
        {
            Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes);

            CustomContainer.Register <IPopupController>(popup.Object);
            FeedbackInvoker feedbackInvoker = new FeedbackInvoker();

            feedbackInvoker.InvokeFeedback(null);
        }
        public void DesignerManagementService_UnitTest_GetResourceModel_SameAsConstructorInstance()
        {
            Mock <IContextualResourceModel> resourceModel      = Dev2MockFactory.SetupResourceModelMock();
            Mock <IResourceRepository>      resourceRepository = Dev2MockFactory.SetupFrameworkRepositoryResourceModelMock(resourceModel, new List <IResourceModel>());

            var designerManagementService = new DesignerManagementService(resourceModel.Object, resourceRepository.Object);

            IContextualResourceModel expected = resourceModel.Object;
            IContextualResourceModel actual   = designerManagementService.GetRootResourceModel();

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 13
0
        public void DsfActivityFactory_UnitTest_ServiceActivityAndNullSourceMethod_DoesNotThrowException()
        {
            var activity = new DsfServiceActivity();
            Mock <IContextualResourceModel> mockRes = Dev2MockFactory.SetupResourceModelMock(ResourceType.Service);

            mockRes.Setup(r => r.WorkflowXaml).Returns(new StringBuilder(StringResources.xmlNullSourceMethodServiceDef));
            var environmentRepository = SetupEnvironmentRepo(Guid.Empty);

            DsfActivityFactory.CreateDsfActivity(mockRes.Object, activity, true, environmentRepository, false);

            //If no exception - pass
            Assert.IsTrue(true);
        }
Ejemplo n.º 14
0
        public void InvokeFeedback_Where_RecorderActionIsNull_Expected_ArgumentNullException()
        {
            Mock <IFeedbackAction> feedbackAction1 = new Mock <IFeedbackAction>();

            feedbackAction1.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction1.Setup(f => f.Priority).Returns(2);
            feedbackAction1.Setup(f => f.StartFeedback()).Verifiable();

            Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Cancel);

            CustomContainer.Register <IPopupController>(popup.Object);
            FeedbackInvoker feedbackInvoker = new FeedbackInvoker();

            feedbackInvoker.InvokeFeedback(feedbackAction1.Object, null);
        }
Ejemplo n.º 15
0
        public void InvokeFeedback_Where_EmailActionIsNull_Expected_ArgumentNullException()
        {
            Mock <IAsyncFeedbackAction> feedbackAction2 = new Mock <IAsyncFeedbackAction>();

            feedbackAction2.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction2.Setup(f => f.Priority).Returns(1);
            feedbackAction2.Setup(f => f.StartFeedback(It.IsAny <Action <Exception> >())).Verifiable();

            Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Cancel);

            CustomContainer.Register <IPopupController>(popup.Object);
            FeedbackInvoker feedbackInvoker = new FeedbackInvoker();

            feedbackInvoker.InvokeFeedback(null, feedbackAction2.Object);
        }
        public void UpdateOnActionSelection_GivenHasInputsWithDataTypes_ShouldWriteToActiveDatalistAndPopulatesInputValues()
        {
            //---------------Set up test pack-------------------
            var eventAggregator = new Mock <IEventAggregator>();

            var mockResourceModel = Dev2MockFactory.SetupResourceModelMock();

            mockResourceModel.Setup(resModel => resModel.WorkflowXaml).Returns(WorkflowXAMLForTest());

            var dataListViewModel  = CreateDataListViewModel(mockResourceModel, eventAggregator.Object);
            var dataListItems      = new OptomizedObservableCollection <IScalarItemModel>();
            var dataListItem       = new ScalarItemModel("scalar1", enDev2ColumnArgumentDirection.Input, string.Empty);
            var secondDataListItem = new ScalarItemModel("scalar2", enDev2ColumnArgumentDirection.Input, string.Empty);

            dataListItems.Add(dataListItem);
            dataListItems.Add(secondDataListItem);

            DataListSingleton.SetDataList(dataListViewModel);



            var id  = Guid.NewGuid();
            var act = new DsfDotNetDllActivity()
            {
                SourceId = id
            };
            var modelItem    = ModelItemUtils.CreateModelItem(act);
            var actionRegion = new Mock <IActionToolRegion <IPluginAction> >();

            actionRegion.Setup(region => region.SelectedAction).Returns(ValueFunctionWithTypes);

            //---------------Assert Precondition----------------

            var countBefore = DataListSingleton.ActiveDataList.ScalarCollection.Count;

            Assert.AreEqual(4, countBefore);
            //---------------Execute Test ----------------------
            var inputRegion = new DotNetInputRegion(modelItem, actionRegion.Object);

            var methodInfo = typeof(DotNetInputRegion).GetMethod("UpdateOnActionSelection", BindingFlags.NonPublic | BindingFlags.Instance);

            Assert.IsNotNull(methodInfo);
            methodInfo.Invoke(inputRegion, new object[] { });
            //---------------Test Result -----------------------
            Assert.AreEqual("[[name]]", inputRegion.Inputs.ToList()[0].Value);
            Assert.AreEqual("[[surname]]", inputRegion.Inputs.ToList()[1].Value);
        }
Ejemplo n.º 17
0
        public void InvokeAsyncFeedback_Where_ActionCanProvideFeedback_Expected_StartFeedbackInvokedAndCurrentActionSet()
        {
            Mock <IAsyncFeedbackAction> feedbackAction = new Mock <IAsyncFeedbackAction>();

            feedbackAction.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction.Setup(f => f.StartFeedback(It.IsAny <Action <Exception> >())).Verifiable();

            Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes);

            FeedbackInvoker feedbackInvoker = new FeedbackInvoker();

            feedbackInvoker.InvokeFeedback(feedbackAction.Object);

            popup.Verify(p => p.Show(), Times.Exactly(0));
            feedbackAction.Verify(f => f.StartFeedback(It.IsAny <Action <Exception> >()), Times.Exactly(1));
            Assert.AreEqual(feedbackAction.Object, feedbackInvoker.CurrentAction);
        }
Ejemplo n.º 18
0
        public void InvokeAsyncFeedback_Where_ActionCantProvideFeedback_NothingInvokedOrSet()
        {
            Mock <IAsyncFeedbackAction> feedbackAction = new Mock <IAsyncFeedbackAction>();

            feedbackAction.Setup(f => f.CanProvideFeedback).Returns(false);
            feedbackAction.Setup(f => f.StartFeedback(It.IsAny <Action <Exception> >())).Verifiable();

            Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes);

            CustomContainer.Register <IPopupController>(popup.Object);
            FeedbackInvoker feedbackInvoker = new FeedbackInvoker();

            feedbackInvoker.InvokeFeedback(feedbackAction.Object);

            popup.Verify(p => p.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>()), Times.Exactly(1));
            feedbackAction.Verify(f => f.StartFeedback(It.IsAny <Action <Exception> >()), Times.Exactly(0));
            Assert.AreEqual(null, feedbackInvoker.CurrentAction);
        }
        // ReSharper disable InconsistentNaming
        public void StartFeedback_Expected_RecordingStarted()
        {
            Mock <IFeedBackRecorder> feedbackRecorder = new Mock <IFeedBackRecorder>();

            feedbackRecorder.Setup(r => r.StartRecording(It.IsAny <string>())).Verifiable();
            CustomContainer.Register <IFeedBackRecorder>(feedbackRecorder.Object);
            Mock <IFeedbackInvoker> feedbackInvoker = new Mock <IFeedbackInvoker>();
            Mock <IPopupController> popup           = Dev2MockFactory.CreateIPopup(MessageBoxResult.OK);

            CustomContainer.Register <IFeedbackInvoker>(feedbackInvoker.Object);
            CustomContainer.Register <IWindowManager>(new Mock <IWindowManager>().Object);
            CustomContainer.Register <IPopupController>(popup.Object);

            RecorderFeedbackAction recorderFeedbackAction = new RecorderFeedbackAction();

            recorderFeedbackAction.StartFeedback();

            feedbackRecorder.Verify(r => r.StartRecording(It.IsAny <string>()), Times.Exactly(1));
        }
        public void CancelFeedback_Expected_KillAllInvoked()
        {
            Mock <IFeedBackRecorder> feedbackRecorder = new Mock <IFeedBackRecorder>();

            feedbackRecorder.Setup(r => r.KillAllRecordingTasks()).Verifiable();

            Mock <IFeedbackInvoker> feedbackInvoker = new Mock <IFeedbackInvoker>();
            Mock <IPopupController> popup           = Dev2MockFactory.CreateIPopup(MessageBoxResult.OK);

            CustomContainer.Register <IFeedBackRecorder>(feedbackRecorder.Object);
            CustomContainer.Register <IFeedbackInvoker>(feedbackInvoker.Object);
            CustomContainer.Register <IWindowManager>(new Mock <IWindowManager>().Object);
            CustomContainer.Register <IPopupController>(popup.Object);

            RecorderFeedbackAction recorderFeedbackAction = new RecorderFeedbackAction();

            recorderFeedbackAction.CancelFeedback();

            feedbackRecorder.Verify(r => r.KillAllRecordingTasks(), Times.Exactly(1));
        }
        public void StartFeedback_Where_FeedbackRecordingAlreadyRunningAndYesIsAnsweredToKillPrompt_Expected_KillAllRecordingTasks()
        {
            int callCount = 0;
            Mock <IFeedBackRecorder> feedbackRecorder = new Mock <IFeedBackRecorder>();

            feedbackRecorder.Setup(r => r.StartRecording(It.IsAny <string>())).Callback(() =>
            {
                callCount++;

                if (callCount == 1)
                {
                    throw new FeedbackRecordingInprogressException();
                }

                if (callCount > 2)
                {
                    throw new Exception("Error in test mock logic, this point should never be reached. This exception's purpose is to end a potential infinite loop.");
                }
            }
                                                                                        ).Verifiable();
            feedbackRecorder.Setup(r => r.KillAllRecordingTasks()).Verifiable();

            CustomContainer.Register <IFeedBackRecorder>(feedbackRecorder.Object);
            Mock <IFeedbackInvoker> feedbackInvoker = new Mock <IFeedbackInvoker>();
            Mock <IPopupController> popup           = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes);

            CustomContainer.Register <IFeedbackInvoker>(feedbackInvoker.Object);
            CustomContainer.Register <IWindowManager>(new Mock <IWindowManager>().Object);
            CustomContainer.Register <IPopupController>(popup.Object);

            RecorderFeedbackAction recorderFeedbackAction = new RecorderFeedbackAction();

            recorderFeedbackAction.StartFeedback();

            feedbackRecorder.Verify(r => r.StartRecording(It.IsAny <string>()), Times.Exactly(2));
            feedbackRecorder.Verify(r => r.KillAllRecordingTasks(), Times.Exactly(1));
            popup.Verify(p => p.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>()), Times.Exactly(3));
        }
        public void FinshFeedback_Where_NoProcessesToStop_Expected_RecordingStoppedInvoked()
        {
            Mock <IFeedBackRecorder> feedbackRecorder = new Mock <IFeedBackRecorder>();

            feedbackRecorder.Setup(r => r.StopRecording()).Callback(() =>
            {
                throw new FeedbackRecordingNoProcessesExcpetion();
            }).Verifiable();

            Mock <IFeedbackInvoker> feedbackInvoker = new Mock <IFeedbackInvoker>();
            Mock <IPopupController> popup           = Dev2MockFactory.CreateIPopup(MessageBoxResult.OK);

            CustomContainer.Register <IFeedBackRecorder>(feedbackRecorder.Object);
            CustomContainer.Register <IFeedbackInvoker>(feedbackInvoker.Object);
            CustomContainer.Register <IWindowManager>(new Mock <IWindowManager>().Object);
            CustomContainer.Register <IPopupController>(popup.Object);

            RecorderFeedbackAction recorderFeedbackAction = new RecorderFeedbackAction();

            recorderFeedbackAction.FinishFeedBack();

            feedbackRecorder.Verify(r => r.StopRecording(), Times.Exactly(1));
            popup.Verify(p => p.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>()), Times.Exactly(1));
        }
        public void CancelFeedback_Where_TimeOutOccurs_Expected_KillAllInvoked()
        {
            Mock <IFeedBackRecorder> feedbackRecorder = new Mock <IFeedBackRecorder>();

            feedbackRecorder.Setup(r => r.KillAllRecordingTasks()).Callback(() =>
            {
                throw new FeedbackRecordingTimeoutException();
            }).Verifiable();

            Mock <IFeedbackInvoker> feedbackInvoker = new Mock <IFeedbackInvoker>();
            Mock <IPopupController> popup           = Dev2MockFactory.CreateIPopup(MessageBoxResult.OK);

            CustomContainer.Register <IFeedBackRecorder>(feedbackRecorder.Object);
            CustomContainer.Register <IFeedbackInvoker>(feedbackInvoker.Object);
            CustomContainer.Register <IWindowManager>(new Mock <IWindowManager>().Object);
            CustomContainer.Register <IPopupController>(popup.Object);

            RecorderFeedbackAction recorderFeedbackAction = new RecorderFeedbackAction();

            recorderFeedbackAction.CancelFeedback();

            feedbackRecorder.Verify(r => r.KillAllRecordingTasks(), Times.Exactly(1));
            popup.Verify(p => p.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>()), Times.Exactly(1));
        }
Ejemplo n.º 24
0
        public void InvokeFeedback_Where_UserClicksFeedback_Expected_LimitedPopups()
        {
            Mock <IAsyncFeedbackAction> feedbackAction = new Mock <IAsyncFeedbackAction>();

            feedbackAction.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction.Setup(f => f.Priority).Returns(2);
            feedbackAction.Setup(f => f.StartFeedback()).Verifiable();



            Mock <IPopupController> yesPopup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes);
            Mock <IPopupController> noPopup  = Dev2MockFactory.CreateIPopup(MessageBoxResult.No);

            CustomContainer.Register <IPopupController>(yesPopup.Object);
            FeedbackInvoker theInvoker = new FeedbackInvoker {
                CurrentAction = feedbackAction.Object
            };

            // If it's already recording, display a box to confirm if the user wants to stop the recording, and click Yes
            theInvoker.InvokeFeedback(feedbackAction.Object, feedbackAction.Object);

            // If it's already recording, display a box to confirm if the user wants to stop the recording, and click No
            theInvoker.InvokeFeedback(feedbackAction.Object, feedbackAction.Object);

            // If it's not recording, display the information box, and click Yes
            theInvoker.Popup         = noPopup.Object;
            theInvoker.CurrentAction = null;
            theInvoker.InvokeFeedback(feedbackAction.Object, feedbackAction.Object);
            // If it's not recording, display the information box, and click No
            theInvoker.CurrentAction = null;
            theInvoker.InvokeFeedback(feedbackAction.Object, feedbackAction.Object);

            // Check all popups showed the correct amount of times
            yesPopup.Verify(p => p.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>()), Times.Exactly(2)); // Once for already recording, once for not recording, and clicking yes
            noPopup.Verify(p => p.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>()), Times.Exactly(2));  // Once for already recording, once for not recording, and clicking no
        }