public void EncodeData() { int[] arr = { 5, 6, 7, 8, 9 }; TestObject pre = new TestObject('1', 2, 3, 4, 1.5f, "Hello, World!", arr); byte[] encoded = NetworkManager.Encode(pre); TestObject post = NetworkManager.Decode <TestObject>(encoded); Console.WriteLine(pre); Console.WriteLine(post); Assert.That(pre.Equals(post)); }
public void EncodeData() { int[] arr = { 5, 6, 7, 8, 9 }; TestObject pre = new TestObject('1', 2, 3, 4, 1.5f, "Hello, World!", arr); byte[] encoded = NetworkManager.Encode(pre); TestObject post = NetworkManager.Decode<TestObject>(encoded); Console.WriteLine(pre); Console.WriteLine(post); Assert.That(pre.Equals(post)); }
public void SendRecieveEncodedData() { netMan.Listen(); int[] intArr = { 8, 9, 10 }; TestObject serializableObj = new TestObject('1', 2, 3, 4, 4f, "seven", intArr); if (!netMan.Connect(NetworkManager.LocalIP)) { Assert.Fail("Failed to connect to self"); } byte[] data = NetworkManager.Encode(serializableObj); if (!netMan.Send(NetworkManager.LocalIP, data)) { Assert.Fail("Failed to send data"); } while (!obs.recieved) { ; } TestObject post = NetworkManager.Decode <TestObject>(obs.dataRecieved); for (int i = 0; i < data.Length && i < obs.dataRecieved.Length; ++i) { Console.WriteLine("pre: {0}", data[i]); Console.WriteLine("post: {0}", obs.dataRecieved[i]); Assert.That(data[i] == obs.dataRecieved[i], "Data not the same here {0}: pre: {0} post: {0}", i); } Console.WriteLine("Pre: {0}", serializableObj.ToString()); Console.WriteLine("Post: {0}", post.ToString()); Assert.That(post.Equals(serializableObj)); }