Exemplo n.º 1
0
 public void SetUp()
 {
     task = new Task()
                {
                    Name = "test"
                };
     _id = task.Id;
     inModel = new TaskEditSetupViewModel(){Id = _id};
     updateInModel = new TaskEditSubmitViewModel(){Id = _id};
     repository = MockRepository.GenerateMock<Repository>();
     repository.Stub(x => x.Get<Task>(_id)).Return(task);
     tlc = new TaskController(repository);
 }
        public void TestDeleteTaskService()
        {
            bool actualResult   = false;
            bool expectedResult = true;

            Entities.Task itemToDelete = new Entities.Task();

            var controller   = new TaskController();
            var actionResult = controller.GetAllTasks() as OkNegotiatedContentResult <List <Task> >;

            itemToDelete = actionResult.Content.FirstOrDefault();

            controller.DeleteTask(itemToDelete.Task_Id);

            var deletedItem = controller.GetTaskByID(itemToDelete.Task_Id) as OkNegotiatedContentResult <Task>;

            if (deletedItem == null)
            {
                actualResult = true;
            }
            Assert.AreEqual(actualResult, expectedResult);
        }
        public void Post()
        {
            // Arrange
            TaskModel record = new TaskModel()
            { Task ="Current Task",
              ParentTask ="Parent Task",
              Project ="Project Manager",
              Priority= 2,
              Status ="Completed",
              User ="******",
              StartDate =DateTime.Now,
              EndDate =DateTime.Now
            };
            TaskController controller = new TaskController();

            // Act
            var result = controller.Post(record);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(true, result);
        }
Exemplo n.º 4
0
        public void FillData()
        {
            DataTable taskDetail = new TaskController().GetTaskDetails(task.TaskID);

            //  txtTaskID.Text = taskDetail.Rows[0]["TASK_ID"].ToString();
            txtTask.Text              = taskDetail.Rows[0]["TASK_NAME"].ToString();
            txtstartDate.Text         = taskDetail.Rows[0]["TASK_START_DATE"].ToString();
            txtEndDate.Text           = taskDetail.Rows[0]["TASK_END_DATE"].ToString();
            txtAssign.Content         = taskDetail.Rows[0]["EMPLOYEE_NAME"].ToString();
            txtRemainingHour.Text     = taskDetail.Rows[0]["ESTIMATED_REMAINING_HOUR"].ToString();
            txtCompletedProgress.Text = taskDetail.Rows[0]["ESTIMATED_PROGRESS"].ToString();
            txtSkill.Content          = taskDetail.Rows[0]["SKILL_NAME"].ToString();
            cmbPriority.SelectedValue = taskDetail.Rows[0]["PRIORITY"].ToString();

            string status = taskDetail.Rows[0]["TASK_STATUS"].ToString();

            if (status.Equals("In Progress"))
            {
                rdoProgress.IsChecked = true;
            }
            else if (status.Equals("Completed"))
            {
                rdoCompleted.IsChecked = true;
            }
            else if (status.Equals("Remaining"))
            {
                rdoRemaining.IsChecked = true;
            }
            else
            {
                rdoProgress.IsChecked  = false;
                rdoCompleted.IsChecked = false;
                rdoRemaining.IsChecked = false;
            }

            TextRange tr = new TextRange(txtWork.Document.ContentStart, txtWork.Document.ContentEnd);

            tr.Text = taskDetail.Rows[0]["WORK_DONE"].ToString();
        }
Exemplo n.º 5
0
        public async Task DeleteConfirmedRedirectsToCorrectAction()
        {
            var deleteViewModel = new DeleteViewModel {
                EventId = 1, UserIsOrgAdmin = true
            };

            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.SendAsync(It.IsAny <AuthorizableTaskQuery>())).ReturnsAsync(new FakeAuthorizableTask(false, true, false, false));

            var sut = new TaskController(mediator.Object, null);

            var result = await sut.DeleteConfirmed(deleteViewModel) as RedirectToActionResult;

            var routeValues = new Dictionary <string, object> {
                ["id"] = deleteViewModel.EventId
            };

            Assert.Equal(result.ActionName, nameof(EventController.Details));
            Assert.Equal(result.ControllerName, "Event");
            Assert.Equal(result.RouteValues, routeValues);
        }
