예제 #1
0
        public void TestCheckIsEndTimeInvalid(string lyricText, string[] timeTags, bool actual)
        {
            var lyric = TestCaseTagHelper.ParseLyric(lyricText);

            lyric.TimeTags = TestCaseTagHelper.ParseTimeTags(timeTags);
            Assert.AreEqual(LyricUtils.CheckIsEndTimeInvalid(lyric), actual);
        }
예제 #2
0
        public void TestGetEndTime(string[] timeTagTexts, double?actualEndTime)
        {
            var timeTags = TestCaseTagHelper.ParseTimeTags(timeTagTexts);
            var endTime  = TimeTagsUtils.GetEndTime(timeTags);

            Assert.AreEqual(endTime, actualEndTime);
        }
예제 #3
0
        public void TestGetTimeTagDisplayRubyText(int indexOfTimeTag, string actual)
        {
            var lyric = new Lyric
            {
                Text     = "カラオケ",
                TimeTags = TestCaseTagHelper.ParseTimeTags(new[]
                {
                    "[0,start]:1000",
                    "[0,start]:1000",
                    "[0,end]:1000",
                    "[1,start]:2000",
                    "[1,start]:2000",
                    "[1,end]:2000",
                    "[2,start]:3000",
                    "[2,start]:3000",
                    "[3,start]:4000",
                    "[3,end]:5000",
                }),
                RubyTags = TestCaseTagHelper.ParseRubyTags(new[]
                {
                    "[0,1]:か",
                    "[2,4]:おけ",
                })
            };
            var timeTag = lyric.TimeTags[indexOfTimeTag];

            Assert.AreEqual(LyricUtils.GetTimeTagDisplayRubyText(lyric, timeTag), actual);
        }
예제 #4
0
        //[TestCase(new[] { "[0,start]:4000", "[0,end]:3000", "[1,start]:2000", "[1,end]:1000" }, new double[] { 4000, 4000, 4000, 4000 })]
        public void TestToDictionary(string[] timeTagTexts, double[] actualTimes)
        {
            var timeTags   = TestCaseTagHelper.ParseTimeTags(timeTagTexts);
            var dictionary = TimeTagsUtils.ToDictionary(timeTags);

            Assert.AreEqual(dictionary.Values.ToArray(), actualTimes);
        }
예제 #5
0
        public void TestSort(string[] timeTagTexts, string[] actualTimeTags)
        {
            var timeTags      = TestCaseTagHelper.ParseTimeTags(timeTagTexts);
            var sortedTimeTag = TimeTagsUtils.Sort(timeTags);

            TimeTagAssert.AreEqual(sortedTimeTag, TestCaseTagHelper.ParseTimeTags(actualTimeTags));
        }
예제 #6
0
        public void TestFindOutOfRange(string text, string[] timeTagTexts, string[] invalidTimeTags)
        {
            var timeTags           = TestCaseTagHelper.ParseTimeTags(timeTagTexts);
            var outOfRangeTimeTags = TimeTagsUtils.FindOutOfRange(timeTags, text);

            TimeTagAssert.AreEqual(outOfRangeTimeTags, TestCaseTagHelper.ParseTimeTags(invalidTimeTags));
        }
예제 #7
0
        [TestCase("", new[] { "[0,start]:1000", "[0,end]:2000" }, false)]      // empty lyric should always count as missing.
        public void TestHasStartTimeTagInLyric(string text, string[] timeTagTexts, bool actual)
        {
            var timeTags = TestCaseTagHelper.ParseTimeTags(timeTagTexts);
            var missing  = TimeTagsUtils.HasStartTimeTagInLyric(timeTags, text);

            Assert.AreEqual(missing, actual);
        }
예제 #8
0
        //[TestCase(new[] { "[0,start]:4000", "[0,end]:3000", "[1,start]:2000", "[1,end]:1000" }, GroupCheck.Asc, SelfCheck.BasedOnStart, new double[] { "[0,start]:4000", "[0,end]:4000", "[1,start]:4000", "[1,end]:4000" })]
        //[TestCase(new[] { "[0,start]:4000", "[0,end]:3000", "[1,start]:2000", "[1,end]:1000" }, GroupCheck.Asc, SelfCheck.BasedOnEnd, new double[] { "[0,start]:3000", "[0,end]:3000", "[1,start]:3000", "[1,end]:3000" })]
        //[TestCase(new[] { "[0,start]:4000", "[0,end]:3000", "[1,start]:2000", "[1,end]:1000" }, GroupCheck.Desc, SelfCheck.BasedOnStart, new double[] { "[0,start]:2000", "[0,end]:2000", "[1,start]:2000", "[1,end]:2000" })]
        //[TestCase(new[] { "[0,start]:4000", "[0,end]:3000", "[1,start]:2000", "[1,end]:1000" }, GroupCheck.Desc, SelfCheck.BasedOnEnd, new double[] { "[0,start]:1000", "[0,end]:1000", "[1,start]:1000", "[1,end]:1000" })]
        public void TestFixInvalid(string[] timeTagTexts, GroupCheck other, SelfCheck self, string[] actualTimeTagTexts)
        {
            // check which part is fixed, using list of time to check result.
            var timeTags     = TestCaseTagHelper.ParseTimeTags(timeTagTexts);
            var fixedTimeTag = TimeTagsUtils.FixInvalid(timeTags, other, self);

            TimeTagAssert.AreEqual(fixedTimeTag, TestCaseTagHelper.ParseTimeTags(actualTimeTagTexts));
        }
