public void Given_showing_completed_tasks_When_GetAdditionalTitle_Then_returns_completed()
        {
            // Given
            var target = new TaskListViewModel
            {
                IsShowCompleted = true
            };

            // When
            var result = target.GetAdditionalTitle();

            // Then
            Assert.That(result.ToString(), Is.EqualTo("<strong>Completed</strong>"));
        }
        public void Given_showing_completed_tasks_When_IsShowOutsandingVisible_Then_is_true()
        {
            // Given
            var target = new TaskListViewModel
            {
                IsShowCompleted = true
            };

            // When
            var result = target.IsShowOutsandingVisible();

            // Then
            Assert.IsTrue(result);
        }
        public void Given_not_showing_deleted_tasks_When_IsShowOutsandingVisible_Then_is_false()
        {
            // Given
            var target = new TaskListViewModel
            {
                IsShowDeleted = false
            };

            // When
            var result = target.IsShowOutsandingVisible();

            // Then
            Assert.IsFalse(result);
        }
示例#4
0
        public void Given_find_Then_correct_view_model_is_returned()
        {
            //Given
            var target = CreateController();

            var viewModel = new TaskListViewModel();
            _mockViewModelFactory.Setup(x => x.GetViewModel()).Returns(viewModel);

            //When
            var result = target.Find(_employeeId, null, null, null, null, null, 0, 0);

            //Then
            Assert.That(result.Model, Is.Not.Null);
            Assert.That(result.Model, Is.TypeOf<TaskListViewModel>());
        }
        public TaskListViewModel GetViewModel()
        {
            using (var session = _businessSafeSessionManager.Session)
            {
                session.FlushMode = FlushMode.Never;

                var employeeIds = GetEmployeeIdsToSearchFor();
                    // If the user wants to view tasks for ALL employees in there company, then retrieve the list of employeeids to find tasks for
                var sites = GetSites();
                var siteGroups = GetSiteGroups();
                var employees = GetEmployees();

                var request = new SearchTasksRequest()
                                  {
                                      CompanyId = _companyId,
                                      EmployeeIds = employeeIds,
                                      CreatedFrom = _createdFrom,
                                      CreatedTo = _createdTo,
                                      CompletedFrom = _completedFrom,
                                      CompletedTo = _completedTo,
                                      TaskCategoryId = _taskCategoryId,
                                      TaskStatusId = _taskStatusId,
                                      ShowDeleted = _showDeleted,
                                      ShowCompleted = _showCompleted,
                                      SiteId = _siteId,
                                      SiteGroupId = _siteGroupId,
                                      AllowedSiteIds = _allowedSiteIds,
                                      Title = _title,
                                      Page = _page != default(int) ? _page : 1,
                                      PageSize = _pageSize != default(int) ? _pageSize : DEFAULT_PAGE_SIZE,
                                      OrderBy = GetOrderBy(),
                                      Ascending = Ascending()
                                  };

                var total = _taskService.Count(request);
                var employeeTasksDto = _taskService.Search(request);

                var viewModel = new TaskListViewModel
                                    {
                                        CompanyId = _companyId,
                                        EmployeeId = (_userEmployeeId.HasValue ? _userEmployeeId : _employeeId),
                                        Employees = employees,
                                        CreatedFrom = _createdFrom,
                                        CreatedTo = _createdTo,
                                        CompletedFrom = _completedFrom,
                                        CompletedTo = _completedTo,
                                        TaskCategories = GetTaskCategories(),
                                        Tasks = TaskViewModel.CreateFrom(employeeTasksDto),
                                        IsBulkReassign = _isBulkReassign,
                                        Sites = sites,
                                        SiteGroups = siteGroups,
                                        SiteId = _siteId,
                                        SiteGroupId = _siteGroupId,
                                        IsShowDeleted = _showDeleted,
                                        IsShowCompleted = _showCompleted,
                                        PageSize = _pageSize != default(int) ? _pageSize : DEFAULT_PAGE_SIZE,
                                        Total = total
                                    };

                return viewModel;
            }
        }
        public void Given_showing_bulk_reassign_tasks_When_GetAdditionalTitle_Then_returns_bulk_reassign()
        {
            // Given
            var target = new TaskListViewModel
            {
                IsBulkReassign = true
            };

            // When
            var result = target.GetAdditionalTitle();

            // Then
            Assert.That(result.ToString(), Is.EqualTo("<strong>Bulk Reassign</strong>"));
        }
        public void Given_showing_outstanding_tasks_When_GetAdditionalTitle_Then_returns_outstanding()
        {
            // Given
            var target = new TaskListViewModel
            {
                IsShowDeleted = false,
                IsShowCompleted = false,
                IsBulkReassign = false
            };

            // When
            var result = target.GetAdditionalTitle();

            // Then
            Assert.That(result.ToString(), Is.EqualTo("<strong>Outstanding</strong>"));
        }