public async Task LoginWithBadCredentials(string credentials) { // SETUP ByteArrayContent content = HttpBody.GetBodyFromJSONString(credentials); // ACT var response = await _testFixture.Client.PostAsync(LOGIN_ROUTE, content); // ASSERT response.StatusCode.Should().Be(HttpStatusCode.Unauthorized); }
public async Task LoginWithGoodCredentials(string credentials) { // SETUP ByteArrayContent content = HttpBody.GetBodyFromJSONString(credentials); // ACT var response = await _testFixture.Client.PostAsync(LOGIN_ROUTE, content); // ASSERT response.StatusCode.Should().Be(HttpStatusCode.OK); var jsonString = await response.Content.ReadAsStringAsync(); var jsonObject = JObject.Parse(jsonString); jsonObject.Should().HaveElement("token").And.HaveElement("expires"); LoginResponseModel loginResponse = jsonObject.ToObject <LoginResponseModel>(); loginResponse.Token.Should().NotBeEmpty(); loginResponse.Expires.Should().BeAfter(DateTime.Now); }