Exemplo n.º 6
0
        public async Task EditPostSendsEditTaskCommandWithCorrectModel_WhenModelStateIsValidAndUserIsAuthorized()
        {
            var model = new EditViewModel {
            };

            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.SendAsync(It.IsAny <EditVolunteerTaskCommand>())).ReturnsAsync(1);
            mediator.Setup(x => x.SendAsync(It.IsAny <AllReady.Areas.Admin.Features.Events.AuthorizableEventQuery>()))
            .ReturnsAsync(new FakeAuthorizableEvent(false, false, false, true));
            mediator.Setup(x => x.SendAsync(It.IsAny <AuthorizableTaskQuery>())).ReturnsAsync(new FakeAuthorizableTask(false, true, false, false));

            var validator = new Mock <IValidateVolunteerTaskEditViewModelValidator>();

            validator.Setup(x => x.Validate(It.IsAny <EditViewModel>())).ReturnsAsync(new List <KeyValuePair <string, string> >());

            var sut = new TaskController(mediator.Object, validator.Object);

            await sut.Edit(model);

            mediator.Verify(x => x.SendAsync(It.Is <EditVolunteerTaskCommand>(y => y.VolunteerTask == model)));
        }
Exemplo n.º 7
0
        public async Task EditGetSendsEditTaskQueryWithCorrectTaskId()
        {
            const int volunteerTaskId = 1;

            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.SendAsync(It.IsAny <EditVolunteerTaskQuery>())).ReturnsAsync(new EditViewModel {
            });
            mediator.Setup(x => x.SendAsync(It.IsAny <AuthorizableTaskQuery>())).ReturnsAsync(new FakeAuthorizableTask(true, false, false, false));

            var urlHelper = new Mock <IUrlHelper>();

            urlHelper.Setup(x => x.Action(It.IsAny <UrlActionContext>())).Returns(It.IsAny <string>());

            var sut = new TaskController(mediator.Object, null)
            {
                Url = urlHelper.Object
            };
            await sut.Edit(volunteerTaskId);

            mediator.Verify(x => x.SendAsync(It.Is <EditVolunteerTaskQuery>(y => y.VolunteerTaskId == volunteerTaskId)), Times.Once);
        }
Exemplo n.º 8
0
        public async Task CreateGetReturnsCorrectView()
        {
            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.SendAsync(It.IsAny <CreateVolunteerTaskQuery>())).ReturnsAsync(new EditViewModel {
            });
            mediator.Setup(x => x.SendAsync(It.IsAny <AllReady.Areas.Admin.Features.Events.AuthorizableEventQuery>()))
            .ReturnsAsync(new FakeAuthorizableEvent(false, false, false, true));

            var urlHelper = new Mock <IUrlHelper>();

            urlHelper.Setup(x => x.Action(It.IsAny <UrlActionContext>())).Returns(It.IsAny <string>());

            var sut = new TaskController(mediator.Object, null)
            {
                Url = urlHelper.Object
            };

            var result = await sut.Create(It.IsAny <int>()) as ViewResult;

            Assert.Equal(result.ViewName, "Edit");
        }
Exemplo n.º 9
0
        public async Task AssignReturnsHttpUnauthorizedResultWhenUserIsNotOrgAdmin()
        {
            var taskModelSummary = new TaskSummaryModel {
                EventId = 1
            };

            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.SendAsync(It.IsAny <TaskQueryAsync>())).ReturnsAsync(taskModelSummary);
            mediator.Setup(x => x.Send(It.IsAny <EventByIdQuery>())).Returns(new Event {
                Campaign = new Campaign {
                    ManagingOrganizationId = 1
                }
            });

            var sut = new TaskController(mediator.Object);

            sut.SetDefaultHttpContext();
            var result = await sut.Assign(1, null);

            Assert.IsType <HttpUnauthorizedResult>(result);
        }
