mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 08:28:39 +00:00
Replace Location table with packed 64-bit int (#679)
* Replace Location table with packed 64 bit int * Remove double Include and fix Slot documentation * Fix compilation errors from merge * Fix namespaces and add expected values to unit tests
This commit is contained in:
parent
575d2b7be7
commit
35ea2682b9
30 changed files with 996 additions and 930 deletions
81
ProjectLighthouse.Tests/Tests/LocationTests.cs
Normal file
81
ProjectLighthouse.Tests/Tests/LocationTests.cs
Normal file
|
@ -0,0 +1,81 @@
|
|||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Misc;
|
||||
using Xunit;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Tests;
|
||||
|
||||
public class LocationTests
|
||||
{
|
||||
[Fact]
|
||||
public void ShouldSetAndReadUserLocation()
|
||||
{
|
||||
Location expected = new()
|
||||
{
|
||||
X = 1000,
|
||||
Y = 5000,
|
||||
};
|
||||
User user = new()
|
||||
{
|
||||
Location = new Location
|
||||
{
|
||||
X = expected.X,
|
||||
Y = expected.Y,
|
||||
},
|
||||
};
|
||||
Assert.True(user.Location.X == expected.X);
|
||||
Assert.True(user.Location.Y == expected.Y);
|
||||
Assert.True(user.LocationPacked == 4_294_967_301_000);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShouldSetAndReadSlotLocation()
|
||||
{
|
||||
Location expected = new()
|
||||
{
|
||||
X = 1000,
|
||||
Y = 5000,
|
||||
};
|
||||
Slot slot = new()
|
||||
{
|
||||
Location = new Location
|
||||
{
|
||||
X = expected.X,
|
||||
Y = expected.Y,
|
||||
},
|
||||
};
|
||||
Assert.True(slot.Location.X == expected.X);
|
||||
Assert.True(slot.Location.Y == expected.Y);
|
||||
Assert.True(slot.LocationPacked == 4_294_967_301_000);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShouldReadLocationAfterDeserialization()
|
||||
{
|
||||
XmlSerializer deserializer = new(typeof(Slot));
|
||||
const string slotData = "<slot><name>test</name><resource>test</resource><location><x>4000</x><y>9000</y></location></slot>";
|
||||
|
||||
Slot? deserialized = (Slot?)deserializer.Deserialize(new StringReader(slotData));
|
||||
Assert.True(deserialized != null);
|
||||
Assert.True(deserialized.Name == "test");
|
||||
Assert.True(deserialized.Location.X == 4000);
|
||||
Assert.True(deserialized.Location.Y == 9000);
|
||||
Assert.True(deserialized.LocationPacked == 17_179_869_193_000);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShouldDeserializeEmptyLocation()
|
||||
{
|
||||
XmlSerializer deserializer = new(typeof(Slot));
|
||||
const string slotData = "<slot><name>test</name></slot>";
|
||||
|
||||
Slot? deserialized = (Slot?)deserializer.Deserialize(new StringReader(slotData));
|
||||
Assert.True(deserialized != null);
|
||||
Assert.True(deserialized.Name == "test");
|
||||
Assert.True(deserialized.Location.X == 0);
|
||||
Assert.True(deserialized.Location.Y == 0);
|
||||
Assert.True(deserialized.LocationPacked == 0);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue