Skip to content

Commit 3ebc1b1

Browse files
test: cleanup up fixed string test to not need struct (#1236)
* test: cleanup up fixed string test to not need struct
1 parent a0231af commit 3ebc1b1

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

com.unity.netcode.gameobjects/Tests/Runtime/NetworkVariableTests.cs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@
77

88
namespace Unity.Netcode.RuntimeTests
99
{
10-
public struct FixedString32Struct : INetworkSerializable
11-
{
12-
public FixedString32Bytes FixedString;
13-
14-
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
15-
{
16-
serializer.SerializeValue(ref FixedString);
17-
}
18-
}
19-
2010
public struct TestStruct : INetworkSerializable
2111
{
2212
public uint SomeInt;
@@ -34,7 +24,7 @@ public class NetworkVariableTest : NetworkBehaviour
3424
public readonly NetworkVariable<int> TheScalar = new NetworkVariable<int>();
3525
public readonly NetworkList<int> TheList = new NetworkList<int>();
3626

37-
public readonly NetworkVariable<FixedString32Struct> FixedStringStruct = new NetworkVariable<FixedString32Struct>();
27+
public readonly NetworkVariable<FixedString32Bytes> FixedString32 = new NetworkVariable<FixedString32Bytes>();
3828

3929
private void ListChanged(NetworkListEvent<int> e)
4030
{
@@ -166,26 +156,23 @@ public void ClientWritePermissionTest([Values(true, false)] bool useHost)
166156
}
167157

168158
[UnityTest]
169-
public IEnumerator FixedString32StructTest([Values(true, false)] bool useHost)
159+
public IEnumerator FixedString32Test([Values(true, false)] bool useHost)
170160
{
171161
m_TestWithHost = useHost;
172162
yield return MultiInstanceHelpers.RunAndWaitForCondition(
173163
() =>
174164
{
175-
var tmp = m_Player1OnServer.FixedStringStruct.Value;
176-
tmp.FixedString = k_FixedStringTestValue;
177-
m_Player1OnServer.FixedStringStruct.Value = tmp;
165+
m_Player1OnServer.FixedString32.Value = k_FixedStringTestValue;
178166

179167
// we are writing to the private and public variables on player 1's object...
180168
},
181169
() =>
182170
{
183-
var tmp = m_Player1OnClient1.FixedStringStruct.Value;
184171

185172
// ...and we should see the writes to the private var only on the server & the owner,
186173
// but the public variable everywhere
187174
return
188-
m_Player1OnClient1.FixedStringStruct.Value.FixedString == k_FixedStringTestValue;
175+
m_Player1OnClient1.FixedString32.Value == k_FixedStringTestValue;
189176
}
190177
);
191178
}

0 commit comments

Comments
 (0)