public void PopulateWorkflowStoreInfo_ClientErrorOccurs_PopulatesModelWithException()
        {
            const string       exceptionMessage = "test exception";
            ConnectionModel    connectionModel  = new ConnectionModel();
            WorkflowStoreModel model            = new WorkflowStoreModel(connectionModel);

            IWorkflowStore workflowStore = Substitute.For <IWorkflowStore>();

            workflowStore.When(x => x.GetIncompleteCount()).Do((ci) => { throw new Exception(exceptionMessage); });
            _workflowStoreFactory.GetWorkflowStore(connectionModel).Returns(workflowStore);

            _workflowInfoService.PopulateWorkflowStoreInfo(model);

            Assert.AreEqual(exceptionMessage, model.ConnectionError);
            Assert.IsNull(model.ActiveCount);
        }
Beispiel #2
0
        public void PopulateWorkflowStoreInfo(WorkflowStoreModel workflowStoreModel)
        {
            if (workflowStoreModel == null)
            {
                throw new ArgumentNullException("workflowStoreModel");
            }

            try
            {
                IWorkflowStore workflowStore = _workflowStoreFactory.GetWorkflowStore(workflowStoreModel.ConnectionModel);
                workflowStoreModel.ActiveCount    = workflowStore.GetIncompleteCount();
                workflowStoreModel.SuspendedCount = workflowStore.GetSuspendedCount();
                workflowStoreModel.CompletedCount = workflowStore.GetCompletedCount();
            }
            catch (Exception ex)
            {
                workflowStoreModel.ConnectionError = ex.Message;
            }
        }
        public void PopulateWorkflowStoreInfo_NoClientErrorOccurs_PopulatesModelWithCounts()
        {
            Random r              = new Random();
            long   activeCount    = r.Next(11, 1000);
            long   suspendedCount = r.Next(1, 10);
            long   completedCount = r.Next(1001, 10000);

            ConnectionModel    connectionModel = new ConnectionModel();
            WorkflowStoreModel model           = new WorkflowStoreModel(connectionModel);

            IWorkflowStore workflowStore = Substitute.For <IWorkflowStore>();

            workflowStore.GetIncompleteCount().Returns(activeCount);
            workflowStore.GetSuspendedCount().Returns(suspendedCount);
            workflowStore.GetCompletedCount().Returns(completedCount);
            _workflowStoreFactory.GetWorkflowStore(connectionModel).Returns(workflowStore);

            _workflowInfoService.PopulateWorkflowStoreInfo(model);

            Assert.AreEqual(activeCount, model.ActiveCount);
            Assert.AreEqual(completedCount, model.CompletedCount);
            Assert.AreEqual(suspendedCount, model.SuspendedCount);
        }