public async Task Can_Get_TodoItems() { // Arrange const int expectedEntitiesPerPage = 5; var person = new Person(); var todoItem = _todoItemFaker.Generate(); todoItem.Owner = person; _context.TodoItems.Add(todoItem); _context.SaveChanges(); var httpMethod = new HttpMethod("GET"); var route = "/api/v1/todo-items"; var description = new RequestProperties("Get TodoItems"); // Act var response = await _fixture.MakeRequest <TodoItem>(description, httpMethod, route); var body = await response.Content.ReadAsStringAsync(); var deserializedBody = JsonApiDeSerializer.DeserializeList <TodoItem>(body, _jsonApiContext); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotEmpty(deserializedBody); Assert.True(deserializedBody.Count <= expectedEntitiesPerPage); }
public async Task Can_Get_Users() { // Arrange var user = _userFaker.Generate(); _context.Users.Add(user); _context.SaveChanges(); var httpMethod = new HttpMethod("GET"); var route = "/api/Users"; // Act var response = await _fixture.MakeRequest("Get Users", httpMethod, route); var body = await response.Content.ReadAsStringAsync(); var deserializedBody = JsonConvert.DeserializeObject <List <User> >(body); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotEmpty(deserializedBody); }