public void Can_Get_Pending_Workflow_Tasks() { List <WorkflowTaskViewModel> result = _service.GetPendingTasks(new List <int> { (int)TaskStatus.PendingApproval }, 10, 1); Assert.NotNull(result); Assert.Empty(result); var i = 0; while (i < 5) { IContent node = Scaffold.Node(_contentService); Guid guid = Guid.NewGuid(); _instancesService.InsertInstance(Scaffold.Instance(guid, 1, node.Id)); _service.InsertTask(Scaffold.Task(guid)); i += 1; } List <WorkflowTaskViewModel> result2 = _service.GetPendingTasks(new List <int> { (int)TaskStatus.PendingApproval }, 10, 1); Assert.NotNull(result2); Assert.Equal(i, result2.Count); }
public void Can_Get_Recursive_Permissions_When_Node_Has_No_Permissions() { Scaffold.ContentType(_contentTypeService); IContentType contentType = _contentTypeService.GetContentType("textpage"); IContent root = Scaffold.Node(_contentService); IContent child = Scaffold.Node(_contentService, root.Id); List <UserGroupPermissionsPoco> permissions = _configService.GetRecursivePermissionsForNode(root.ToPublishedContent()); Assert.Null(permissions); permissions = _configService.GetRecursivePermissionsForNode(child.ToPublishedContent()); Assert.Null(permissions); // add a permission so something is returned... var poco = new UserGroupPermissionsPoco { ContentTypeId = contentType.Id, GroupId = 3, Permission = 0 }; _configService.UpdateContentTypeConfig(new Dictionary <int, List <UserGroupPermissionsPoco> > { { 0, new List <UserGroupPermissionsPoco> { poco } } }); permissions = _configService.GetRecursivePermissionsForNode(child.ToPublishedContent()); Assert.NotNull(permissions); }
public void Can_Get_Populated_Instance(int taskCount, int lastGroupId) { IContent node = Scaffold.Node(ApplicationContext.Current.Services.ContentService); Guid guid = Guid.NewGuid(); WorkflowInstancePoco instance = Scaffold.Instance(guid, (int)WorkflowType.Publish, node.Id); _service.InsertInstance(instance); for (var i = 1; i <= taskCount; i += 1) { _tasksService.InsertTask(Scaffold.Task(guid, DateTime.Now, i < taskCount ? i : lastGroupId, i, i < taskCount ? 1 : 3)); } // this has groups, tasks, everything. Or it should. WorkflowInstancePoco populatedInstance = _service.GetPopulatedInstance(guid); Assert.Equal(taskCount, populatedInstance.TaskInstances.Count); Assert.Equal(0, populatedInstance.TotalSteps); // this shouldn't be set yet Assert.Equal(lastGroupId, populatedInstance.TaskInstances.First().UserGroup.GroupId); // tasks are descending by id Assert.Equal(WorkflowStatus.PendingApproval, populatedInstance.WorkflowStatus); }
public void Can_Get_Recursive_Permissions_For_Node_When_Node_Has_Permissions() { IContent root = Scaffold.Node(_contentService); IContent child = Scaffold.Node(_contentService, root.Id); IContent grandChild = Scaffold.Node(_contentService, child.Id); List <UserGroupPermissionsPoco> permissions = _configService.GetRecursivePermissionsForNode(grandChild.ToPublishedContent()); // node has no permissions, yet Assert.Empty(permissions); // add a permission so something is returned... var poco = new UserGroupPermissionsPoco { GroupId = 3, Permission = 0, NodeId = grandChild.Id }; _configService.UpdateNodeConfig(new Dictionary <int, List <UserGroupPermissionsPoco> > { { 0, new List <UserGroupPermissionsPoco> { poco } } }); permissions = _configService.GetRecursivePermissionsForNode(grandChild.ToPublishedContent()); Assert.Single(permissions); }
public void Can_Convert_To_IPublishedContent() { Scaffold.ContentType(_contentTypeService); IContent node = Scaffold.Node(_contentService); IPublishedContent content = node.ToPublishedContent(); Assert.NotNull(content); }
public void Can_Get_Node_Name() { Scaffold.ContentType(_contentTypeService); IContent home = Scaffold.Node(_contentService); string name = _utility.GetNodeName(home.Id); Assert.NotNull(name); Assert.Equal(home.Name, name); }
public void Can_Generate_Preview() { Scaffold.ContentType(ApplicationContext.Current.Services.ContentTypeService); IContent node = Scaffold.Node(ApplicationContext.Current.Services.ContentService); Guid guid = Guid.NewGuid(); _instancesService.InsertInstance(Scaffold.Instance(guid, 0, node.Id)); _previewService.Generate(node.Id, 0, guid); }
public void Can_Get_Node() { Scaffold.ContentType(_contentTypeService); IContent home = Scaffold.Node(_contentService); object node = _utility.GetContent(home.Id); Assert.NotNull(node); Assert.Equal(home.Id, node.Get("Id")); Assert.IsAssignableFrom <IContent>(node); }
public async void Get_Pending_Tasks_Response_Is_Generic_When_No_Settings_Or_Flow() { Scaffold.ContentType(_contentTypeService); IContent node = Scaffold.Node(_contentService); // generic response if no settings object content = await _tasksController.GetNodePendingTasks(node.Id).GetContent(); Assert.Null(content.Get("settings")); Assert.Null(content.Get("noFlow")); }
public void Can_Get_Content_Type_Permission_For_Node() { IContentType type = _contentTypeService.GetContentType("textpage"); IContent node = Scaffold.Node(_contentService); Dictionary <int, List <UserGroupPermissionsPoco> > perms = Scaffold.Permissions(0, 2, 0, type.Id); _configService.UpdateContentTypeConfig(perms); Assert.NotNull(_configService.GetPermissionsForNode(node.Id)); }
public void Can_Get_Tasks_By_Group_Id() { IContent node = Scaffold.Node(_contentService); Guid guid = Guid.NewGuid(); _instancesService.InsertInstance(Scaffold.Instance(guid, 1, node.Id)); _service.InsertTask(Scaffold.Task(guid, DateTime.Now.AddDays(-1), 3, 1, 1)); _service.InsertTask(Scaffold.Task(guid, DateTime.Now, 3, 3)); List <WorkflowTaskViewModel> result = _service.GetAllGroupTasks(3, 10, 1); Assert.NotNull(result); Assert.Equal(2, result.Count); }
public async void Can_Get_Paged_Node_Tasks() { // get an error if the node doesn't exist //object response = await _tasksController.GetNodeTasks(666, -1, -1).GetContent(); //Assert.Equal("NullReferenceException", (string)response.Get("ExceptionType")); //Assert.Equal(MagicStrings.ErrorGettingPendingTasksForNode.Replace("{id}", "666"), (string)response.Get("ExceptionMessage")); 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)); _tasksService.InsertTask(Scaffold.Task(guid)); _tasksService.InsertTask(Scaffold.Task(guid)); // needs flow or function exits Dictionary <int, List <UserGroupPermissionsPoco> > config = Scaffold.Permissions(node.Id, 3, 2); _configService.UpdateNodeConfig(config); JObject content = await _tasksController.GetNodeTasks(node.Id, 10, 1).GetContent(); Assert.Equal(1, content.Value <int>("totalPages")); Assert.Equal(10, content.Value <int>("count")); Assert.Equal(3, content.Value <JArray>("items").Count); // when 3 tasks, 1 per page, page 2 should be 1 item content = await _tasksController.GetNodeTasks(node.Id, 1, 2).GetContent(); Assert.Equal(3, content.Value <int>("totalPages")); Assert.Equal(1, content.Value <int>("count")); Assert.Single(content.Value <JArray>("items")); // when 5 tasks, and 2 per page, page 2 should be 2 items _tasksService.InsertTask(Scaffold.Task(guid)); _tasksService.InsertTask(Scaffold.Task(guid)); content = await _tasksController.GetNodeTasks(node.Id, 2, 2).GetContent(); Assert.Equal(3, content.Value <int>("totalPages")); Assert.Equal(2, content.Value <int>("count")); Assert.Equal(2, content.Value <JArray>("items").Count); }
public void Can_Get_Ancestor_Permissions() { // scaffold Scaffold.ContentType(_contentTypeService); IContent root = Scaffold.Node(_contentService); IContent child = Scaffold.Node(_contentService, root.Id); IContent childChild = Scaffold.Node(_contentService, child.Id); // set permissions on root // mock some data Dictionary <int, List <UserGroupPermissionsPoco> > config = Scaffold.Permissions(root.Id, 3, 2); _configService.UpdateNodeConfig(config); bool hasFlow = _utility.HasFlow(childChild.Id); Assert.True(hasFlow); }
public void Can_Get_Task_By_id() { IContent root = Scaffold.Node(_contentService); Guid guid = Guid.NewGuid(); _instancesService.InsertInstance(Scaffold.Instance(guid, 1, root.Id)); _service.InsertTask(Scaffold.Task(guid)); List <WorkflowTaskViewModel> tasks = _service.GetPendingTasks(new List <int> { (int)TaskStatus.PendingApproval }, 10, 1); int id = tasks.First().TaskId; WorkflowTaskViewModel taskViewModel = _service.GetTask(id); Assert.NotNull(taskViewModel); Assert.Equal(id, taskViewModel.TaskId); }
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")); }
public void Can_Get_Paged_Filtered_Tasks() { IContent node = Scaffold.Node(_contentService); Guid guid = Guid.NewGuid(); _instancesService.InsertInstance(Scaffold.Instance(guid, 1, node.Id)); _service.InsertTask(Scaffold.Task(guid)); _service.InsertTask(Scaffold.Task(guid)); _service.InsertTask(Scaffold.Task(guid)); _service.InsertTask(Scaffold.Task(guid)); _service.InsertTask(Scaffold.Task(guid, DateTime.Now, 2, 1, 1)); List <WorkflowTaskViewModel> tasks = _service.GetFilteredPagedTasksForDateRange(DateTime.Now.AddDays(-2), 2, 1); Assert.NotEmpty(tasks); Assert.Equal(2, tasks.Count); tasks = _service.GetFilteredPagedTasksForDateRange(DateTime.Now.AddDays(-2), 1, 1, "1"); Assert.NotEmpty(tasks); Assert.Single(tasks); }