예제 #9
0
        public void TestTimeTagTimeFormattedString(string[] timeTags, string format)
        {
            var lyric = new Lyric
            {
                TimeTags = TestCaseTagHelper.ParseTimeTags(timeTags),
            };

            Assert.AreEqual(LyricUtils.TimeTagTimeFormattedString(lyric), format);
        }
예제 #10
0
        public void TestFindInvalid(string[] timeTagTexts, GroupCheck other, SelfCheck self, int[] errorIndex)
        {
            // run all and find invalid indexes.
            var timeTags       = TestCaseTagHelper.ParseTimeTags(timeTagTexts);
            var invalidTimeTag = TimeTagsUtils.FindInvalid(timeTags, other, self);
            var invalidIndexes = invalidTimeTag.Select(v => timeTags.IndexOf(v)).ToArray();

            Assert.AreEqual(invalidIndexes, errorIndex);
        }
예제 #11
0
        public void TestFindOverlapping(string[] timeTagTexts, GroupCheck other, SelfCheck self, int[] errorIndex)
        {
            // run all and find overlapping indexes.
            var timeTags                  = TestCaseTagHelper.ParseTimeTags(timeTagTexts);
            var overlappingTimeTags       = TimeTagsUtils.FindOverlapping(timeTags, other, self);
            var overlappingTimeTagIndexed = overlappingTimeTags.Select(v => timeTags.IndexOf(v)).ToArray();

            Assert.AreEqual(overlappingTimeTagIndexed, errorIndex);
        }
예제 #12
0
        public void TestHasTimedTimeTags(string[] timeTags, bool hasTimedTimeTag)
        {
            var lyric = new Lyric
            {
                Text     = "カラオケ",
                TimeTags = TestCaseTagHelper.ParseTimeTags(timeTags),
            };

            Assert.AreEqual(LyricUtils.HasTimedTimeTags(lyric), hasTimedTimeTag);
        }
예제 #13
0
        public void TestLyricTimeTag(string text, string[] timeTags)
        {
            var beatmap = decodeLrcLine(text);

            // Get first lyric from beatmap
            var lyric = beatmap.HitObjects.OfType <Lyric>().FirstOrDefault();

            // Check time tag
            TimeTagAssert.ArePropertyEqual(lyric?.TimeTags, TestCaseTagHelper.ParseTimeTags(timeTags));
        }
예제 #14
0
        public void TestCheckInvalidLyricTime(string lyricText, string[] timeTags, TimeInvalid[] invalid)
        {
            var lyric = TestCaseTagHelper.ParseLyric(lyricText);

            lyric.TimeTags = TestCaseTagHelper.ParseTimeTags(timeTags);

            var checker = createChecker();
            var result  = checker.CheckInvalidLyricTime(lyric);

            Assert.AreEqual(result, invalid);
        }
예제 #15
0
        protected void RunTimeTagCheckTest(Lyric lyric, string[] actualTimeTags, TConfig config)
        {
            var generator = Activator.CreateInstance(typeof(TTimeTagGenerator), config) as TTimeTagGenerator;

            // create time tag and actually time tag.
            var timeTags      = generator?.CreateTimeTags(lyric);
            var actualIndexed = TestCaseTagHelper.ParseTimeTags(actualTimeTags);

            // check should be equal
            TimeTagAssert.AreEqual(timeTags, actualIndexed);
        }
예제 #16
0
        public void TestAddTextTimeTag(string[] timeTags, int position, string addedText, string[] actualTimeTags)
        {
            var lyric = new Lyric
            {
                Text     = "カラオケ",
                TimeTags = TestCaseTagHelper.ParseTimeTags(timeTags),
            };

            LyricUtils.AddText(lyric, position, addedText);
            TimeTagAssert.ArePropertyEqual(lyric.TimeTags, TestCaseTagHelper.ParseTimeTags(actualTimeTags));
        }
예제 #17
0
        public void TestRemoveTextTimeTag(string[] timeTags, int position, int count, string[] actualTimeTags)
        {
            var lyric = new Lyric
            {
                Text     = "カラオケ",
                TimeTags = TestCaseTagHelper.ParseTimeTags(timeTags),
            };

            LyricUtils.RemoveText(lyric, position, count);
            TimeTagAssert.AreEqual(lyric.TimeTags, TestCaseTagHelper.ParseTimeTags(actualTimeTags));
        }
        public void TestCheckInvalidLyricTime(string lyricText, string[] timeTags, TimeInvalid[] invalid)
        {
            var lyric = TestCaseTagHelper.ParseLyric(lyricText);

            lyric.TimeTags = TestCaseTagHelper.ParseTimeTags(timeTags);

            var issue = run(lyric).OfType <LyricTimeIssue>().FirstOrDefault();
            var invalidTimeTagDictionaryKeys = issue?.InvalidLyricTime ?? Array.Empty <TimeInvalid>();

            Assert.AreEqual(invalidTimeTagDictionaryKeys, invalid);
        }
