示例#1
0
        public void TestShiftingIndex(int index, TextIndex.IndexState state, int shifting, int actualIndex, TextIndex.IndexState actualState)
        {
            var textIndex       = new TextIndex(index, state);
            var actualTextIndex = new TextIndex(actualIndex, actualState);

            Assert.AreEqual(TextIndexUtils.ShiftingIndex(textIndex, shifting), actualTextIndex);
        }
        public void TestDeserialize(string json, int index, TextIndex.IndexState state, int?time)
        {
            var result = JsonConvert.DeserializeObject <TimeTag>($"\"{json}\"", CreateSettings());
            var actual = new TimeTag(new TextIndex(index, state), time);

            Assert.AreEqual(result?.Index, actual.Index);
            Assert.AreEqual(result?.Time, actual.Time);
        }
        public void TestSerialize(int index, TextIndex.IndexState state, int?time, string json)
        {
            var timeTag = new TimeTag(new TextIndex(index, state), time);

            var result = JsonConvert.SerializeObject(timeTag, CreateSettings());

            Assert.AreEqual(result, $"\"{json}\"");
        }
        [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));
            }
        }
示例#5
0
        public void TestPositionFormattedString(int index, TextIndex.IndexState state, string actual)
        {
            var textIndex = new TextIndex(index, state);

            Assert.AreEqual(TextIndexUtils.PositionFormattedString(textIndex), actual);
        }
示例#6
0
        public void TestOutOfRange(int index, TextIndex.IndexState state, string lyric, bool outOfRange)
        {
            var textIndex = new TextIndex(index, state);

            Assert.AreEqual(TextIndexUtils.OutOfRange(textIndex, lyric), outOfRange);
        }
示例#7
0
 public void TestReverseState(TextIndex.IndexState state, TextIndex.IndexState actualState)
 {
     Assert.AreEqual(TextIndexUtils.ReverseState(state), actualState);
 }
示例#8
0
        [TestCase(0, true, -1, TextIndex.IndexState.End)] // In utils not checking is index out of range
        public void TestFromStringIndex(int textindex, bool end, int actualIndex, TextIndex.IndexState actualState)
        {
            var actualTextIndex = new TextIndex(actualIndex, actualState);

            Assert.AreEqual(TextIndexUtils.FromStringIndex(textindex, end), actualTextIndex);
        }
示例#9
0
        public void TestToStringIndex(int index, TextIndex.IndexState state, int actualIndex)
        {
            var textIndex = new TextIndex(index, state);

            Assert.AreEqual(TextIndexUtils.ToStringIndex(textIndex), actualIndex);
        }
示例#10
0
 public static TextIndex.IndexState ReverseState(TextIndex.IndexState state)
 {
     return(state == TextIndex.IndexState.Start ? TextIndex.IndexState.End : TextIndex.IndexState.Start);
 }