public void TestDeserialize(string json, int startIndex, int endIndex, string text)
        {
            var result = JsonConvert.DeserializeObject <RubyTag>($"\"{json}\"", CreateSettings());
            var actual = new RubyTag
            {
                StartIndex = startIndex,
                EndIndex   = endIndex,
                Text       = text
            };

            TextTagAssert.ArePropertyEqual(result, actual);
        }
        public void TestSerialize(int startIndex, int endIndex, string text, string json)
        {
            var rubyTag = new RubyTag
            {
                StartIndex = startIndex,
                EndIndex   = endIndex,
                Text       = text
            };

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

            Assert.AreEqual(result, $"\"{json}\"");
        }
        protected CreateTextTagCaretPosition CreateCreateTextTagCaretPosition(Lyric[] lyrics, int lyricIndex, int startIndex, int endIndex)
        {
            if (lyricIndex == NOT_EXIST)
            {
                return(null);
            }

            var lyric = lyrics.ElementAtOrDefault(lyricIndex);

            // todo : need to able to switch between ruby or romaji.
            var textTag = new RubyTag
            {
                StartIndex = startIndex,
                EndIndex   = endIndex,
                Text       = "ルビ"
            };

            return(new CreateTextTagCaretPosition(lyric, textTag));
        }
Esempio n. 4
0
        public void TestAtTagDecode(string rubyTagText, string parent, string ruby)
        {
            // Ruby tag
            var rubyTag = new RubyTag
            {
                Parent = parent,
                Ruby   = ruby
            };

            // Ruby tag component
            var atRubyTagComponent = new RubyTagParserComponent(null);
            var atTag = atRubyTagComponent.Encode(rubyTag);

            // At tag component
            var atTagComponent = new AtTagParserComponent();
            var result         = atTagComponent.Encode(atTag);

            Assert.AreEqual(result, rubyTagText);
        }