예제 #19
0
        [TestCase(3081, "hello", null)]               // English
        public void TestCreateTimeTag(int lcid, string text, string[] actualTimeTag)
        {
            var lyric = new Lyric
            {
                Language = new CultureInfo(lcid),
                Text     = text,
            };
            var selector          = new TimeTagGeneratorSelector();
            var generatedTimeTags = selector.GenerateTimeTags(lyric);

            TimeTagAssert.AreEqual(generatedTimeTags, TestCaseTagHelper.ParseTimeTags(actualTimeTag));
        }
예제 #20
0
        public void TestSeparateLyricTimeTag(string text, string[] timeTags, int splitIndex, string[] firstTimeTags, string[] secondTimeTags)
        {
            var lyric = new Lyric
            {
                Text     = text,
                TimeTags = TestCaseTagHelper.ParseTimeTags(timeTags)
            };

            var(firstLyric, secondLyric) = LyricsUtils.SplitLyric(lyric, splitIndex);

            TimeTagAssert.AreEqual(firstLyric.TimeTags, TestCaseTagHelper.ParseTimeTags(firstTimeTags));
            TimeTagAssert.AreEqual(secondLyric.TimeTags, TestCaseTagHelper.ParseTimeTags(secondTimeTags));
        }
예제 #21
0
        public void TestCheckInvalidTimeTags(string text, string[] timeTags, TimeTagInvalid[] invalids)
        {
            var lyric = new Lyric
            {
                Text     = text,
                TimeTags = TestCaseTagHelper.ParseTimeTags(timeTags)
            };

            var checker = createChecker();
            var result  = checker.CheckInvalidTimeTags(lyric);

            Assert.AreEqual(result.Keys.ToArray(), invalids);
        }
        public void TestCheckInvalidTimeTags(string text, string[] timeTags, TimeTagInvalid[] invalids)
        {
            var lyric = new Lyric
            {
                Text     = text,
                TimeTags = TestCaseTagHelper.ParseTimeTags(timeTags)
            };

            var issue = run(lyric).OfType <TimeTagIssue>().FirstOrDefault();
            var invalidTimeTagDictionaryKeys = issue?.InvalidTimeTags.Keys.ToArray() ?? Array.Empty <TimeTagInvalid>();

            Assert.AreEqual(invalidTimeTagDictionaryKeys, invalids);
        }
예제 #23
0
        public void TestCreateNotes(string[] timeTags, string[] noteTexts)
        {
            var lyric = new Lyric
            {
                Text     = "カラオケ",
                TimeTags = TestCaseTagHelper.ParseTimeTags(timeTags),
            };

            var generator = new NoteGenerator(new NoteGeneratorConfig());
            var notes     = generator.CreateNotes(lyric);

            //var notes = LyricUtils.CreateDefaultNotes(lyric);
            Assert.AreEqual(notes.Select(x => x.Text).ToArray(), noteTexts);
        }
        public void TestCheckMissingStartEndTimeTag(string text, string[] timeTags, bool missingStartTimeTag, bool missingEndTimeTag)
        {
            var lyric = new Lyric
            {
                Text     = text,
                TimeTags = TestCaseTagHelper.ParseTimeTags(timeTags)
            };

            var issue = run(lyric).OfType <TimeTagIssue>().FirstOrDefault();

            if (issue == null)
            {
                Assert.IsFalse(missingStartTimeTag);
                Assert.IsFalse(missingEndTimeTag);
            }
            else
            {
                Assert.AreEqual(issue.MissingStartTimeTag, missingStartTimeTag);
                Assert.AreEqual(issue.MissingEndTimeTag, missingEndTimeTag);
            }
        }
예제 #25
0
        [TestCase(new[] { "[-1,start]:" }, new[] { "[-1,start]:" }, new[] { "[-1,start]:", "[6,start]:" })]                // deal with the case with not invalid time tag position.
        public void TestCombineLyricTimeTag(string[] firstTimeTags, string[] secondTimeTags, string[] actualTimeTags)
        {
            var lyric1 = new Lyric
            {
                Text     = "karaoke",
                TimeTags = TestCaseTagHelper.ParseTimeTags(firstTimeTags)
            };
            var lyric2 = new Lyric
            {
                Text     = "karaoke",
                TimeTags = TestCaseTagHelper.ParseTimeTags(secondTimeTags)
            };

            var combineLyric = LyricsUtils.CombineLyric(lyric1, lyric2);
            var timeTags     = combineLyric.TimeTags;

            for (int i = 0; i < timeTags.Length; i++)
            {
                var actualTimeTag = TestCaseTagHelper.ParseTimeTag(actualTimeTags[i]);
                Assert.AreEqual(timeTags[i].Index, actualTimeTag.Index);
                Assert.AreEqual(timeTags[i].Time, actualTimeTag.Time);
            }
        }