Exemplo n.º 10
0
        public async Task EditPostReturnsCorrectViewAndViewModelWhenEndDateTimeIsLessThanStartDateTimeAndModelStateIsInvalid()
        {
            var model = new TaskEditModel {
                EndDateTime = DateTimeOffset.Now.AddDays(-1), StartDateTime = DateTimeOffset.Now.AddDays(1)
            };

            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.Send(It.IsAny <EventByIdQuery>())).Returns(new Event {
                Campaign = new Campaign {
                    TimeZoneId = "Eastern Standard Time"
                }
            });

            var sut    = new TaskController(mediator.Object);
            var result = await sut.Edit(model) as ViewResult;

            var modelResult = result.ViewData.Model as TaskEditModel;

            Assert.IsType <ViewResult>(result);
            Assert.Equal(modelResult, model);
        }
Exemplo n.º 11
0
        public async Task CreatePostRedirectsToCorrectAction()
        {
            const int organizationId   = 1;
            var       taskSummaryModel = new TaskSummaryModel {
                OrganizationId = organizationId
            };
            var       startDateTime   = DateTimeOffset.Now.AddDays(-1);
            var       endDateTime     = DateTimeOffset.Now.AddDays(1);
            const int taskEditModelId = 1;
            var       model           = new TaskEditModel {
                Id = taskEditModelId, StartDateTime = startDateTime, EndDateTime = endDateTime, OrganizationId = organizationId
            };

            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.Send(It.IsAny <EventByIdQuery>())).Returns(new Event
            {
                Campaign = new Campaign {
                    TimeZoneId = "Eastern Standard Time"
                },
                StartDateTime = startDateTime.AddDays(-1),
                EndDateTime   = endDateTime.AddDays(1)
            });
            mediator.Setup(x => x.SendAsync(It.IsAny <TaskQueryAsync>())).ReturnsAsync(taskSummaryModel);

            var routeValues = new Dictionary <string, object> {
                ["id"] = model.Id
            };

            var sut = new TaskController(mediator.Object);

            MakeUserOrganizationAdminUser(sut, organizationId.ToString());

            var result = await sut.Create(taskEditModelId, model) as RedirectToActionResult;

            Assert.Equal(result.ActionName, nameof(TaskController.Details));
            Assert.Equal(result.ControllerName, "Event");
            Assert.Equal(result.RouteValues, routeValues);
        }
 public AddUpdateChildTaskForm(User _user, bool _isUpdate, dateForm dateForm, childTasksForm childTasksForm)
 {
     InitializeComponent();
     user     = _user;
     isUpdate = _isUpdate;
     //load tasks into comboBox
     this.dateForm       = dateForm;
     this.childTasksForm = childTasksForm;
     //LoadComboBoxes();
     //comboPriority.SelectedIndex = 0;
     instance = this;
     deadlinePicker.Format       = DateTimePickerFormat.Custom;
     deadlinePicker.CustomFormat = "MM/dd/yyyy hh:mm tt";
     if (dateForm != null)
     {
         this.taskTitle = TaskController.getATask(dateForm.getSelectedNodeTaskID()).title;
     }
     else if (childTasksForm != null)
     {
         this.taskTitle = childTasksForm.getTask().title;
     }
 }
        public void TestRetrieveParentTasks_Success(BenchmarkContext benchContext)
        {
            var context     = new MockProjectManagerEntities();
            var parentTasks = new TestDbSet <DAC.ParentTask>();

            parentTasks.Add(new DAC.ParentTask()
            {
                Parent_ID        = 12345,
                Parent_Task_Name = "PTASK"
            });
            parentTasks.Add(new DAC.ParentTask()
            {
                Parent_ID        = 123456,
                Parent_Task_Name = "MYTASK"
            });
            context.ParentTasks = parentTasks;

            var controller = new TaskController(new BC.TaskBC(context));
            var result     = controller.RetrieveParentTasks() as JSendResponse;

            addCounter.Increment();
        }
