public void AuthResponseMessageTest() { // try setting value with constructor var message = new AuthResponseMessage { success = true, message = "abc" }; Assert.That(message.success, Is.EqualTo(true)); Assert.That(message.message, Is.EqualTo("abc")); // serialize var writer = new NetworkWriter(1300); writer.Write(message); // try deserialize var reader = new NetworkReader(); reader.Reset(writer.ToArraySegment()); AuthResponseMessage fresh = reader.Read <AuthResponseMessage>(); Assert.That(fresh.success, Is.EqualTo(true)); Assert.That(fresh.message, Is.EqualTo("abc")); reader.Dispose(); }
public void DoesNotUseCustomWriter() { // check method names Assert.That(Writer <MyCustomType> .Write.Method.Name, Is.Not.EqualTo(new Action <NetworkWriter, MyCustomType>(MyCustomTypeExtension.WriteOnlyPartOfCustom).Method.Name)); Assert.That(Reader <MyCustomType> .Read.Method.Name, Is.Not.EqualTo(new Func <NetworkReader, MyCustomType>(MyCustomTypeExtension.ReadOnlyPartOfCustom).Method.Name)); // check writing and reading var data = new MyCustomType { first = 10, second = 20, }; var writer = new NetworkWriter(1300); writer.Write(data); var reader = new NetworkReader(); reader.Reset(writer.ToArraySegment()); MyCustomType copy = reader.Read <MyCustomType>(); // should have copied both fields, // if it uses custom extension methods it will only write first Assert.That(copy.first, Is.EqualTo(data.first)); Assert.That(copy.second, Is.EqualTo(data.second)); reader.Dispose(); }
public void TearDown() { // we have to clear these each time so that capactity doesn't effect other tests writer.Reset(); writer = null; reader.Dispose(); reader = null; }
public void TearDown() { TearDownTestObjects(); ownerWriter.Reset(); observersWriter.Reset(); reader.Dispose(); }
public void TearDown() { UnityEngine.Object.DestroyImmediate(serverTester.gameObject); UnityEngine.Object.DestroyImmediate(clientTester.gameObject); ownerWriter.Reset(); observersWriter.Reset(); reader.Dispose(); }
public void TestAccessingCustomWriterAndReader() { var data = new MyType { id = 10, name = "Yo Gaba Gaba" }; var writer = new NetworkWriter(1300); writer.Write(data); var reader = new NetworkReader(); reader.Reset(writer.ToArraySegment()); var copy = reader.Read <MyType>(); Assert.That(copy, Is.EqualTo(data)); reader.Dispose(); }
public void AuthRequestMessageTest() { // try setting value with constructor var message = new AuthRequestMessage { serverCode = "abc", }; Assert.That(message.serverCode, Is.EqualTo("abc")); // serialize var writer = new NetworkWriter(1300); writer.Write(message); // try deserialize var reader = new NetworkReader(); reader.Reset(writer.ToArraySegment()); var fresh = reader.Read <AuthRequestMessage>(); Assert.That(fresh.serverCode, Is.EqualTo("abc")); reader.Dispose(); }
public void TearDown() { writer.Reset(); reader.Dispose(); }
public void TearDown() { reader.Dispose(); reader = null; }
public void TearDown() { ownerWriter.Reset(); observersWriter.Reset(); reader.Dispose(); }