public void Complete() { var projectId = 3; var storyId = 4; var id = 5; var initials = true; var description = "Doin work"; var task = new Task { Description = description, Id = id, StoryId = storyId, IsCompleted = false }; var storyService = new Mock<IStoryProvider>(); storyService.Setup(e => e.GetTask(projectId, storyId, id)).Returns(task); storyService.Setup(e => e.UpdateTask(task, projectId)); var controller = new TaskController(storyService.Object); var result = controller.Complete(id, storyId, projectId, true, 1); var viewResult = result as PartialViewResult; Assert.NotNull(viewResult); Assert.AreEqual("TaskDetails", viewResult.ViewName); Assert.IsInstanceOf<TaskViewModel>(viewResult.Model); var modelTask = viewResult.Model as TaskViewModel; Assert.AreEqual(projectId, modelTask.ProjectId); Assert.AreEqual(storyId, modelTask.StoryId); Assert.AreEqual(id, modelTask.Id); Assert.IsTrue(modelTask.Complete); storyService.Verify(); }
public ActionResult AddTask(long projectId, long storyId, string description, string initials, IterationType iterationType) { var task = new Task { Description = description, StoryId = storyId }; task.Description = AddInitialsToDescription(task, initials,projectId, iterationType); service.AddNewTask(task, projectId); return GetStory(storyId, projectId, iterationType); }
public void CanAddNewTask() { var task = new Task(); var taskRepo = new Mock<ITaskRepository>(MockBehavior.Strict); taskRepo.Setup(repo => repo.Save(task)).Returns(new DatabaseOperationResponse(true)); new CharcoalStoryProvider(Mock.Of<IStoryRepository>(),taskRepo.Object) .AddNewTask(task, projectId); taskRepo.Verify(); }
public void CannotUpdateInexistantTask() { var task = new Task(); task.Description = "Im a task"; task.Assignees = "Dude1, Dude2"; task.IsCompleted = true; task.StoryId = m_database.Stories.All().ToList<dynamic>()[0].Id; DatabaseOperationResponse response = m_repository.Update(task); Assert.IsFalse(response.HasSucceeded); }
public void GetOwners() { var task = new Task { Description = "this is a task with two owners (OO/DD)" }; var taskViewModel = new TaskViewModel(task,1, IterationType.Undefined); var owners = taskViewModel.GetOwners(); Assert.AreEqual(2, owners.Count); Assert.AreEqual("OO", owners[0]); Assert.AreEqual("DD", owners[1]); task = new Task { Description = "this is a task with one owner (OO)" }; taskViewModel = new TaskViewModel(task,1, IterationType.Undefined); var singleOwner = taskViewModel.GetOwners(); Assert.AreEqual(1, singleOwner.Count); Assert.AreEqual("OO", singleOwner.First()); }
public void CanDeleteTask() { var task = new Task(); task.Description = "Im a task"; task.Assignees = "Dude1, Dude2"; task.IsCompleted = true; task.StoryId = m_database.Stories.All().ToList<dynamic>()[0].Id; DatabaseOperationResponse response = m_repository.Save(task); Assert.IsTrue(response.HasSucceeded); Task retrievedTask = m_database.Tasks.All().ToList<dynamic>()[0]; response = m_repository.Delete(retrievedTask.Id); Assert.IsTrue(response.HasSucceeded); var tasks = m_database.Tasks.All().ToList<Task>(); Assert.AreEqual(0, tasks.Count); }
public void CanFindById() { var task = new Task(); task.Description = "Im a task"; task.Assignees = "Dude1, Dude2"; task.IsCompleted = true; task.StoryId = m_database.Stories.All().ToList<dynamic>()[0].Id; DatabaseOperationResponse response = m_repository.Save(task); Assert.IsTrue(response.HasSucceeded, response.Description); Task retrievedTask = m_database.Tasks.All().ToList<dynamic>()[0]; Task foundTask = m_repository.Find(retrievedTask.Id); Verifytask(retrievedTask, foundTask); Assert.NotNull(foundTask.Story); Assert.NotNull(foundTask.Story.Id); Assert.AreEqual(task.StoryId, foundTask.Story.Id); }
public void SignUp_Already_Has_Initials() { var projectId = 3; var storyId = 4; var id = 5; var initials = "NN/GZ"; var description = "Doin work (AA/FF)"; var task = new Task { Description = description, Id = id, StoryId = storyId,}; var storyService = new Mock<IStoryProvider>(); storyService.Setup(e=>e.GetTask(projectId, storyId, id)).Returns(task); storyService.Setup(e=>e.UpdateTask(task,projectId)); var controller = new TaskController(storyService.Object); var result = controller.SignUp(initials, new[] { string.Format("{0}-{1}-{2}-{3}", projectId, storyId, id,2) }); var redirectResult = result as RedirectToRouteResult; Assert.NotNull(redirectResult); Assert.True(task.Description.EndsWith("(NN/GZ)")); Assert.False(task.Description.Contains("(AA/FF)")); storyService.Verify(); }
public void Complete_Doesnt_Save_Task_If_No_Change() { var projectId = 3; var storyId = 4; var id = 5; var completed = true; var description = "Doin work"; var task = new Task {Description = description, Id = id, StoryId = storyId}; var storyService = new Mock<IStoryProvider>(); storyService.Setup(e => e.GetTask(projectId, storyId, id)).Returns(task); var controller = new TaskController(storyService.Object); var result = controller.Complete(id, storyId, projectId, completed,2); var viewResult = result as PartialViewResult; Assert.NotNull(viewResult); Assert.AreEqual("TaskDetails", viewResult.ViewName); Assert.IsInstanceOf<TaskViewModel>(viewResult.Model); Assert.AreEqual(task, (viewResult.Model as TaskViewModel).Task); storyService.Verify(); }
public void CanFindAll() { var story = new Story(); story.Title = "My New story"; story.Description = "loooooooo"; story.Status = StoryStatus.Started; story.CreatedBy = m_database.Users.All().ToList<dynamic>()[0].Id; story.ProjectId = m_database.Projects.All().ToList<dynamic>()[0].Id; DatabaseOperationResponse response = m_repository.Save(story); Assert.IsTrue(response.HasSucceeded); var repository = new TaskRepository(DatabaseHelper.GetConnectionString()); var task = new Task(); task.Description = "Im a task"; task.Assignees = "Dude1, Dude2"; task.IsCompleted = true; task.StoryId = m_database.Stories.All().ToList<dynamic>()[0].Id; response = repository.Save(task); Assert.IsTrue(response.HasSucceeded, response.Description); var task2 = new Task(); task2.Description = "Yes I am a taks"; task2.Assignees = "Dude1, Dude2"; task2.IsCompleted = true; task2.StoryId = m_database.Stories.All().ToList<dynamic>()[0].Id; response = repository.Save(task2); Assert.IsTrue(response.HasSucceeded, response.Description); var stories = m_repository.FindAll(); Assert.AreEqual(1, stories.Count); Assert.AreEqual(2, stories[0].Tasks.Count); Assert.NotNull(stories[0].Project); Assert.AreEqual(story.ProjectId, stories[0].Project.Id); }
public void CanUpdateTaskk() { var task = new Task(); var taskRepo = new Mock<ITaskRepository>(MockBehavior.Strict); taskRepo.Setup(repo => repo.Update(task)).Returns(new DatabaseOperationResponse(true)); Assert.IsTrue(new CharcoalStoryProvider(Mock.Of<IStoryRepository>(), taskRepo.Object) .UpdateTask(task, projectId).HasSucceeded); taskRepo.Verify(); }
public Task AddNewTask(Task task, long projectId) { var response = m_taskRepository.Save(task); return response.HasSucceeded ? response.Object : null; }
public OperationResponse UpdateTask(Task task, long projectId) { var res = m_taskRepository.Update(task); return new OperationResponse(res.HasSucceeded, res.Description); }
public TaskViewModel(Task task, long projectId, IterationType iterationType) { m_projectId = projectId; Task = task; IterationType = iterationType; }
private string AddInitialsToDescription(Task task, string initials, long projectId, int iterationType) { return new TaskViewModel(task, projectId, (IterationType)iterationType).GetDescriptionWithoutOwners() + (string.IsNullOrEmpty(initials) ? "" : (" (" + initials.ToUpper() + ")")); }