public void ListRemove(T[] inputs) { var list = new SelfList <T>(); foreach (var input in inputs) { list.Add(input); } var rnd = new Random(list.Count); int i = rnd.Next(list.Count); list.Remove(inputs[i]); int index = 0; foreach (var output in list.GetAll()) { if (index == i) { index++; } Assert.AreEqual(inputs[index], output); Console.WriteLine($"{inputs[index]},{output}"); index++; } }
public void ListAdd(T[] inputs) { var list = new SelfList <T>(); foreach (var input in inputs) { list.Add(input); } foreach (var(output, index) in list.GetAll().Select((output, index) => (output, index))) { Assert.AreEqual(inputs[index], output); Console.WriteLine($"{inputs[index]},{output}"); } }
public void ListException(T[] inputs) { var list = new SelfList <T>(); foreach (var input in inputs) { list.Add(input); } Assert.That(() => { foreach (var(output, index) in list.GetAll().Select((output, index) => (output, index))) { list.Add(inputs[0]); } }, Throws.Exception.With.Message.EqualTo("列挙中にリストが変更されました。")); }