Created
November 9, 2012 16:51
-
-
Save posaunehm/4046798 to your computer and use it in GitHub Desktop.
ListとSortedListの挙動の違いを確認する。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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