Files
sbox-public/engine/Sandbox.Test.Unit/Network/NetList.cs
Lorenz Junglas 91f8fcf183 Speed up / parallelize tests (#3587)
- Added Sandbox.Test.Unit project (contains independent tests that can run in parallel) 
- Modify some slow/stress tests (e.g. instead of doing a million iterations settle for 10k).

Tests run almost twice as fast now.
2025-12-10 14:23:00 +01:00

54 lines
850 B
C#

using System;
namespace Networking;
[TestClass]
public class NetList
{
[TestMethod]
public void AddRemoveAndCount()
{
var list = new NetList<int>();
Assert.IsTrue( list.Count == 0 );
list.Add( 3 );
Assert.IsTrue( list.Count == 1 );
Assert.AreEqual( 3, list[0] );
list.Remove( 3 );
Assert.IsTrue( list.Count == 0 );
}
[TestMethod]
public void Iterate()
{
var list = new NetList<int>();
list.Add( 1 );
list.Add( 2 );
list.Add( 3 );
var current = 0;
foreach ( var item in list )
{
current++;
Assert.AreEqual( item, current );
}
Assert.AreEqual( 1, list[0] );
Assert.AreEqual( 2, list[1] );
Assert.AreEqual( 3, list[2] );
}
[TestMethod]
public void ValidAccess()
{
var list = new NetList<int>();
Assert.ThrowsException<ArgumentOutOfRangeException>( () =>
{
list[0] = 1;
} );
}
}