[TestCase(0, TextIndex.IndexState.Start, 3, 1, null)] // test switch value. public void TestClamp(int index, TextIndex.IndexState state, int minIndex, int maxIndex, int?actualIndex) { var textIndex = new TextIndex(index, state); if (actualIndex != null) { var actualTextIndex = new TextIndex(actualIndex.Value, state); Assert.AreEqual(TextIndexUtils.Clamp(textIndex, minIndex, maxIndex), actualTextIndex); } else { Assert.Throws <ArgumentException>(() => TextIndexUtils.Clamp(textIndex, minIndex, maxIndex)); } }