Basic testing framework

This commit is contained in:
jvyden 2021-10-14 23:50:08 -04:00
commit 5052d19656
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
8 changed files with 97 additions and 4 deletions

View file

@ -0,0 +1,28 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Xunit;
namespace ProjectLighthouse.Tests {
public class AuthenticationTest : LighthouseTest {
[Fact]
public async Task ShouldReturnErrorOnNoPostData() {
var response = await this.Client.PostAsync("/LITTLEBIGPLANETPS3_XML/login", null!);
Assert.False(response.IsSuccessStatusCode);
#if NET6_0_OR_GREATER
Assert.True(response.StatusCode == HttpStatusCode.BadRequest);
#else
Assert.True(response.StatusCode == HttpStatusCode.NotAcceptable);
#endif
}
[DatabaseFact]
public async Task ShouldAuthenticateWithValidData() {
const char nullChar = (char)0x00;
const char sepChar = (char)0x20;
var response = await this.Client.PostAsync("/LITTLEBIGPLANETPS3_XML/login", new StringContent($"{nullChar}{sepChar}jvyden{nullChar}"));
Assert.True(response.StatusCode == HttpStatusCode.OK);
}
}
}