Beispiel #1
0
        public void TodoTest_CompleteTodo_ShouldMarkTodoAsArchived(string description)
        {
            var todo = Todo.Create(description);

            todo.Archive();
            todo.IsArchived.Should().BeTrue();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var db   = new TodoDb();
            var data = Todo.Create().ToList();

            //db.Todos.AddRange(data);
            //foreach(var td in data)
            //{
            //    db.Todos.Add(td);
            //}


            //db.SaveChanges();


            var todos = from t in db.Todos
                        orderby t.Completed
                        select t;


            foreach (var t in todos)
            {
                Console.WriteLine(t.Task + " | Completed: " + t.Completed);
            }
        }
Beispiel #3
0
        public void TodoTest_UnCompleteTodo_ShouldMarkTodoAsUnCompleted(string description)
        {
            var todo = Todo.Create(description);

            todo.UnComplete();
            todo.IsCompleted.Should().BeFalse();
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            var data = Todo.Create()
                       .Select(t => t.Task)
                       .ToArray();


            File.WriteAllLines(BaseFile, data);
            //or

            //using (var fs = new FileStream(BaseFile, FileMode.Create))
            //using (var writer = new StreamWriter(fs))
            //{
            //    foreach (var line in data)
            //    {
            //        writer.WriteLine(line);
            //    }
            //}


            using (var fs = new FileStream(BaseFile, FileMode.Open))
                using (var writer = new StreamReader(fs))
                {
                    while (!writer.EndOfStream)
                    {
                        Console.WriteLine(writer.ReadLine());
                    }
                }
        }
Beispiel #5
0
 public JsonResult Create(Todo todo)
 {
     if (ModelState.IsValid)
     {
         todo.Create();
     }
     return Json(todo);
 }
Beispiel #6
0
        public void CreateTest()
        {
            //arrange
            //var expected = true;

            //act
            var actual = Todo.Create("Flank");

            //assert
            Assert.True(actual);
        }
Beispiel #7
0
        public IActionResult Create([FromBody] TodoInputModel item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            // replace with command pattern or builder pattern or mediatR
            var newItem = Todo.Create(
                item.Description);

            _todoService.Store(newItem);
            return(Ok());
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            var todos   = Todo.Create();
            var payload = JsonConvert.SerializeObject(todos);

            File.WriteAllText(basePath, payload);


            var content   = File.ReadAllText(basePath);
            var readTodos = JsonConvert.DeserializeObject <List <Todo> >(content);

            foreach (var todo in readTodos)
            {
                Console.WriteLine($"{todo.Task} - {(todo.Completed ? "yup": "nope")}");
            }
        }
Beispiel #9
0
        public void TodoTest_CreateTodo_ShouldReturnTodoUnArchived(string description)
        {
            var todo = Todo.Create(description);

            todo.IsArchived.Should().BeFalse();
        }
Beispiel #10
0
        public void TodoTest_CreateTodo_ShouldReturnTodo(string description)
        {
            var todo = Todo.Create(description);

            todo.Description.Should().Be(description);
        }
 public void Post([FromBody] TodoAddRequest request)
 {
     Todo.Create(request.Input);
 }
Beispiel #12
0
 public IActionResult Create(string task)
 {
     Todo.Create(task);
     return(RedirectToAction("Index"));
 }