mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 08:28:39 +00:00
The Great Formatting of 2022
This commit is contained in:
parent
59cc7f02fb
commit
35f50f5f8c
162 changed files with 6609 additions and 6809 deletions
|
@ -9,85 +9,84 @@ using LBPUnion.ProjectLighthouse.Types.Levels;
|
|||
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests.GameApiTests
|
||||
namespace ProjectLighthouse.Tests.GameApiTests;
|
||||
|
||||
public class SlotTests : LighthouseServerTest
|
||||
{
|
||||
public class SlotTests : LighthouseServerTest
|
||||
[DatabaseFact]
|
||||
public async Task ShouldOnlyShowUsersLevels()
|
||||
{
|
||||
[DatabaseFact]
|
||||
public async Task ShouldOnlyShowUsersLevels()
|
||||
await using Database database = new();
|
||||
|
||||
Random r = new();
|
||||
|
||||
User userA = await database.CreateUser($"unitTestUser{r.Next()}", HashHelper.GenerateAuthToken());
|
||||
User userB = await database.CreateUser($"unitTestUser{r.Next()}", HashHelper.GenerateAuthToken());
|
||||
|
||||
Location l = new()
|
||||
{
|
||||
await using Database database = new();
|
||||
X = 0,
|
||||
Y = 0,
|
||||
};
|
||||
database.Locations.Add(l);
|
||||
await database.SaveChangesAsync();
|
||||
|
||||
Random r = new();
|
||||
Slot slotA = new()
|
||||
{
|
||||
Creator = userA,
|
||||
CreatorId = userA.UserId,
|
||||
Name = "slotA",
|
||||
Location = l,
|
||||
LocationId = l.Id,
|
||||
ResourceCollection = "",
|
||||
};
|
||||
|
||||
User userA = await database.CreateUser($"unitTestUser{r.Next()}", HashHelper.GenerateAuthToken());
|
||||
User userB = await database.CreateUser($"unitTestUser{r.Next()}", HashHelper.GenerateAuthToken());
|
||||
Slot slotB = new()
|
||||
{
|
||||
Creator = userB,
|
||||
CreatorId = userB.UserId,
|
||||
Name = "slotB",
|
||||
Location = l,
|
||||
LocationId = l.Id,
|
||||
ResourceCollection = "",
|
||||
};
|
||||
|
||||
Location l = new()
|
||||
{
|
||||
X = 0,
|
||||
Y = 0,
|
||||
};
|
||||
database.Locations.Add(l);
|
||||
await database.SaveChangesAsync();
|
||||
database.Slots.Add(slotA);
|
||||
database.Slots.Add(slotB);
|
||||
|
||||
Slot slotA = new()
|
||||
{
|
||||
Creator = userA,
|
||||
CreatorId = userA.UserId,
|
||||
Name = "slotA",
|
||||
Location = l,
|
||||
LocationId = l.Id,
|
||||
ResourceCollection = "",
|
||||
};
|
||||
|
||||
Slot slotB = new()
|
||||
{
|
||||
Creator = userB,
|
||||
CreatorId = userB.UserId,
|
||||
Name = "slotB",
|
||||
Location = l,
|
||||
LocationId = l.Id,
|
||||
ResourceCollection = "",
|
||||
};
|
||||
|
||||
database.Slots.Add(slotA);
|
||||
database.Slots.Add(slotB);
|
||||
|
||||
await database.SaveChangesAsync();
|
||||
await database.SaveChangesAsync();
|
||||
|
||||
// XmlSerializer serializer = new(typeof(Slot));
|
||||
// Slot slot = (Slot)serializer.Deserialize(new StringReader(bodyString));
|
||||
|
||||
LoginResult loginResult = await this.Authenticate();
|
||||
LoginResult loginResult = await this.Authenticate();
|
||||
|
||||
HttpResponseMessage respMessageA = await this.AuthenticatedRequest
|
||||
($"LITTLEBIGPLANETPS3_XML/slots/by?u={userA.Username}&pageStart=1&pageSize=1", loginResult.AuthTicket);
|
||||
HttpResponseMessage respMessageB = await this.AuthenticatedRequest
|
||||
($"LITTLEBIGPLANETPS3_XML/slots/by?u={userB.Username}&pageStart=1&pageSize=1", loginResult.AuthTicket);
|
||||
HttpResponseMessage respMessageA = await this.AuthenticatedRequest
|
||||
($"LITTLEBIGPLANETPS3_XML/slots/by?u={userA.Username}&pageStart=1&pageSize=1", loginResult.AuthTicket);
|
||||
HttpResponseMessage respMessageB = await this.AuthenticatedRequest
|
||||
($"LITTLEBIGPLANETPS3_XML/slots/by?u={userB.Username}&pageStart=1&pageSize=1", loginResult.AuthTicket);
|
||||
|
||||
Assert.True(respMessageA.IsSuccessStatusCode);
|
||||
Assert.True(respMessageB.IsSuccessStatusCode);
|
||||
Assert.True(respMessageA.IsSuccessStatusCode);
|
||||
Assert.True(respMessageB.IsSuccessStatusCode);
|
||||
|
||||
string respA = await respMessageA.Content.ReadAsStringAsync();
|
||||
string respB = await respMessageB.Content.ReadAsStringAsync();
|
||||
string respA = await respMessageA.Content.ReadAsStringAsync();
|
||||
string respB = await respMessageB.Content.ReadAsStringAsync();
|
||||
|
||||
Assert.False(string.IsNullOrEmpty(respA));
|
||||
Assert.False(string.IsNullOrEmpty(respB));
|
||||
Assert.False(string.IsNullOrEmpty(respA));
|
||||
Assert.False(string.IsNullOrEmpty(respB));
|
||||
|
||||
Assert.NotEqual(respA, respB);
|
||||
Assert.DoesNotContain(respA, "slotB");
|
||||
Assert.DoesNotContain(respB, "slotA");
|
||||
Assert.NotEqual(respA, respB);
|
||||
Assert.DoesNotContain(respA, "slotB");
|
||||
Assert.DoesNotContain(respB, "slotA");
|
||||
|
||||
// Cleanup
|
||||
// Cleanup
|
||||
|
||||
database.Slots.Remove(slotA);
|
||||
database.Slots.Remove(slotB);
|
||||
database.Slots.Remove(slotA);
|
||||
database.Slots.Remove(slotB);
|
||||
|
||||
await database.RemoveUser(userA);
|
||||
await database.RemoveUser(userB);
|
||||
await database.RemoveUser(userA);
|
||||
await database.RemoveUser(userB);
|
||||
|
||||
await database.SaveChangesAsync();
|
||||
}
|
||||
await database.SaveChangesAsync();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue