public void Returns_Settings_If_Settings_Exist() { Scaffold.Config(); WorkflowSettingsPoco settings = _repo.GetSettings(); Assert.NotNull(settings); Assert.Equal("12", settings.DefaultApprover); }
public async void Cannot_Update_Group_With_Invalid_Model() { Scaffold.Config(); object result = await(await _groupsController.Put(null)).GetContent(); Assert.Equal(MagicStrings.ErrorUpdatingGroup, result.Get("ExceptionMessage")); }
public void Can_Get_All() { Scaffold.Config(); List <UserGroupPermissionsPoco> allPermissions = _configService.GetAll(); Assert.NotEmpty(allPermissions); }
public InstancesServiceTests() { Host.Run(new[] { "install y" }).Wait(); Scaffold.Run(); Scaffold.Config(); _service = new InstancesService(); }
public void Can_Initiate_Publish_Workflow() { Scaffold.Config(); var process = new DocumentPublishProcess(); WorkflowInstancePoco instance = process.InitiateWorkflow(1073, 3, "A test comment"); Assert.NotNull(instance); }
public void Recursive_Permissions_Returns_Null_When_Node_Is_Null() { Scaffold.Config(); // no node, returns immediately List <UserGroupPermissionsPoco> permissions = _configService.GetRecursivePermissionsForNode(null); Assert.Null(permissions); }
public ImportExportRepositoryTests() { Host.Run(new[] { "install y" }).Wait(); Scaffold.Run(); Scaffold.Config(); _repo = new ImportExportRepository(); }
public void Can_Export_User2UserGroups() { IEnumerable <User2UserGroupExport> user2UserGroups = _repo.ExportUser2UserGroups(); Assert.Empty(user2UserGroups); Scaffold.Config(); user2UserGroups = _repo.ExportUser2UserGroups(); Assert.NotEmpty(user2UserGroups); }
public InstancesServiceTests() { Host.Run(new[] { "install y" }).Wait(); Scaffold.Run(); Scaffold.Config(); Scaffold.ContentType(ApplicationContext.Current.Services.ContentTypeService); _service = new InstancesService(); _tasksService = new TasksService(); }
public void Can_Export_UserGroupPermissions() { IEnumerable <UserGroupPermissionsExport> userGroupPermissions = _repo.ExportUserGroupPermissions(); Assert.Empty(userGroupPermissions); Scaffold.Config(); userGroupPermissions = _repo.ExportUserGroupPermissions(); Assert.NotEmpty(userGroupPermissions); }
public async void Can_Export_All() { Scaffold.Config(); ImportExportModel export = await _importExportService.Export(); Assert.NotNull(export); Assert.NotEmpty(export.User2UserGroup); Assert.NotEmpty(export.UserGroupPermissions); Assert.NotEmpty(export.UserGroups); }
public async void Cannot_Validate_Request_When_No_Tasks() { Scaffold.Config(); Guid guid = Guid.NewGuid(); _instancesService.InsertInstance(Scaffold.Instance(guid, 1, 1089)); bool isValid = await _previewService.Validate(1089, 99, 6456, guid); Assert.False(isValid); }
public ConfigServiceTests() { Host.Run(new[] { "install y" }).Wait(); Scaffold.Run(); Scaffold.Config(); _configService = new ConfigService(new PocoRepository()); _contentService = ApplicationContext.Current.Services.ContentService; _contentTypeService = ApplicationContext.Current.Services.ContentTypeService; }
public void Can_Get_Tasks_By_Group_Id() { Scaffold.Config(); _service.InsertTask(Scaffold.Task(Guid.Empty, DateTime.Now.AddDays(-1), 3, 1, 1)); _service.InsertTask(Scaffold.Task(Guid.Empty, DateTime.Now, 3, 3)); List <WorkflowTask> result = _service.GetAllGroupTasks(3, 10, 1); Assert.NotNull(result); Assert.Equal(2, result.Count); }
public void Can_Get_Permissions_For_Node() { Scaffold.Config(); // will return an empty collection as no permissions exist Assert.Empty(_configService.GetPermissionsForNode(9999)); // this one has a permission, so should return something var permissions = _configService.GetPermissionsForNode(1089); Assert.NotEmpty(permissions); }
public void Can_Export_Settings() { WorkflowSettingsExport settings = _repo.ExportSettings(); Assert.NotNull(settings); Assert.Null(settings.DefaultApprover); Scaffold.Config(); settings = _repo.ExportSettings(); Assert.NotNull(settings); Assert.Equal("12", settings.DefaultApprover); }
public void Can_Get_Task_By_id() { Scaffold.Config(); _service.InsertTask(Scaffold.Task()); List <WorkflowTask> tasks = _service.GetPendingTasks(new[] { 1, 2, 3 }, 10, 1); int id = tasks.First().TaskId; WorkflowTask task = _service.GetTask(id); Assert.NotNull(task); Assert.Equal(id, task.TaskId); }
public void Can_Get_Tasks_With_Group_By_Instance_Guid() { Scaffold.Config(); Guid guid = Guid.NewGuid(); _instancesService.InsertInstance(Scaffold.Instance(guid, 1)); _service.InsertTask(Scaffold.Task(guid)); List <WorkflowTaskInstancePoco> result = _service.GetTasksWithGroupByInstanceGuid(guid); Assert.NotNull(result); Assert.Single(result); Assert.Equal(1, result[0].GroupId); // same as default in scaffold.task }
public async void Cannot_Update_Group_If_Name_In_Use() { Scaffold.Config(); var group = new UserGroupPoco { GroupId = 3, Name = "Publisher", Users = new List <User2UserGroupPoco>() }; object result = await(await _groupsController.Put(group)).GetContent(); Assert.Equal(MagicStrings.GroupNameExists, result.Get("msg")); }
public async void Cannot_Validate_Request_When_Last_Task_Not_Pending() { Scaffold.Config(); Guid guid = Guid.NewGuid(); WorkflowTaskInstancePoco task = Scaffold.Task(guid, status: (int)TaskStatus.NotRequired); _tasksService.InsertTask(task); _instancesService.InsertInstance(Scaffold.Instance(guid, 1, 1089)); bool isValid = await _previewService.Validate(1089, 0, task.Id, guid); Assert.False(isValid); }
public void Can_Get_Tasks_By_Node_Id() { Scaffold.Config(); const int nodeId = 1055; Guid guid = Guid.NewGuid(); _instancesService.InsertInstance(Scaffold.Instance(guid, 1, nodeId)); _service.InsertTask(Scaffold.Task(guid, DateTime.Now.AddDays(-1), 3, 1, 1)); _service.InsertTask(Scaffold.Task(guid, DateTime.Now, 3, 3)); List <WorkflowTaskInstancePoco> result = _service.GetTasksByNodeId(nodeId); Assert.NotNull(result); Assert.Equal(2, result.Count); }
public async void Can_Update_Group() { Scaffold.Config(); var group = new UserGroupPoco { GroupId = 12, Name = "PublisherUpdated", Alias = "publisherUpdated", Users = new List <User2UserGroupPoco>() }; object result = await(await _groupsController.Put(group)).GetContent(); Assert.Equal(MagicStrings.GroupUpdated.Replace("{name}", "PublisherUpdated"), result.Get("msg")); }
public PreviewServiceTests() { Host.Run(new[] { "install y" }).Wait(); Scaffold.Run(); Scaffold.Config(); // even though it's not being used, this needs to stay _mocker = new ContextMocker(); _previewService = new PreviewService(); _tasksService = new TasksService(); _instancesService = new InstancesService(); _configService = new ConfigService(); _groupService = new GroupService(); }
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 async void Can_Delete_Group_And_Event_Is_Raised() { // populate groups Scaffold.Config(); IEnumerable <UserGroupPoco> groups = await _groupService.GetUserGroupsAsync(); int groupId = groups.First().GroupId; GroupService.Deleted += (sender, args) => { Assert.NotNull(args); Assert.Equal(groupId, args.GroupId); }; await _groupService.DeleteUserGroupAsync(groupId); }
public void Can_Get_Recursive_Permissions_For_Node() { Scaffold.Config(); Scaffold.ContentType(_contentTypeService); var type = _contentTypeService.GetContentType("textpage"); var mock = new MockRepository(MockBehavior.Default); Mock <IPublishedContent> content = mock.Create <IPublishedContent>(); content.Setup(x => x.Id).Returns(1089); List <UserGroupPermissionsPoco> permissions = _configService.GetRecursivePermissionsForNode(content.Object); // node has permissions, returns without recursion Assert.NotNull(permissions); // todo - to recurse, we need a contenttype }
public void Can_Get_Paged_Filtered_Tasks() { Scaffold.Config(); _service.InsertTask(Scaffold.Task()); _service.InsertTask(Scaffold.Task()); _service.InsertTask(Scaffold.Task()); _service.InsertTask(Scaffold.Task()); _service.InsertTask(Scaffold.Task(new Guid(), DateTime.Now, 2, 1, 1)); List <WorkflowTask> 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); }
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_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 void Can_Get_Pending_Workflow_Tasks() { Scaffold.Config(); const int nodeId = 1055; List <WorkflowTask> result = _service.GetPendingTasks(new[] { 1, 2, 3 }, 10, 1); Assert.NotNull(result); Assert.Empty(result); Guid guid = Guid.NewGuid(); _instancesService.InsertInstance(Scaffold.Instance(guid, 1, nodeId)); _service.InsertTask(Scaffold.Task(guid, DateTime.Now.AddDays(-4), 2, 1, 1)); _service.InsertTask(Scaffold.Task(guid, DateTime.Now.AddDays(-1), 3, 2, 1)); _service.InsertTask(Scaffold.Task(guid, DateTime.Now, 3, 3)); result = _service.GetPendingTasks(new[] { 1, 2, 3 }, 10, 1); Assert.NotNull(result); Assert.Equal(3, result.Count); }