diff --git a/.gitignore b/.gitignore
index 7bf48b618..04c3e8999 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@ Source/Source.sln
Output/
bin/
.vs/
+Unity-Technologies-networking/packages
# ============ #
# OS generated #
@@ -42,3 +43,6 @@ bin/
.Trashes
ehthumbs.db
Thumbs.db
+
+
+
diff --git a/Unity-Technologies-networking/Networking.sln b/Unity-Technologies-networking/Networking.sln
index e8e5de86c..dacc2646d 100644
--- a/Unity-Technologies-networking/Networking.sln
+++ b/Unity-Technologies-networking/Networking.sln
@@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityEngine.Networking-Edit
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UNetWeaver", "Weaver\UNetWeaver.csproj", "{709222FD-15C2-497D-8B31-366ADCC074CD}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityEngine.Networking.Tests", "UnityEngine.Networking.Tests\UnityEngine.Networking.Tests.csproj", "{F57702C3-86F0-421C-8B29-AE00F0B84BAF}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -40,6 +42,12 @@ Global
{F8AD1DD0-E73F-419B-97BB-3C708BCA79C8}.Release|Any CPU.Build.0 = Release|Any CPU
{F8AD1DD0-E73F-419B-97BB-3C708BCA79C8}.Testing|Any CPU.ActiveCfg = Release|Any CPU
{F8AD1DD0-E73F-419B-97BB-3C708BCA79C8}.Testing|Any CPU.Build.0 = Release|Any CPU
+ {F57702C3-86F0-421C-8B29-AE00F0B84BAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F57702C3-86F0-421C-8B29-AE00F0B84BAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F57702C3-86F0-421C-8B29-AE00F0B84BAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F57702C3-86F0-421C-8B29-AE00F0B84BAF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F57702C3-86F0-421C-8B29-AE00F0B84BAF}.Testing|Any CPU.ActiveCfg = Debug|Any CPU
+ {F57702C3-86F0-421C-8B29-AE00F0B84BAF}.Testing|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Unity-Technologies-networking/UnityEngine.Networking.Tests/NetworkWriterTest.cs b/Unity-Technologies-networking/UnityEngine.Networking.Tests/NetworkWriterTest.cs
new file mode 100644
index 000000000..791eba400
--- /dev/null
+++ b/Unity-Technologies-networking/UnityEngine.Networking.Tests/NetworkWriterTest.cs
@@ -0,0 +1,125 @@
+using NUnit.Framework;
+using System;
+using UnityEngine;
+
+namespace UnityEngine.Networking.Tests
+{
+ [TestFixture()]
+ public class NetworkWriterTest
+ {
+
+ [Test]
+ public void TestWritingSmallMessage()
+ {
+ // try serializing <32kb and see what happens
+ NetworkWriter writer = new NetworkWriter();
+ for (int i = 0; i < 30000 / 4; ++i)
+ writer.Write(i);
+ Assert.That(writer.Position, Is.EqualTo(30000));
+ }
+
+ [Test]
+ public void TestWritingLargeMessage()
+ {
+ // try serializing <32kb and see what happens
+ NetworkWriter writer = new NetworkWriter();
+ for (int i = 0; i < 40000 / 4; ++i)
+ writer.Write(i);
+ Assert.That(writer.Position, Is.EqualTo(40000));
+ }
+
+ [Test]
+ public void TestResetting()
+ {
+ NetworkWriter writer = new NetworkWriter();
+ writer.StartMessage((short)1337);
+ writer.Write(1);
+ writer.Write(2);
+ writer.Write(3);
+ writer.Write(4);
+ writer.FinishMessage();
+
+ // try SeekZero and reset afterwards
+ int messageSize = writer.Position;
+ writer.SeekZero();
+ Assert.That(writer.Position, Is.Zero);
+ writer.Position = messageSize;
+
+ // check if .ToArray() returns array until .Position
+ writer.Position = 4;
+ Assert.That(writer.ToArray().Length, Is.EqualTo(4));
+ }
+
+
+
+ [Test]
+ public void TestWritingAndReading()
+ {
+ // write all simple types once
+ NetworkWriter writer = new NetworkWriter();
+ writer.StartMessage((short)1337);
+ writer.Write((char)1);
+ writer.Write((byte)2);
+ writer.Write((sbyte)3);
+ writer.Write((bool)true);
+ writer.Write((short)4);
+ writer.Write((ushort)5);
+ writer.Write((int)6);
+ writer.Write((uint)7);
+ writer.Write((long)8L);
+ writer.Write((ulong)9L);
+ writer.Write((float)10);
+ writer.Write((double)11);
+ writer.Write((decimal)12);
+ writer.Write((string)null);
+ writer.Write((string)"");
+ writer.Write((string)"13");
+ writer.Write(new byte[] { 14, 15 }, 0, 2); // just the byte array, no size info etc.
+ writer.WriteBytesAndSize((byte[])null); // [SyncVar] struct values can have uninitialized byte arrays, null needs to be supported
+ writer.WriteBytesAndSize(new byte[] { 17, 18 }, 0, 2); // buffer, no-offset, count
+ writer.WriteBytesAndSize(new byte[] { 19, 20, 21 }, 1, 2); // buffer, offset, count
+ writer.WriteBytesAndSize(new byte[] { 22, 23 }, 0, 2); // size, buffer
+
+ writer.FinishMessage();
+
+ byte[] data = writer.ToArray();
+
+
+ // read them
+ NetworkReader reader = new NetworkReader(writer.ToArray());
+
+ Assert.That(reader.ReadInt16(), Is.EqualTo(data.Length - sizeof(ushort) * 2)); // msgType
+ Assert.That(reader.ReadUInt16(), Is.EqualTo(1337)); // contentSize (messasge.size - 4 bytes header)
+ Assert.That(reader.ReadChar(), Is.EqualTo(1));
+ Assert.That(reader.ReadByte(), Is.EqualTo(2));
+ Assert.That(reader.ReadSByte(), Is.EqualTo(3));
+ Assert.That(reader.ReadBoolean(), Is.True);
+ Assert.That(reader.ReadInt16(), Is.EqualTo(4));
+ Assert.That(reader.ReadUInt16(), Is.EqualTo(5));
+ Assert.That(reader.ReadInt32(), Is.EqualTo(6));
+ Assert.That(reader.ReadUInt32(), Is.EqualTo(7));
+ Assert.That(reader.ReadInt64(), Is.EqualTo(8));
+ Assert.That(reader.ReadUInt64(), Is.EqualTo(9));
+ Assert.That(reader.ReadSingle(), Is.EqualTo(10));
+ Assert.That(reader.ReadDouble(), Is.EqualTo(11));
+ Assert.That(reader.ReadDecimal(), Is.EqualTo(12));
+ Assert.That(reader.ReadString(), Is.Null); // writing null string should write null in HLAPI Pro ("" in original HLAPI)
+ Assert.That(reader.ReadString(), Is.EqualTo(""));
+ Assert.That(reader.ReadString(), Is.EqualTo("13"));
+
+ Assert.That(reader.ReadBytes(2), Is.EqualTo(new byte[] { 14, 15 }));
+
+ Assert.That(reader.ReadBytesAndSize(), Is.Null);
+
+ Assert.That(reader.ReadBytesAndSize(), Is.EqualTo(new byte[] { 17, 18 }));
+
+ Assert.That(reader.ReadBytesAndSize(), Is.EqualTo(new byte[] { 20, 21 }));
+
+ Assert.That(reader.ReadBytesAndSize(), Is.EqualTo(new byte[] { 22, 23 }));
+
+ reader.SeekZero();
+ Assert.That(reader.Position, Is.Zero);
+
+ }
+ }
+}
diff --git a/Unity-Technologies-networking/UnityEngine.Networking.Tests/UnityEngine.Networking.Tests.csproj b/Unity-Technologies-networking/UnityEngine.Networking.Tests/UnityEngine.Networking.Tests.csproj
new file mode 100644
index 000000000..3c57f9aec
--- /dev/null
+++ b/Unity-Technologies-networking/UnityEngine.Networking.Tests/UnityEngine.Networking.Tests.csproj
@@ -0,0 +1,50 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {F57702C3-86F0-421C-8B29-AE00F0B84BAF}
+ Library
+ UnityEngine.Networking.Tests
+ UnityEngine.Networking.Tests
+ v4.7
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG;
+ prompt
+ 4
+
+
+ true
+ bin\Release
+ prompt
+ 4
+
+
+
+
+ ..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll
+
+
+ ..\lib\UnityEngine.dll
+
+
+
+
+
+
+
+
+
+
+ {5F1B8F9B-4500-4D09-808B-F43E8337DF05}
+ UnityEngine.Networking
+
+
+
+
\ No newline at end of file
diff --git a/Unity-Technologies-networking/UnityEngine.Networking.Tests/packages.config b/Unity-Technologies-networking/UnityEngine.Networking.Tests/packages.config
new file mode 100644
index 000000000..36927ff05
--- /dev/null
+++ b/Unity-Technologies-networking/UnityEngine.Networking.Tests/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/appveyor.yml b/appveyor.yml
index f74002790..bd476c94e 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,5 +1,8 @@
version: '{branch}-{build}'
+before_build:
+ - nuget restore Unity-Technologies-networking/Networking.sln
+
build:
project: Unity-Technologies-networking/Networking.sln
verbosity: minimal