NetworkReaderTest to reach 100% NetworkReader coverage

This commit is contained in:
vis2k 2020-01-22 09:51:06 +01:00
parent e798ac45de
commit 9d7513925f
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,33 @@
using System;
using System.IO;
using NUnit.Framework;
using UnityEngine;
namespace Mirror.Tests
{
// NetworkWriterTest already covers most cases for NetworkReader.
// only a few are left
[TestFixture]
public class NetworkReaderTest
{
[Test]
public void ReadBytesCountTooBigTest()
{
// calling ReadBytes with a count bigger than what is in Reader
// should throw an exception
byte[] bytes = {0x00, 0x01};
NetworkReader reader = new NetworkReader(bytes);
try
{
byte[] result = reader.ReadBytes(bytes, bytes.Length + 1);
// BAD: IF WE GOT HERE, THEN NO EXCEPTION WAS THROWN
Assert.Fail();
}
catch (EndOfStreamException)
{
// GOOD
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3799af27efdf144909de8790851053a8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: