Skip to content

Instantly share code, notes, and snippets.

@gnschenker
Created December 30, 2019 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnschenker/8606db6fa134be6ad00b6a0b186af462 to your computer and use it in GitHub Desktop.
Save gnschenker/8606db6fa134be6ad00b6a0b186af462 to your computer and use it in GitHub Desktop.
Integration test for API
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using api;
using Xunit;
namespace tests
{
public class UnitTest1
{
[Fact]
public async Task should_read_glossary_items()
{
var factory = new WebApiTesterFactory();
var client = factory.CreateClient();
client.BaseAddress = new Uri("https://localhost:5001/api/");
var response = await client.GetAsync("glossary");
var data = await JsonSerializer.DeserializeAsync<IEnumerable<GlossaryItem>>(
response.Content.ReadAsStreamAsync().Result);
Assert.True(data.Count() > 0);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment