Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save acraven/0b77a03ebd74f67510aa4a167069f641 to your computer and use it in GitHub Desktop.
Save acraven/0b77a03ebd74f67510aa4a167069f641 to your computer and use it in GitHub Desktop.
using System.Net;
using System.Threading.Tasks;
using FluentAssertions.Json;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
namespace Microservice.OutsideIn.Tests
{
public class RetrieveOneContact : ScenarioBase
{
private HttpStatusCode _statusCode;
private string _content;
[OneTimeSetUp]
public async Task SetupScenario()
{
var contact = new
{
firstName = "Janet",
lastName = "Montgomery",
dateOfBirth = "1985-10-29"
};
var (_, location) = await PostAsync(contact, $"contacts");
(_statusCode, _content) = await GetAsync(location);
}
[Test]
public void GetReturnsStatusCodeOkay()
{
Assert.That(_statusCode, Is.EqualTo(HttpStatusCode.OK));
}
[Test]
public void GetReturnsContact()
{
var contact = JObject.Parse(_content);
var expectedContact = new JObject
{
["firstName"] = "Janet",
["lastName"] = "Montgomery",
["dateOfBirth"] = "1985-10-29"
};
contact.Should().ContainSubtree(expectedContact);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment