Exemplo n.º 1
0
        public void Returns_Settings_If_Settings_Exist()
        {
            Scaffold.Config();
            WorkflowSettingsPoco settings = _repo.GetSettings();

            Assert.NotNull(settings);
            Assert.Equal("12", settings.DefaultApprover);
        }
Exemplo n.º 2
0
        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"));
        }
Exemplo n.º 3
0
        public void Can_Get_All()
        {
            Scaffold.Config();

            List <UserGroupPermissionsPoco> allPermissions = _configService.GetAll();

            Assert.NotEmpty(allPermissions);
        }
Exemplo n.º 4
0
        public InstancesServiceTests()
        {
            Host.Run(new[] { "install y" }).Wait();

            Scaffold.Run();
            Scaffold.Config();

            _service = new InstancesService();
        }
Exemplo n.º 5
0
        public void Can_Initiate_Publish_Workflow()
        {
            Scaffold.Config();

            var process = new DocumentPublishProcess();
            WorkflowInstancePoco instance = process.InitiateWorkflow(1073, 3, "A test comment");

            Assert.NotNull(instance);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 9
0
        public InstancesServiceTests()
        {
            Host.Run(new[] { "install y" }).Wait();

            Scaffold.Run();
            Scaffold.Config();
            Scaffold.ContentType(ApplicationContext.Current.Services.ContentTypeService);

            _service      = new InstancesService();
            _tasksService = new TasksService();
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        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;
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        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
        }
Exemplo n.º 19
0
        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"));
        }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
        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"));
        }
Exemplo n.º 23
0
        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();
        }
Exemplo n.º 24
0
        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);
        }
Exemplo n.º 26
0
        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
        }
Exemplo n.º 27
0
        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"));
        }
Exemplo n.º 29
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);
        }
Exemplo n.º 30
0
        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);
        }