Exemplo n.º 14
0
        public void TestInsertTasks_Success()
        {
            var context = new MockProjectManagerEntities();
            var users   = new TestDbSet <DAC.User>();

            users.Add(new DAC.User()
            {
                Employee_ID = "654219",
                First_Name  = "Rajesh",
                Last_Name   = "Ray",
                User_ID     = 123,
            });
            context.Users = users;
            var task = new ProjectManager.Models.Task()
            {
                Task_Name  = "ASDQW",
                Parent_ID  = 123674,
                Project_ID = 34856,
                Start_Date = DateTime.Now,
                End_Date   = DateTime.Now.AddDays(2),
                Priority   = 10,
                Status     = 0,
                User       = new User()
                {
                    FirstName  = "Rajesh",
                    LastName   = "Ray",
                    EmployeeId = "654219",
                    UserId     = 1000
                }
            };

            var controller = new TaskController(new BC.TaskBC(context));
            var result     = controller.InsertTaskDetails(task) as JSendResponse;


            Assert.IsNotNull(result);

            Assert.IsNotNull((context.Users.Local[0]).Employee_ID);
        }
        public async Task GetTaskAll_ShouldExecuteRepository_GetTaskAll()
        {
            using (var context = new TaskDbContext(contextOptions, configuration, DataBaseFlags.Test))
            {
                //Arrange
                var textService = new Services.TaskService(context, _mapper, _cacheTaskService.Object);
                var controller  = new TaskController(textService);

                //Act
                var actionResultFromController = await controller.GetAllTask();

                //Assert
                var objectResult = actionResultFromController.Result as OkObjectResult;
                var taskResults  = objectResult.Value as List <TaskResultModel>;

                Assert.NotNull(objectResult);
                Assert.NotNull(taskResults);
                Assert.Equal(200, objectResult.StatusCode);
                Assert.Equal(_textTaskResult[0].Count, taskResults[0].ListGuids[0].ListFoundWord[0].Count);  // 1
                Assert.Equal(_textTaskResult[1].Count, taskResults[0].ListGuids[0].ListFoundWord[1].Count);  // 21
            }
        }
Exemplo n.º 16
0
        public DTOTaskStatus GetTask(int TaskId)
        {
            DTOTaskStatus objDTOStatus = new DTOTaskStatus();

            objDTOStatus.Success       = true;
            objDTOStatus.StatusMessage = "";

            // Get Settings
            string CurrentHostLocation = $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}";
            string ContentRootPath     = _hostEnvironment.ContentRootPath;
            string strCurrentUser      = this.User.Claims.FirstOrDefault().Value;
            string strConnectionString = GetConnectionString();
            int    intUserId           = -1;
            bool   IsAdministrator     = true;
            bool   IsAuthenticated     = true;

            try
            {
                DTOTask obJDTOTask = new DTOTask();
                obJDTOTask.taskId         = TaskId;
                obJDTOTask.ticketPassword = "";

                objDTOStatus.Task = TaskController.GetTask(
                    obJDTOTask,
                    intUserId,
                    IsAdministrator,
                    strConnectionString,
                    strCurrentUser,
                    IsAuthenticated);
            }
            catch (Exception ex)
            {
                objDTOStatus.Success       = false;
                objDTOStatus.StatusMessage = ex.GetBaseException().Message;
            }

            return(objDTOStatus);
        }
