private void Seed() { _todoService.Add(new Todo() { Text = "abc" }); _todoService.Add(new Todo() { Text = "abcA" }); }
public void WhenChangeStatus_GivenTheIdIsNotFound_ThenFalseIsReturned() { // Arrange var invalidId = 333; // Act _todoService.Add(new DataModel.TodoItem { Id = 1, Description = "New" }); var result = _todoService.ChangeStatus(invalidId, true); // Assert Assert.IsFalse(result, "false must be returned"); }
public async Task WhenATodoItemIsAdded_ThenItemsCountIsIncreasedByOne() { // Arrange // Act var todoListBeforeAdding = await _todoService.GetAllTodoItemsAsync(); _todoService.Add(new DataModel.TodoItem { Description = "New" }); var todoListAfterAdding = await _todoService.GetAllTodoItemsAsync(); // Assert Assert.IsTrue(todoListAfterAdding.Length == todoListBeforeAdding.Length + 1, "A new item must be added"); }
public void Add_New_Todo() { var teste = new TodoService(mockTodoRepository.Object); var retorno = teste.Add(newTodo); Assert.IsTrue(retorno); }
public async Task <IActionResult> CreateTodo( [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] Todo req, ILogger log) { var result = await _todoService.Add(req); return(new OkObjectResult(result)); }
public void Add_NewItem_ReturnsResultObject() { // Arrange A.CallTo(() => _repository.AddItem(A <TodoItem> ._)).Returns(true); // Act var result = _todoService.Add(_todoItem.Title, _todoItem.Description); // Assert result.IsSuccess.Should().BeTrue(); result.NewItem.Should().NotBeNull(); result.NewItem.Title.Should().Be(_todoItem.Title); result.NewItem.Description.Should().Be(_todoItem.Description); result.NewItem.CreatedTimeStamp.Should().BeCloseTo(DateTime.UtcNow, TimeSpan.FromMilliseconds(100)); result.NewItem.Id.Should().NotBeEmpty(); result.NewItem.IsCompleted.Should().BeFalse(); }
public void WhenATodoItemIsAdded_GivenItemIsNull_ThenReturnFalse() { // Arrange // Act var result = _todoService.Add(null); // Assert Assert.IsFalse(result, "Add must return false"); }
public ActionResult Create(Todo model) { model.ID = Guid.NewGuid(); model.RegisterId = ((User)Session["login"]).ID; model.IsComplete = false; db.Add(model); return(RedirectToAction("Index")); }
public void ReturnsListOfItems() { _service.Add(new TodoItem() { Name = "Task A" }); _service.Add(new TodoItem() { Name = "Task B" }); var todoItems = _service.GetItems(); Assert.Equal(3, todoItems.Count); Assert.Equal("Item1", todoItems.ElementAt(0).Name); Assert.Equal("Task A", todoItems.ElementAt(1).Name); Assert.Equal("Task B", todoItems.ElementAt(2).Name); }
public void SavesTodoItemByString() { TodoItem todoItem; using (var context = new TodoContext(_dbContextOptions)) { var service = new TodoService(context); todoItem = service.Add("item1"); } Assert.Equal("item1", todoItem.Name); }
public void ReturnsItemIfPresent() { var todoItem = _service.Add(new TodoItem() { Name = "item0" }); var result = _service.GetById(todoItem.Id); Assert.NotNull(result); Assert.Equal("item0", result.Name); }
public void RemovesItem() { var todoItem = _service.Add(new TodoItem() { Name = "item0" }); _service.Delete(todoItem.Id); var result = _service.GetById(todoItem.Id); Assert.Null(result); }
public async Task <IHttpActionResult> Post(TodoItemModel item) { item.Created = DateTime.Now; BllTodoItem result = await service.Add(item.ToBll()); if (result == null) { return(BadRequest(ModelState)); } return(CreatedAtRoute("DefaultApi", new { id = item.Id }, result.ToViewModel())); }
public void SavesTodoItemObject() { TodoItem todoItem; using (var context = new TodoContext(_dbContextOptions)) { var service = new TodoService(context); todoItem = service.Add(new TodoItem() { Name = "item2" }); } Assert.Equal("item2", todoItem.Name); }
public void SetsNewValue() { var todoItem = _service.Add(new TodoItem() { Name = "item0" }); todoItem.Name = "item1"; var result = _service.Update(todoItem); Assert.Equal(todoItem.Id, result.Id); Assert.Equal("item1", result.Name); }
public ApiResponse Post([FromBody] Todo value) { var response = new ApiResponse(); try { response.Data = _todoService.Add(value); } catch (Exception ex) { response.HasError = true; response.ErrorMessage = ex.Message; } response.ResponseDate = DateTime.Now; return(response); }
public async Task <IActionResult> AddTodo(TodoAddViewModel todo) //[FromBody] { if (todo != null) { // NOTE: Used AutoMapper for Object-to-Object mapping instead of old school viewModel var mappedViewModel = new Todo { WorkTodo = todo.WorkTodo, IsCompleted = todo.IsCompleted }; //var mappedViewModel = _mapper.Map<Todo>(todo); int result = await _todoService.Add(mappedViewModel).ConfigureAwait(false); return(Ok(result)); } return(BadRequest()); }
public IActionResult Add([FromBody] Todo todo) { return(Json(TodoService.Add(todo.text))); }
public bool Add(string value) { return(todoService.Add(value)); }
public async Task NewTodo() { TodoService.Url = Url; TodoService.Client = Http.CreateClient(); Response = await TodoService.Add(Request); }
public IHttpActionResult Put(string description) { var target = _service.Add(description); return(Ok(target)); }