private OlTaskStatus MapStatus2To1(TodoStatus value) { switch (value) { case TodoStatus.Cancelled: return(OlTaskStatus.olTaskDeferred); case TodoStatus.Completed: return(OlTaskStatus.olTaskComplete); case TodoStatus.InProcess: return(OlTaskStatus.olTaskInProgress); case TodoStatus.NeedsAction: return(OlTaskStatus.olTaskNotStarted); } throw new NotImplementedException(string.Format("Mapping for value '{0}' not implemented.", value)); }
public ActionResult <TodoStatus> Get(int id) { var model = new TodoStatus() { TodoStatusId = id }; var serviceResult = _todoStatusService.Fetch(model); if (serviceResult.Status == BrashActionStatus.ERROR) { return(BadRequest(serviceResult.Message)); } if (serviceResult.Status == BrashActionStatus.NOT_FOUND) { return(NotFound(serviceResult.Message)); } return(serviceResult.Model); }
public static TodoSpec ByStatus(TodoStatus status) { return(Spec.For <Todo>(t => t.Status == status)); }
public Todo(string t, string b, TodoStatus s) { title = t; body = b; status = s; }
public void MarkAs(TodoStatus status, DateTime when) { Status = status; LastChanged = when; }
public Todo(string description, TodoStatus status = TodoStatus.NotStarted) : this() { Description = description; Status = status; }
public TodoModel(string content, TodoStatus status) { this.content = content; id = System.Guid.NewGuid().ToString(); this.status = status; }
public int setCompleted() { Done = TodoStatus.Completed; return((int)Done); }
public void GivenCorrectTodo_Create_ReturnCorrectTodo(string id, string title, string description, TodoStatus status, string createdOn, string dueDate) { var todo = new TodoModel { Id = Guid.Parse(id), Title = title, Description = description, Status = status, CreatedOn = DateTime.Parse(createdOn), DueDate = DateTime.Parse(dueDate) }; var repositoryTodo = new TodoModel(); MockRepository.Setup(a => a.Insert(todo)).Returns(repositoryTodo); var service = new Service.TodoService(MockRepository.Object); var serviceTodo = service.Create(todo); Assert.Equal(serviceTodo, repositoryTodo); }
public void SetStatus(TodoStatus status) => Status = status;
/// <summary> /// Set status. /// </summary> /// <param name="status">Status.</param> public void SetStatus(TodoStatus status) { _status = status; }
public void markIncomplete() { status = TodoStatus.INCOMPLETE; completedAt = null; }
public void markComplete() { status = TodoStatus.COMPLETE; completedAt = DateTime.Now; }
public Todo(Guid id, string title, TodoStatus status) { Id = id; Title = title; Status = status; }
[InlineData("a00e0400-3000-0000-3000-000050000001", "Football", "", TodoStatus.InProgress, "2020-05-15T14:29:15.1823029Z", "2020-05-19T21:00:00.0000000Z")] // without Description public void GivenValidEntity_Update_UpdateEntity(string id, string title, string description, TodoStatus status, string createdOn, string dueDate) { //arrange var todo = new TodoModel() { Id = Guid.Parse(id), Title = title, Description = description, Status = status, CreatedOn = DateTime.Parse(createdOn), DueDate = DateTime.Parse(dueDate) }; var todoAsElement = EntityToElement(todo); Container.Add(todoAsElement); var repo = new Xml.TodoRepository(MockXmlContext.Object); //act todo.Title = "Concert"; todo.Description = "Go to Metallica concert"; repo.Update(todo); //assert var all = Container.Elements(); var element = all.First(a => a.Attribute("Id").Value == todo.Id.ToString()); Assert.Equal(todo.Id.ToString(), element.Attribute("Id").Value); Assert.Equal(todo.Title, element.Element("Title").Value); Assert.Equal(todo.Description, element.Element("Description").Value); Assert.Equal(todo.Status.ToString(), element.Element("Status").Value); Assert.Equal(todo.CreatedOn.ToUniversalTime().ToString("o", CultureInfo.InvariantCulture), element.Element("CreatedOn").Value); Assert.Equal(todo.DueDate.ToUniversalTime().ToString("o", CultureInfo.InvariantCulture), element.Element("DueDate").Value); }
public void GivenExistingTodo_Update_UpdateRetursTrue(string id, string title, string description, TodoStatus status, string createdOn, string dueDate) { var todo = new TodoModel { Id = Guid.Parse(id), Title = title, Description = description, Status = status, CreatedOn = DateTime.Parse(createdOn), DueDate = DateTime.Parse(dueDate) }; MockRepository.Setup(a => a.Update(todo)); todo.Title = "Concert"; todo.Description = "Go to Metallica concert"; var service = new Service.TodoService(MockRepository.Object); var isUpdated = service.Update(todo); Assert.True(isUpdated); }
[InlineData("600e0400-3c00-0000-3000-020050000001", "Football", "", TodoStatus.InProgress, "2020-05-15T14:29:15.1823029Z", "2020-05-19T21:00:00.0000000Z")] // without Description public void GivenNotExistedId_Update_DoesNothing(string id, string title, string description, TodoStatus status, string createdOn, string dueDate) { //arrange var todo = new TodoModel() { Id = Guid.Parse(id), Title = title, Description = description, Status = status, CreatedOn = DateTime.Parse(createdOn), DueDate = DateTime.Parse(dueDate) }; var repo = new Xml.TodoRepository(MockXmlContext.Object); //act todo.Title = "Concert"; todo.Description = "Go to Metallica concert"; repo.Update(todo); //assert var all = Container.Elements(); var element = all.FirstOrDefault(a => a.Attribute("Id").Value == todo.Id.ToString()); Assert.Null(element); }
public void GivenExistingTodo_Delete_CallRepositorySave(string id, string title, string description, TodoStatus status, string createdOn, string dueDate) { var todo = new TodoModel { Id = Guid.Parse(id), Title = title, Description = description, Status = status, CreatedOn = DateTime.Parse(createdOn), DueDate = DateTime.Parse(dueDate) }; MockRepository.Setup(a => a.GetById(todo.Id)).Returns(todo); MockRepository.Setup(a => a.Delete(todo.Id)); var service = new Service.TodoService(MockRepository.Object); service.Delete(todo.Id); MockRepository.Verify(a => a.Save(), Times.Once); }
[InlineData("Football", "", TodoStatus.InProgress, "2020-05-15T14:29:15.1823029Z", "2020-05-19T21:00:00.0000000Z")] // without Description public void GivenValidTodo_Insert_ReturnsNewTodo(string title, string description, TodoStatus status, string createdOn, string dueDate) { //arrange var repo = new Xml.TodoRepository(MockXmlContext.Object); var entity = new TodoModel() { Title = title, Description = description, Status = status, CreatedOn = DateTime.Parse(createdOn, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind), DueDate = DateTime.Parse(dueDate, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind) }; //act var todo = repo.Insert(entity); //assert Assert.NotNull(todo); Assert.NotEmpty(todo.Id.ToString()); Assert.NotEqual("00000000-0000-0000-0000-000000000000", todo.Id.ToString()); Assert.Equal(todo.Title, entity.Title); Assert.Equal(todo.Description, entity.Description); Assert.Equal(todo.Status, entity.Status); Assert.Equal(todo.CreatedOn, entity.CreatedOn); Assert.Equal(todo.DueDate, entity.DueDate); }
public TodoModel(string content, string id, TodoStatus status) { this.content = content; this.id = id; this.status = status; }
public Todo(string title, string description, DateTime deadline, List <string> tags = null, TodoStatus status = TodoStatus.Active) { Title = title; Description = description; Deadline = deadline; Tags = tags ?? new List <string>(); Status = status; }
public IActionResult GetTodoList(TodoStatus state) { return(PartialView("TodoListPartial", state)); }
public void CreateUpdateDeleteFetch() { // file system var path = "/shop/randomsilo/modern-web/backends/TodoList"; var project = "TodoList"; var outputPath = $"{path}/{project}.Infrastructure.Test/TestOutput/"; var databaseFile = GetDatabase(outputPath, MethodBase.GetCurrentMethod()); // logger ILogger logger = GetLogger($"{outputPath}/{MethodBase.GetCurrentMethod().ReflectedType.Name}_{MethodBase.GetCurrentMethod().Name}.log"); // database setup // - context IDatabaseContext databaseContext = new DatabaseContext( $"Data Source={databaseFile}" , "TestDb" , "TestSchema" , $"{path}/sql/sqlite/ALL.sql" ); Assert.NotNull(databaseContext); // - manager IManageDatabase databaseManager = new DatabaseManager(databaseContext); Assert.NotNull(databaseManager); // - create tables databaseManager.CreateDatabase(); // - repository var todoStatusRepository = new TodoStatusRepository(databaseManager, new TodoStatusRepositorySql(), logger); Assert.NotNull(todoStatusRepository); // faker BrashActionResult <TodoStatus> result = null; var todoStatusFaker = new TodoStatusFaker(databaseManager, logger); Assert.NotNull(todoStatusFaker); // create var todoStatusCreateModel = todoStatusFaker.GetOne(); result = todoStatusRepository.Create(todoStatusCreateModel); Assert.True(result.Status == BrashActionStatus.SUCCESS, result.Message); Assert.True(result.Model.TodoStatusId > 0); // use model with id todoStatusCreateModel = result.Model; // update var todoStatusUpdateModel = todoStatusFaker.GetOne(); todoStatusUpdateModel.TodoStatusId = todoStatusCreateModel.TodoStatusId; result = todoStatusRepository.Update(todoStatusUpdateModel); Assert.True(result.Status == BrashActionStatus.SUCCESS, result.Message); // delete result = todoStatusRepository.Delete(todoStatusCreateModel); Assert.True(result.Status == BrashActionStatus.SUCCESS, result.Message); // fetch // - make fakes var fakes = todoStatusFaker.GetMany(10); // - add fakes to database List <int?> ids = new List <int?>(); foreach (var f in fakes) { result = todoStatusRepository.Create(f); Assert.True(result.Status == BrashActionStatus.SUCCESS, result.Message); Assert.True(result.Model.TodoStatusId >= 0); ids.Add(result.Model.TodoStatusId); } // - get fakes from database foreach (var id in ids) { var model = new TodoStatus() { TodoStatusId = id }; result = todoStatusRepository.Fetch(model); Assert.True(result.Status == BrashActionStatus.SUCCESS, result.Message); Assert.True(result.Model.TodoStatusId >= 0); } }
public Todo(string description, DateTime?due, TodoStatus status = TodoStatus.NotStarted) : this(description, status) { Due = due; }
public BrashActionResult <TodoStatus> Fetch(TodoStatus model) { return(Repository.Fetch(model)); }
public void MarkAs(TodoStatus status) { MarkAs(status, DateTime.Today); }
public BrashActionResult <TodoStatus> Delete(TodoStatus model) { return(Repository.Delete(model)); }
public StatusValue(TodoStatus status) { Status = (Status)(int)status; }
internal void ChangeStatus(TodoStatus status) { Status = status; }