Saxonite 1.2.11.8
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
|
||||
namespace Sarand.UnitTests.Core.Base.Utils
|
||||
{
|
||||
[TestClass]
|
||||
public class ListUtil_Tester
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Is Empty.
|
||||
//-------------------------------------------------------------------
|
||||
[TestMethod]
|
||||
public void ListUtil_IsEmpty_Test()
|
||||
{
|
||||
List<String> values = new List<string>();
|
||||
|
||||
Assert.AreEqual(true, ListUtil.IsEmpty(values));
|
||||
Assert.AreEqual(true, values.IsEmpty());
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
values.Add(i.ToString());
|
||||
|
||||
Assert.AreEqual(false, ListUtil.IsEmpty(values));
|
||||
Assert.AreEqual(false, values.IsEmpty());
|
||||
|
||||
values.Clear();
|
||||
|
||||
Assert.AreEqual(true, ListUtil.IsEmpty(values));
|
||||
Assert.AreEqual(true, values.IsEmpty());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Randomise.
|
||||
//-------------------------------------------------------------------
|
||||
[TestMethod]
|
||||
public void ListUtil_Randomise_Test()
|
||||
{
|
||||
// Assume that randomising a list of 100 values highly unlikely to result in same sequence!
|
||||
int itemsInList = 100;
|
||||
int testsToRun = 1000;
|
||||
|
||||
for (int testIdx = 0; testIdx < testsToRun; testIdx++)
|
||||
{
|
||||
// Initialise list with sequence.
|
||||
List<String> values = new List<string>();
|
||||
for (int i = 0; i < itemsInList; i++)
|
||||
values.Add(i.ToString());
|
||||
|
||||
for (int i = 0; i < itemsInList; i++)
|
||||
Assert.AreEqual(i.ToString(), values[i]);
|
||||
|
||||
values = values.Randomise();
|
||||
//Debug.WriteLine($"{SysUtil.Fn} Values: {values.Concat(",")}");
|
||||
|
||||
bool originalSequence = true;
|
||||
for (int i = 0; i < itemsInList; i++)
|
||||
{
|
||||
if (values[i] != i.ToString())
|
||||
{
|
||||
originalSequence = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Assert.AreEqual(false, originalSequence);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user