mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-20 12:19:32 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
56 lines
908 B
C#
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;
|
|
} );
|
|
}
|
|
}
|