Skip to content

Instantly share code, notes, and snippets.

@posaunehm
Created November 9, 2012 16:51
Show Gist options
  • Save posaunehm/4046798 to your computer and use it in GitHub Desktop.
Save posaunehm/4046798 to your computer and use it in GitHub Desktop.
ListとSortedListの挙動の違いを確認する。
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
namespace List_SortedList_Behavior_Test
{
public class Test
{
private List<int> _randList;
[SetUp]
public void SetUpTest()
{
var rand = new Random();
_randList = Enumerable.Range(1, 10000).Select(_ => rand.Next()).ToList();
}
[TestCase]
public void Listは追加順を保つ()
{
var sut = new List<int>();
_randList.ForEach(sut.Add);
sut.Is(_randList);
}
[TestCase]
public void SortedListは追加順を保たない()
{
var sut = new SortedList<Guid,int>();
_randList.ForEach(_ => sut.Add(Guid.NewGuid(),_));
sut.Values.Is(_randList); //Fail
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment