mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
test for sync list using interface (#1767)
This commit is contained in:
parent
a2eb666f15
commit
d4f834ac08
@ -158,6 +158,23 @@ public void SyncListGenericStructWithCustomMethods()
|
|||||||
Assert.That(weaverErrors, Is.Empty);
|
Assert.That(weaverErrors, Is.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SyncListErrorForInterface()
|
||||||
|
{
|
||||||
|
Assert.That(CompilationFinishedHook.WeaveFailed, Is.True);
|
||||||
|
string weaverError = @"Mirror\.Weaver error:";
|
||||||
|
string type = @"MirrorTest\.MyInterfaceList";
|
||||||
|
string errorMessage = @"cannot have item of type MirrorTest\.MyInterface\. Use a type supported by mirror instead";
|
||||||
|
Assert.That(weaverErrors, Has.Some.Match($"{weaverError} {type} {errorMessage}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SyncListInterfaceWithCustomMethods()
|
||||||
|
{
|
||||||
|
Assert.That(CompilationFinishedHook.WeaveFailed, Is.False);
|
||||||
|
Assert.That(weaverErrors, Is.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void SyncListErrorWhenUsingGenericListInNetworkBehaviour()
|
public void SyncListErrorWhenUsingGenericListInNetworkBehaviour()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using Mirror;
|
||||||
|
|
||||||
|
namespace MirrorTest
|
||||||
|
{
|
||||||
|
class SyncListErrorForInterface : NetworkBehaviour
|
||||||
|
{
|
||||||
|
MyInterfaceList Foo;
|
||||||
|
}
|
||||||
|
interface MyInterface
|
||||||
|
{
|
||||||
|
int someNumber { get; set; }
|
||||||
|
}
|
||||||
|
class MyInterfaceList : SyncList<MyInterface> { }
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using Mirror;
|
||||||
|
|
||||||
|
namespace MirrorTest
|
||||||
|
{
|
||||||
|
class SyncListInterfaceWithCustomMethods : NetworkBehaviour
|
||||||
|
{
|
||||||
|
MyInterfaceList Foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IMyInterface
|
||||||
|
{
|
||||||
|
int someNumber { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyUser : IMyInterface
|
||||||
|
{
|
||||||
|
public int someNumber { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyInterfaceList : SyncList<IMyInterface>
|
||||||
|
{
|
||||||
|
protected override void SerializeItem(NetworkWriter writer, IMyInterface item)
|
||||||
|
{
|
||||||
|
writer.WriteInt32(item.someNumber);
|
||||||
|
}
|
||||||
|
protected override IMyInterface DeserializeItem(NetworkReader reader)
|
||||||
|
{
|
||||||
|
return new MyUser { someNumber = reader.ReadInt32() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user