Exemplo n.º 17
0
        private void TienDo()
        {
            N = 0;
            foreach (ListViewItem Item in listPC.Items)
            {
                if (Item.SubItems[4].Text.Contains("Xong"))
                {
                    N++;
                }
            }
            var Total = listPC.Items.Count;

            pbTiendo1.Minimum = 0;
            pbTiendo1.Maximum = Total;
            pbTiendo1.Value   = N;
            if (N == Total)
            {
                Models.Task task = new Models.Task();
                task        = TaskController.GetTask(taskid);
                task.tienDo = "100%";
                TaskController.UpdateTask(task);
                var i = 100;
                pbTiendo1.CreateGraphics().DrawString(i.ToString() + "%", new Font("Arial", (float)10.25, FontStyle.Bold),
                                                      Brushes.Red, new PointF(pbTiendo1.Width / 2 - 10, pbTiendo1.Height / 2 - 7));
            }
            else
            {
                Models.Task task = new Models.Task();
                task = TaskController.GetTask(taskid);
                var x = (double)N / Total * 100;
                var i = (Math.Round(x));
                task.tienDo = i.ToString() + "%";
                TaskController.UpdateTask(task);
                pbTiendo1.CreateGraphics().DrawString(i.ToString() + "%", new Font("Arial", (float)10.25, FontStyle.Bold),
                                                      Brushes.Red, new PointF(pbTiendo1.Width / 2 - 10, pbTiendo1.Height / 2 - 7));
            }
            pbTiendo1.BeginInvoke(new Action(delegate() { pbTiendo1.Value = N; }));
        }
        public void TestEndTaskService()
        {
            bool actualResult   = false;
            bool expectedResult = true;

            Entities.Task itemToEnd = new Entities.Task();

            var controller   = new TaskController();
            var actionResult = controller.GetAllTasks() as OkNegotiatedContentResult <List <Task> >;

            itemToEnd = actionResult.Content.Where(item => item.Status.Equals(false)).FirstOrDefault();
            if (itemToEnd != null)
            {
                controller.EndTask(itemToEnd.Task_ID);
                actionResult = controller.GetAllTasks() as OkNegotiatedContentResult <List <Task> >;
                itemToEnd    = actionResult.Content.Where(item => item.Task_ID.Equals(itemToEnd.Task_ID)).FirstOrDefault();
                if (itemToEnd.Status ?? true)
                {
                    actualResult = true;
                }
            }
            Assert.AreEqual(actualResult, expectedResult);
        }
        public void TestUpdateService()
        {
            bool actualResult   = true;
            bool expectedResult = true;
            //Entities.Task itemToUpdate = new Entities.Task();

            var controller   = new TaskController();
            var actionResult = controller.GetAllTasks() as OkNegotiatedContentResult <List <Task> >;

            var itemToUpdate = actionResult.Content.FirstOrDefault();

            itemToUpdate.Task_Name = "UpdatedTaskName_Nunit";
            controller.UpdateTask(itemToUpdate);

            var updatedItem = controller.GetTaskByID(itemToUpdate.Task_ID) as OkNegotiatedContentResult <Task>;

            if (!updatedItem.Content.Task_Name.Equals("UpdatedTaskName_Nunit"))
            {
                actualResult = false;
            }

            Assert.AreEqual(actualResult, expectedResult);
        }
Exemplo n.º 20
0
        public void QueryTasks_ShouldReturnAllProjects()
        {
            //arrange
            var testProjects = GetTestTasks();
            var queryResult  = new FilterResult <Task>()
            {
                Data = testProjects, Total = testProjects.Count()
            };
            var mockTaskRepository = new Mock <ITaskRepository>().Object;

            Mock.Get <ITaskRepository>(mockTaskRepository).Setup(r => r.Query(It.IsAny <FilterState>())).Returns(queryResult);

            var taskFacade     = new TaskFacade(mockTaskRepository);
            var taskController = new TaskController(taskFacade);
            var filterState    = new FilterState();

            //act : no filters
            var x      = taskController.Query(filterState);
            var result = x as OkNegotiatedContentResult <FilterResult <TaskDto> >;

            //assert
            Assert.AreEqual(testProjects.Count(), result.Content.Total);
        }
        public void CreateTask()
        {
            var mockSet = new Mock <DbSet <Task> >();

            var mockContext = new Mock <PrMngSystemDBEntities>();

            mockContext.Setup(m => m.Tasks).Returns(mockSet.Object);

            var service = new TaskController();

            var task = new Task
            {
                progress    = (decimal)12.00,
                deadline    = DateTime.Parse("12-Mar-19 12:00:00 AM"),
                description = "task desc",
                status      = 2,
                assignee    = null
            };

            var result = service.CreateTask(1, task);

            Assert.IsNotNull(result);
        }
