mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-01 17:48:41 +00:00
Basic testing framework
This commit is contained in:
parent
bce6d1e2ef
commit
5052d19656
8 changed files with 97 additions and 4 deletions
28
ProjectLighthouse.Tests/Tests/AuthenticationTest.cs
Normal file
28
ProjectLighthouse.Tests/Tests/AuthenticationTest.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue