Commit 46bd2d20 authored by Steve Smith's avatar Steve Smith

parent 500bff60
...@@ -50,6 +50,7 @@ namespace CleanArchitecture.Web.Api ...@@ -50,6 +50,7 @@ namespace CleanArchitecture.Web.Api
public IActionResult MarkComplete(int itemId) public IActionResult MarkComplete(int itemId)
{ {
var item = _todoRepository.GetById(itemId); var item = _todoRepository.GetById(itemId);
if (item == null) return NotFound();
item.MarkComplete(); item.MarkComplete();
_todoRepository.Update(item); _todoRepository.Update(item);
......
using CleanArchitecture.Core.Entities; using CleanArchitecture.Core.Entities;
using CleanArchitecture.Web;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xunit; using Xunit;
...@@ -22,7 +16,7 @@ namespace CleanArchitecture.Tests.Integration.Web ...@@ -22,7 +16,7 @@ namespace CleanArchitecture.Tests.Integration.Web
var response = await _client.GetAsync("/api/todoitems"); var response = await _client.GetAsync("/api/todoitems");
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var stringResponse = await response.Content.ReadAsStringAsync(); var stringResponse = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<IEnumerable<ToDoItem>>(stringResponse).ToList(); var result = JsonConvert.DeserializeObject<IEnumerable<ToDoItem>>(stringResponse);
Assert.Equal(2, result.Count()); Assert.Equal(2, result.Count());
Assert.Equal(1, result.Count(a => a.Title == "Test Item 1")); Assert.Equal(1, result.Count(a => a.Title == "Test Item 1"));
......
...@@ -33,9 +33,7 @@ namespace CleanArchitecture.Tests.Integration.Web ...@@ -33,9 +33,7 @@ namespace CleanArchitecture.Tests.Integration.Web
.UseEnvironment("Testing"); // ensure ConfigureTesting is called in Startup .UseEnvironment("Testing"); // ensure ConfigureTesting is called in Startup
var server = new TestServer(builder); var server = new TestServer(builder);
var client = server.CreateClient(); return server.CreateClient();
return client;
} }
protected virtual void InitializeServices(IServiceCollection services) protected virtual void InitializeServices(IServiceCollection services)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment