Created
December 30, 2019 12:35
-
-
Save gnschenker/8606db6fa134be6ad00b6a0b186af462 to your computer and use it in GitHub Desktop.
Integration test for API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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