Skip to content

Commit

Permalink
fix: add comments and backing field for time (#618)
Browse files Browse the repository at this point in the history
* fix: add comments and backing field for time

* readonly to fix code smell

* add tests
  • Loading branch information
uweeby committed Feb 20, 2021
1 parent 7a42dab commit da74e11
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
9 changes: 8 additions & 1 deletion Assets/Mirage/Runtime/NetworkClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ public class NetworkClient : MonoBehaviour, INetworkClient
/// </summary>
public bool IsConnected => connectState == ConnectState.Connected;

public readonly NetworkTime Time = new NetworkTime();
readonly NetworkTime _time = new NetworkTime();
/// <summary>
/// Time kept in this client
/// </summary>
public NetworkTime Time
{
get { return _time; }
}

/// <summary>
/// NetworkClient can connect to local server in host mode too
Expand Down
10 changes: 8 additions & 2 deletions Assets/Mirage/Runtime/NetworkServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,14 @@ public class NetworkServer : MonoBehaviour, INetworkServer
/// </summary>
public bool Active { get; private set; }

// Time kept in this server
public readonly NetworkTime Time = new NetworkTime();
readonly NetworkTime _time = new NetworkTime();
/// <summary>
/// Time kept in this server
/// </summary>
public NetworkTime Time
{
get { return _time; }
}

/// <summary>
/// This shuts down the server and disconnects all clients.
Expand Down
6 changes: 6 additions & 0 deletions Assets/Tests/Runtime/Host/NetworkClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,11 @@ public void DisconnectedNotNullTest()
{
Assert.That(client.Disconnected, Is.Not.Null);
}

[Test]
public void TimeNotNullTest()
{
Assert.That(client.Time, Is.Not.Null);
}
}
}
6 changes: 6 additions & 0 deletions Assets/Tests/Runtime/Host/NetworkServerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,11 @@ public void OnStopHostNotNullTest()
{
Assert.That(server.OnStopHost, Is.Not.Null);
}

[Test]
public void TimeNotNullTest()
{
Assert.That(server.Time, Is.Not.Null);
}
}
}

0 comments on commit da74e11

Please sign in to comment.