Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Party base sync #1033

Open
wants to merge 10 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 78 additions & 10 deletions source/E2E.Tests/Services/PartyBases/PartyBaseLifetimeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

namespace E2E.Tests.Services.PartyBases;

public class PartyBasePropertyTests : IDisposable
public class PartyBaseLifetimeTests : IDisposable
{
E2ETestEnvironment TestEnvironment { get; }

public PartyBasePropertyTests(ITestOutputHelper output)
public PartyBaseLifetimeTests(ITestOutputHelper output)
{
TestEnvironment = new E2ETestEnvironment(output);
}
Expand All @@ -22,7 +22,7 @@ public void Dispose()
}

[Fact]
public void Server_MobileParty_SyncAllClients()
public void ServerCreate_PartyBase_SyncAllClients()
{
// Arrange
var server = TestEnvironment.Server;
Expand All @@ -33,13 +33,9 @@ public void Server_MobileParty_SyncAllClients()
server.Call(() =>
{
var party = GameObjectCreator.CreateInitializedObject<MobileParty>();
partyId = party.StringId;
var partyBase = new PartyBase(default(MobileParty));

partyId = party.StringId;
Assert.True(server.ObjectManager.TryGetId(party.Party, out partyBaseId));


partyBase.MobileParty = party;
});

// Assert
Expand All @@ -50,12 +46,12 @@ public void Server_MobileParty_SyncAllClients()
{
Assert.True(client.ObjectManager.TryGetObject<MobileParty>(partyId, out var clientParty));
Assert.True(client.ObjectManager.TryGetObject<PartyBase>(partyBaseId, out var clientPartyBase));
Assert.Equal(clientParty, clientPartyBase.MobileParty);
Assert.Equal(clientPartyBase.MobileParty, clientParty);
}
}

[Fact]
public void Client_MobileParty_DoesNothing()
public void ClientCreate_PartyBase_DoesNothing()
{
// Arrange
var server = TestEnvironment.Server;
Expand All @@ -74,5 +70,77 @@ public void Client_MobileParty_DoesNothing()
// Assert
Assert.Null(partyBaseId);
}

[Fact]
public void ServerDestroy_PartyBase_SyncAllClients()
{
// Arrange
var server = TestEnvironment.Server;

string? partyId = null;
string? partyBaseId = null;
server.Call(() =>
{
var party = GameObjectCreator.CreateInitializedObject<MobileParty>();

Assert.True(server.ObjectManager.TryGetId(party, out partyId));
Assert.True(server.ObjectManager.TryGetId(party.Party, out partyBaseId));
});


// Act
server.Call(() =>
{
Assert.True(server.ObjectManager.TryGetObject<MobileParty>(partyId, out var party));

// PartyBase will be removed with party as they are coupled
MessageBroker.Instance.Publish(this, new PartyDestroyed(party));
});

// Assert
Assert.NotNull(partyBaseId);

foreach (var client in TestEnvironment.Clients)
{
Assert.False(client.ObjectManager.TryGetObject<PartyBase>(partyBaseId, out var _));
}
}

[Fact]
public void ClientDestroy_PartyBase_DoesNothing()
{
// Arrange
var server = TestEnvironment.Server;

string? partyId = null;
string? partyBaseId = null;
server.Call(() =>
{
var party = GameObjectCreator.CreateInitializedObject<MobileParty>();

Assert.True(server.ObjectManager.TryGetId(party, out partyId));
Assert.True(server.ObjectManager.TryGetId(party.Party, out partyBaseId));
});


// Act

var firstClient = TestEnvironment.Clients.First();
firstClient.Call(() =>
{
Assert.True(server.ObjectManager.TryGetObject<MobileParty>(partyId, out var party));

// PartyBase will be removed with party as they are coupled
MessageBroker.Instance.Publish(this, new PartyDestroyed(party));
});

// Assert
Assert.NotNull(partyBaseId);

foreach (var client in TestEnvironment.Clients)
{
Assert.True(client.ObjectManager.TryGetObject<PartyBase>(partyBaseId, out var _));
}
}
}

150 changes: 0 additions & 150 deletions source/E2E.Tests/Services/PartyBases/PartyBasePropertyTests.cs

This file was deleted.

Loading