Exemplo n.º 22
0
        public void Task_Update_ValidData_Return_OkResult()
        {
            //Arrange
            var controller = new TaskController(taskService);
            var id         = 2;

            //Act
            var existingTask = controller.Get(id);
            var okResult     = existingTask.Should().BeOfType <OkObjectResult>().Subject;
            var result       = okResult.Value.Should().BeAssignableTo <Task>().Subject;

            var task = new Task();

            task.Assignee    = result.Assignee;
            task.Description = result.Description;
            task.IsCompleted = result.IsCompleted;
            task.DueDate     = result.DueDate;

            var updatedData = controller.Put(id, task);

            //Assert
            Assert.IsType <OkResult>(updatedData);
        }
Exemplo n.º 23
0
        public async Task DeleteReturnsCorrectViewModelAndView()
        {
            const int organizationId  = 1;
            var       deleteViewModel = new DeleteViewModel {
                OrganizationId = organizationId
            };

            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.SendAsync(It.IsAny <DeleteQuery>())).ReturnsAsync(deleteViewModel);

            var sut = new TaskController(mediator.Object, null);

            sut.MakeUserAnOrgAdmin(organizationId.ToString());

            var result = await sut.Delete(It.IsAny <int>()) as ViewResult;

            var modelResult = result.ViewData.Model as DeleteViewModel;

            Assert.IsType <ViewResult>(result);
            Assert.IsType <DeleteViewModel>(modelResult);
            Assert.Equal(modelResult, deleteViewModel);
        }
Exemplo n.º 24
0
        internal List <CompoundIssue> CompareTasksToUserPrefs(List <Issue> tasks, Dictionary <string, string> linkedTasks)
        {
            var issueList = new List <CompoundIssue>();

            foreach (var issue in tasks)
            {
                if (linkedTasks.ContainsKey(issue.Key.Value))
                {
                    issueList.Add(new CompoundIssue()
                    {
                        DevTask = issue, LinkedTask = TaskController.GetIssue(linkedTasks[issue.Key.Value])
                    });
                }
                else
                {
                    issueList.Add(new CompoundIssue()
                    {
                        DevTask = issue
                    });
                }
            }
            return(issueList);
        }
Exemplo n.º 25
0
        public async Task AssignSendsTaskQueryAsyncWithCorrectTaskId()
        {
            const int taskId           = 1;
            var       taskModelSummary = new TaskSummaryModel {
                ActivityId = 1
            };

            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.Send(It.IsAny <ActivityByActivityIdQuery>())).Returns(new Activity {
                Campaign = new Campaign {
                    ManagingOrganizationId = 1
                }
            });
            mediator.Setup(x => x.SendAsync(It.IsAny <TaskQueryAsync>())).ReturnsAsync(taskModelSummary);

            var sut = new TaskController(mediator.Object);

            sut.SetDefaultHttpContext();
            await sut.Assign(taskId, null);

            mediator.Verify(x => x.SendAsync(It.Is <TaskQueryAsync>(y => y.TaskId == taskId)), Times.Once);
        }
Exemplo n.º 26
0
        public async Task DeleteReturnsCorrectViewModelAndView()
        {
            const int organizationId   = 1;
            var       taskSummaryModel = new TaskSummaryModel {
                OrganizationId = organizationId
            };

            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.SendAsync(It.IsAny <TaskQueryAsync>())).ReturnsAsync(taskSummaryModel);

            var sut = new TaskController(mediator.Object);

            MakeUserOrganizationAdminUser(sut, organizationId.ToString());

            var result = await sut.Delete(It.IsAny <int>()) as ViewResult;

            var modelResult = result.ViewData.Model as TaskSummaryModel;

            Assert.IsType <ViewResult>(result);
            Assert.IsType <TaskSummaryModel>(modelResult);
            Assert.Equal(modelResult, taskSummaryModel);
        }
