Add SerializerTests

This commit is contained in:
jvyden 2021-10-15 00:54:21 -04:00
commit 5e31bb8c31
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
2 changed files with 32 additions and 1 deletions

View file

@ -5,7 +5,7 @@ using ProjectLighthouse.Types;
using Xunit;
namespace ProjectLighthouse.Tests {
public class AuthenticationTest : LighthouseTest {
public class AuthenticationTests : LighthouseTest {
[Fact]
public async Task ShouldReturnErrorOnNoPostData() {
HttpResponseMessage response = await this.Client.PostAsync("/LITTLEBIGPLANETPS3_XML/login", null!);

View file

@ -0,0 +1,31 @@
using System.Collections.Generic;
using ProjectLighthouse.Serialization;
using Xunit;
namespace ProjectLighthouse.Tests {
public class SerializerTests : LighthouseTest {
[Fact]
public void BlankElementWorks() {
Assert.Equal("<test></test>", LbpSerializer.BlankElement("test"));
}
[Fact]
public void StringElementWorks() {
Assert.Equal("<test>asd</test>", LbpSerializer.StringElement("test", "asd"));
Assert.Equal("<test>asd</test>", LbpSerializer.StringElement(new KeyValuePair<string, object>("test", "asd")));
}
[Fact]
public void TaggedStringElementWorks() {
Assert.Equal("<test foo=\"bar\">asd</test>", LbpSerializer.TaggedStringElement("test", "asd", "foo", "bar"));
Assert.Equal("<test foo=\"bar\">asd</test>", LbpSerializer.TaggedStringElement(new KeyValuePair<string, object>("test", "asd"),
new KeyValuePair<string, object>("foo", "bar")));
}
[Fact]
public void ElementsWorks() {
Assert.Equal("<test>asd</test><foo>bar</foo>", LbpSerializer.Elements(new KeyValuePair<string, object>("test", "asd"),
new KeyValuePair<string, object>("foo", "bar")));
}
}
}