Files
sbox-public/engine/Sandbox.Test/Network/netList.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

56 lines
908 B
C#

using System;
using System.Collections.Generic;
using System.Text.Json;
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;
} );
}
}