public void UpdateTask() { using (var fixture = new FixtureInit("http://localhost")) { //INIT var repository = new TasksRepository(fixture.Setup.Context); var task = new Task() { Number = 0, UserId = fixture.Setup.User.Id, Description = "My new task", Status = 0, ActualWork = 0 }; repository.Save(task); //ACT task.Description = "My new task (update)"; repository.Save(task); //POST var foundTask = repository.Tasks.WithId(task.Id); Assert.That(foundTask, Is.Not.Null); Assert.That(foundTask.Description, Is.EqualTo("My new task (update)")); } }
public void Tasks_SortedByPosition() { using (var fixture = new FixtureInit("http://localhost")) { // arrange var repository = new TasksRepository(fixture.Setup.Context); repository.Save(new Task { UserId = fixture.Setup.User.Id, Position = 3 }); repository.Save(new Task { UserId = fixture.Setup.User.Id, Position = 2 }); repository.Save(new Task { UserId = fixture.Setup.User.Id, Position = 1 }); // act var tasks = repository.Tasks.ToArray(); // assert Assert.That(tasks[0].Position, Is.EqualTo(1)); Assert.That(tasks[1].Position, Is.EqualTo(2)); Assert.That(tasks[2].Position, Is.EqualTo(3)); } }
public void TasksRepository_Save() { var expected = _repository.Save(new Task { Title = "Task One" }); Assert.AreNotEqual(Guid.Empty, expected.Id); _repository.Delete(expected.Id); }
private int AddTask(string fileName, string ymd) { var task = new Tasks(); task.FileName = fileName; task.Ymd = ymd; task.State = 1; return(tasksRepository.Save(task).Id); }
public void Initialize() { _server = TestServer.Create <StartUp>(); _repository = new TasksRepository(new RedisClient()); _taskOne = _repository.Save(new Task { Title = "TaskOne" }); _taskTwo = _repository.Save(new Task { Title = "TaskTwo" }); }
private void Add() { Console.Clear(); TaskData taskData = new TaskData(); taskData.Creator = AuthenticationService.LoggedUser.Id; Console.WriteLine("Add new Task:"); Console.Write("Title: "); taskData.Title = Console.ReadLine(); Console.Write("Description: "); taskData.Description = Console.ReadLine(); Console.Write("Time: "); taskData.Time = Convert.ToInt32(Console.ReadLine()); Console.Write("Responsible User Id: "); taskData.ResponsibleUser = Convert.ToInt32(Console.ReadLine()); Console.Write("Creation Date: "); taskData.CreationDate = Console.ReadLine(); Console.Write("Last Update Date: "); taskData.LastUpdateDate = Console.ReadLine(); Console.Write("State (Waiting or Completed): "); taskData.State = Console.ReadLine(); TasksRepository tasksRepository = new TasksRepository("tasks.txt"); tasksRepository.Save(taskData); Console.WriteLine("Task saved successfully."); Console.ReadKey(true); }
public void GetAllTasks() { using (var fixture = new FixtureInit("http://localhost")) { //INIT var repository = new TasksRepository(fixture.Setup.Context); var tasks = new[] { new Task() { UserId = fixture.Setup.User.Id, Description = "test1" }, new Task() { UserId = fixture.Setup.User.Id, Description = "test2" } }; foreach (var task in tasks) { repository.Save(task); } //ACT var foundTasks = repository.Tasks; //POST Assert.That(foundTasks, Is.Not.Null); Assert.That(foundTasks.Count(), Is.EqualTo(2)); } }
public void AddTask() { Entity.Task task = CollectTaskInformation(); TasksRepository taskRepo = new TasksRepository("tasks.txt"); taskRepo.Save(task); Console.WriteLine("Task saved successfully!!"); Console.ReadKey(true); }
public ActionResult Create(Task task) { if (ModelState.IsValid) { repository.Save(task); } return(RedirectToAction("Index", "Task")); }
public void Can_Create_Task_And_Update_From_Repository() { var repository = new TasksRepository( new ProjectsRepository(ConfigurationManager.ConnectionStrings["TaskTracker"].ConnectionString), new TagsRepository(ConfigurationManager.ConnectionStrings["TaskTracker"].ConnectionString)); var testValue = "TestValue"; var updatedValue = "UpdatedValue"; var task = new Task { Name = "TestValue" }; var newTask = repository.Save(task); newTask.Name = updatedValue; var updatedTask = repository.Save(newTask); Assert.That(updatedTask.Id, Is.EqualTo(newTask.Id)); Assert.That(updatedTask.Name, Is.EqualTo(updatedValue)); }
public ActionResult ChangeStatus(Task task) { if (AuthenticationManager.LoggedUser == null) { return(RedirectToAction("Login", "Home")); } task.LastModified = DateTime.Now; TasksRepository tasksRepository = new TasksRepository(new TaskManagerDb()); tasksRepository.Save(task); return(RedirectToAction("EditComment", "CommentsManager", new { taskId = task.Id })); }
public ActionResult EditTask(Task task) { if (AuthenticationManager.LoggedUser == null) { return(RedirectToAction("Login", "Home")); } task.LastModified = DateTime.Now; TasksRepository tasksRepository = new TasksRepository(new TaskManagerDb()); tasksRepository.Save(task); return(RedirectToAction("Index", "TasksManager")); }
public void Save_CreatedDateInitialized_TaskSavedWithCreatedDate() { using (var fixture = new FixtureInit("http://localhost")) { // arrange var repository = new TasksRepository(fixture.Setup.Context); // act var task = new Task { UserId = fixture.Setup.User.Id, Description = "created date test" }; repository.Save(task); // assert var found = repository.Tasks.Where(t => t.Description == "created date test").SingleOrDefault(); Assert.That(found.CreatedDate, Is.Not.Null); } }
public void ChangeStatus(int taskId) { TasksRepository tasksRepository = new TasksRepository("tasks.txt"); Task task = tasksRepository.GetById(taskId); task.LastModified = DateTime.Now.Date; Console.Write("New task status: "); var isDone = Console.ReadLine(); if (!string.IsNullOrEmpty(isDone)) { task.IsDone = bool.Parse(isDone); } tasksRepository.Save(task); Console.WriteLine("Task saved successfully."); Console.ReadKey(true); }
public void Tasks_DoneFlag_DefaultIsFalse() { using (var fixture = new FixtureInit("http://localhost")) { // arrange var repository = new TasksRepository(fixture.Setup.Context); var task = new Task { Description = "Test task", UserId = fixture.Setup.User.Id }; // act repository.Save(task); // assert var savedTask = repository.Tasks.Where(t => t.Id == task.Id).SingleOrDefault(); Assert.That(savedTask.Done, Is.False); } }
public void Can_Create_Task_And_Remove_From_Repository() { var repository = new TasksRepository( new ProjectsRepository(ConfigurationManager.ConnectionStrings["TaskTracker"].ConnectionString), new TagsRepository(ConfigurationManager.ConnectionStrings["TaskTracker"].ConnectionString)); var testValue = "TestValue"; var task = new Task { Name = "TestValue" }; var newTask = repository.Save(task); Assert.That(newTask.Id, Is.Not.EqualTo(0)); Assert.That(newTask.Name, Is.EqualTo(testValue)); repository.Remove(task.Id); Assert.That(repository.Find(newTask.Id), Is.Null); }
public void EditTask() { Console.Clear(); Console.Write("Enter task id to edit: "); int id = 0; bool IsInt = int.TryParse(Console.ReadLine(), out id); while (IsInt == false) { Console.WriteLine("Only numbers can be entered for ID's!!"); Console.Write("Enter task id to edit: "); IsInt = int.TryParse(Console.ReadLine(), out id); } TasksRepository taskRepo = new TasksRepository("tasks.txt"); List <Task> tasks = taskRepo.GetAll(Task => Task.Id == id); if (tasks.Count == 0) { Console.WriteLine($"There is no task with id {id}!!!"); Console.ReadKey(true); return; } Task task = tasks[0]; Console.WriteLine($"Old title: {task.Title}"); Console.Write("New title: "); task.Title = Console.ReadLine(); Console.WriteLine($"Old description: {task.Description}"); Console.Write("New description: "); task.Description = Console.ReadLine(); Console.WriteLine($"Old evaluated time to complete: {task.EvaluatedTimeToComplete} hours"); Console.Write("New evaluated time to complete: "); int tempEvalTime = 0; bool isInt = int.TryParse(Console.ReadLine(), out tempEvalTime); while (isInt == false) { Console.WriteLine("Only integers can be entered for the hours!!"); Console.Write("New evaluated time to complete: "); isInt = int.TryParse(Console.ReadLine(), out tempEvalTime); } task.EvaluatedTimeToComplete = tempEvalTime; Console.WriteLine($"Old assignee id: {task.AssigneeId}"); Console.Write("New assignee id: "); int tempAssigneeId = 0; bool isInt1 = int.TryParse(Console.ReadLine(), out tempAssigneeId); while (isInt1 == false) { Console.WriteLine("Only integers can be entered for the ID's!!"); Console.Write("New assignee id: "); isInt1 = int.TryParse(Console.ReadLine(), out tempAssigneeId); } task.AssigneeId = tempAssigneeId; task.LastEditDate = DateTime.Now; Console.WriteLine($"Old task state: {task.TaskState}"); Console.WriteLine("Enter one of the options below: \"A\" - Awaiting Execution; \"I\" - In Execution; \"F\" - Finished"); Console.Write("New task State: "); string inputTaskState = Console.ReadLine(); switch (inputTaskState.ToUpper()) { case "A": task.TaskState = TaskState.AwaitingExecution; break; case "I": task.TaskState = TaskState.InExecution; break; case "F": task.TaskState = TaskState.Finished; break; default: Console.WriteLine("Invalid input!! Use one of the available options above!!"); Console.ReadKey(true); break; } taskRepo.Save(task); Console.WriteLine("Task edited successfully!!"); Console.ReadKey(true); }
public void ChangeTaskState() { Console.Clear(); Console.Write("Enter id of the task which State you would like to change: "); int inputTaskId = 0; bool isInt = int.TryParse(Console.ReadLine(), out inputTaskId); while (isInt == false) { Console.WriteLine("You can only enter integers for task ID's!!"); Console.Write("Enter id of the task which state you would like to change: "); isInt = int.TryParse(Console.ReadLine(), out inputTaskId); } TasksRepository taskRepo = new TasksRepository("tasks.txt"); List <Task> tasks = taskRepo.GetAll(Task => Task.Id == inputTaskId); if (tasks.Count == 0) { Console.WriteLine($"There are no tasks with id {inputTaskId}"); Console.ReadKey(true); } Task task = tasks[0]; if (!(task.AssigneeId == AuthenticationService.LoggedUser.Id || task.CreatorId == AuthenticationService.LoggedUser.Id)) { Console.WriteLine("You can only modify task status of tasks which you created or which you are assigned to!"); Console.ReadKey(true); return; } else { Console.WriteLine($"Current task State: {task.TaskState}"); SelectTaskStatus: Console.WriteLine("Enter one of the options below: \"A\" - Awaiting Execution; \"I\" - In Execution; \"F\" - Finished"); Console.Write("New task State: "); string inputTaskState = Console.ReadLine(); switch (inputTaskState.ToUpper()) { case "A": task.TaskState = TaskState.AwaitingExecution; break; case "I": task.TaskState = TaskState.InExecution; break; case "F": task.TaskState = TaskState.Finished; break; default: Console.WriteLine("Invalid input!! Use one of the available options above!!"); Console.ReadKey(true); goto SelectTaskStatus; } task.LastEditDate = DateTime.Now; taskRepo.Save(task); Console.WriteLine("Task State changed successfully!"); Console.ReadKey(true); } }