Exemplo n.º 27
0
        static void Main(string[] args)
        {
            try
            {
                Log.Information("Starting server...");
                using (var actionExecutor = new MultiThreadActionExecutor(Config.ThreadsCount))
                    using (var taskController = new TaskController(actionExecutor))
                        using (var host = ServiceFactory.CreateServiceExample(taskController))
                        {
                            host.Open();
                            Log.Information("Server started");
                            host.Faulted += Host_Faulted;
                            Console.ReadKey();
                        }

                Log.Information("Server stopped");
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 28
0
        public void EndTask_ThroughputMode(BenchmarkContext context)
        {
            //Arrange
            endTaskCounter = context.GetCounter(EndTaskCounterName);
            var projectManagerContext = new TestProjectManagerContext();
            var testController        = new PerTestTaskController();

            testController.Tasks().ForEach(x =>
            {
                projectManagerContext.Tasks.Add(x);
            });

            var task = new Task()
            {
                TaskId = 1
            };

            //Act
            var     controller = new TaskController(projectManagerContext);
            dynamic result     = controller.EndTask(task.TaskId);

            endTaskCounter.Increment();
        }
Exemplo n.º 29
0
        public void UpdateTask_ThroughputMode(BenchmarkContext context)
        {
            //Arrange
            updateTaskCounter = context.GetCounter(UpdateTaskCounterName);
            var projectManagerContext = new TestProjectManagerContext();
            var testController        = new PerTestTaskController();

            testController.Tasks().ForEach(x =>
            {
                projectManagerContext.Tasks.Add(x);
            });

            var task = new Task()
            {
                TaskId = 2, TaskName = "FS1", Priority = 5, StartDate = new DateTime(2018, 10, 1), EndDate = new DateTime(2018, 10, 2)
            };

            //Act
            var     controller = new TaskController(projectManagerContext);
            dynamic result     = controller.UpdateTask(task);

            updateTaskCounter.Increment();
        }
Exemplo n.º 30
0
        public void CreateTask_CreatesNewTaskAndReturnsOkResult()
        {
            var request = new CreateTaskRequest();

            var newTask = A.Fake <ITask>();

            var taskRepository = A.Fake <ITaskRepository>();

            A.CallTo(() => taskRepository.Create()).Returns(newTask);

            var mapper = A.Fake <IMapper>();

            var controller = new TaskController(
                taskRepository,
                mapper);

            var result = controller.CreateTask(request) as OkResult;

            Assert.IsNotNull(result);

            A.CallTo(() => mapper.Map(request, newTask)).MustHaveHappened();
            A.CallTo(() => taskRepository.SaveChanges()).MustHaveHappened();
        }
Exemplo n.º 31
0
        public void GetOutstandingTasks_ReturnsOutstandingTasks()
        {
            var tasks = Enumerable.Empty <ITask>();

            var taskViewModels = Enumerable.Empty <TaskViewModel>();

            var taskRepository = A.Fake <ITaskRepository>();

            A.CallTo(() => taskRepository.GetOutstanding()).Returns(tasks);

            var mapper = A.Fake <IMapper>();

            A.CallTo(() => mapper.Map <IEnumerable <ITask>, IEnumerable <TaskViewModel> >(tasks)).Returns(taskViewModels);

            var controller = new TaskController(
                taskRepository,
                mapper);

            var result = controller.GetOutstandingTasks() as OkNegotiatedContentResult <IEnumerable <TaskViewModel> >;

            Assert.IsNotNull(result);
            Assert.AreSame(taskViewModels, result.Content);
        }
Exemplo n.º 32
0
 public void SetUp()
 {
     repository = MockRepository.GenerateStub<Repository>();
     tlc = new TaskController(repository);
 }