Created
December 22, 2019 16:34
-
-
Save acraven/0b77a03ebd74f67510aa4a167069f641 to your computer and use it in GitHub Desktop.
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.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