Пример #1
0
        public void Can_Update_Instance()
        {
            Guid         guid    = Guid.NewGuid();
            const string comment = "This here is an update";

            _service.InsertInstance(Scaffold.Instance(guid, 1));

            WorkflowInstancePoco instance = _service.GetByGuid(guid);

            instance.AuthorComment = comment;

            _service.UpdateInstance(instance);
            WorkflowInstancePoco updatedInstance = _service.GetByGuid(guid);

            Assert.Equal(comment, updatedInstance.AuthorComment);
        }
Пример #2
0
        public async void Can_Validate_Request()
        {
            Guid guid = Guid.NewGuid();

            const int userId = 11;
            const int nodeId = 1089;

            UserGroupPoco group = await AddGroupWithPermissionAndUser(userId, nodeId);

            // create a task on an instance
            WorkflowTaskPoco task = Scaffold.Task(guid, groupId: group.GroupId);

            _tasksService.InsertTask(task);
            _instancesService.InsertInstance(Scaffold.Instance(guid, 1, nodeId));

            // is valid when the user is in the group responsible for the task with the given id
            // and the task belongs to the given instance by guid
            // and both the task and instance are related to the given node id
            bool isValid = await _previewService.Validate(nodeId, userId, task.Id, guid);

            Assert.True(isValid);

            // invalid user id
            isValid = await _previewService.Validate(nodeId, 99, task.Id, guid);

            Assert.False(isValid);

            // invalid task id
            isValid = await _previewService.Validate(nodeId, userId, 11111, guid);

            Assert.False(isValid);

            // invalid guid
            isValid = await _previewService.Validate(nodeId, userId, task.Id, Guid.NewGuid());

            Assert.False(isValid);

            // invalid node id
            isValid = await _previewService.Validate(43535, userId, task.Id, guid);

            Assert.False(isValid);
        }
Пример #3
0
        public void Can_Count_User_Tasks()
        {
            Scaffold.Config();

            Guid guid = Guid.NewGuid();

            _instancesService.InsertInstance(Scaffold.Instance(guid, 1));
            _service.InsertTask(Scaffold.Task(guid));

            // status 1 is approved, there are none
            List <WorkflowTaskInstancePoco> result = _service.GetTaskSubmissionsForUser(0, new[] { 1 });

            Assert.NotNull(result);
            Assert.Empty(result);

            // status 3 is pending approval, there should be one
            result = _service.GetTaskSubmissionsForUser(0, new[] { 3 });

            Assert.NotNull(result);
            Assert.Single(result);
        }
        public async void Can_Get_Node_Pending_Tasks()
        {
            Scaffold.ContentType(_contentTypeService);
            IContent node = Scaffold.Node(_contentService);

            Scaffold.Config();

            Guid guid = Guid.NewGuid();

            _instancesService.InsertInstance(Scaffold.Instance(guid, 1, node.Id));
            _tasksService.InsertTask(Scaffold.Task(guid));

            // needs flow or function exits
            Dictionary <int, List <UserGroupPermissionsPoco> > config = Scaffold.Permissions(node.Id, 3, 0);

            _configService.UpdateNodeConfig(config);

            JObject content = await _tasksController.GetNodePendingTasks(node.Id).GetContent();

            Assert.Single(content.Value <JArray>("items"));
        }
Пример #5
0
        public async void Can_Validate_Request()
        {
            Scaffold.Config();

            Guid guid = Guid.NewGuid();

            WorkflowTaskInstancePoco task = Scaffold.Task(guid);

            _tasksService.InsertTask(task);
            _instancesService.InsertInstance(Scaffold.Instance(guid, 1, 1089));

            // is valid when the user is in the group responsible for the task with the given id
            // and the task belongs to the given instance by guid
            // and both the task and instance are related to the given node id
            bool isValid = await _previewService.Validate(1089, 0, task.Id, guid);

            Assert.True(isValid);

            isValid = await _previewService.Validate(1089, 99, 6456, guid);

            Assert.False(isValid);
        }
Пример #6
0
        /// <summary>
        /// Quickly scaffold a set of instances with arbitrary values and no tasks
        /// This method adds the instances to the db
        /// </summary>
        /// <param name="count"></param>
        /// <param name="type"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public static IEnumerable <WorkflowInstancePoco> Instances(int count, int type = 1, int status = (int)WorkflowStatus.PendingApproval, int?nodeId = null)
        {
            List <WorkflowInstancePoco> response = new List <WorkflowInstancePoco>();

            for (var i = 0; i < count; i++)
            {
                WorkflowInstancePoco instance = Instance(Guid.NewGuid(), type, nodeId ?? Utility.RandomInt(), Utility.RandomInt(), status);

                InstancesService.InsertInstance(instance);
                response.Add(instance);
            }

            return(response);
        }