Skip to content

Instantly share code, notes, and snippets.

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 scottsauber/a91fca3bdb026e617bf2e91cfd252cb1 to your computer and use it in GitHub Desktop.
Save scottsauber/a91fca3bdb026e617bf2e91cfd252cb1 to your computer and use it in GitHub Desktop.
[Fact]
public async Task DoesReturnOk_GivenUserExists()
{
// Arrange
var user = new ApplicationUser
{
Id = "123",
Email = "test@test.com"
};
_context.Users.Add(user);
_context.SaveChanges();
// Act
var response = await _client.GetAsync($"/api/ApplicationUsers/{user.Id}");
// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
string jsonResult = await response.Content.ReadAsStringAsync();
ApplicationUser userFromJson = JsonConvert.DeserializeObject<ApplicationUser>(jsonResult);
Assert.Equal(user.Id, userFromJson.Id);
Assert.Equal(user.Email, userFromJson.Email);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment