forked from synchrok/TypeText
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup state in TextTyper printing (issue #2)
This adds a TypedTextGenerator that provides a pure function to return the print string at a desired place in a line of dialogue. This resolves some of the issues I had with mishandled state, namely issue #7 and issue #5.
- Loading branch information
1 parent
117d0b0
commit 3cba8b0
Showing
11 changed files
with
1,284 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 56 additions & 54 deletions
110
Assets/RedBlueGames/TextTyper/Tests/Editor/RichTextTagTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,60 @@ | ||
using UnityEngine; | ||
using UnityEditor; | ||
using NUnit.Framework; | ||
using RedBlueGames.Tools.TextTyper; | ||
|
||
public class RichTextTagTests | ||
namespace RedBlueGames.Tools.TextTyper.Tests | ||
{ | ||
[Test] | ||
public void Constructor_OpeningTag_Parses() | ||
{ | ||
//Arrange | ||
var tag = "<b>"; | ||
|
||
//Act | ||
var richTextTag = new RichTextTag(tag); | ||
|
||
//Assert | ||
Assert.AreEqual(tag, richTextTag.TagText); | ||
Assert.AreEqual("b", richTextTag.TagType); | ||
Assert.IsFalse(richTextTag.IsClosingTag); | ||
Assert.AreEqual("</b>", richTextTag.ClosingTagText); | ||
Assert.AreEqual(string.Empty, richTextTag.Parameter); | ||
} | ||
|
||
[Test] | ||
public void Constructor_TagAndParameter_Parses() | ||
{ | ||
//Arrange | ||
var tag = "<color=#FFFFFFFF>"; | ||
|
||
//Act | ||
var richTextTag = new RichTextTag(tag); | ||
|
||
//Assert | ||
Assert.AreEqual(tag, richTextTag.TagText); | ||
Assert.AreEqual("color", richTextTag.TagType); | ||
Assert.IsFalse(richTextTag.IsClosingTag); | ||
Assert.AreEqual("</color>", richTextTag.ClosingTagText); | ||
Assert.AreEqual("#FFFFFFFF", richTextTag.Parameter); | ||
} | ||
using UnityEngine; | ||
using UnityEditor; | ||
using NUnit.Framework; | ||
|
||
[Test] | ||
public void Constructor_ClosingTag_Parses() | ||
public class RichTextTagTests | ||
{ | ||
//Arrange | ||
var tag = "</color>"; | ||
|
||
//Act | ||
var richTextTag = new RichTextTag(tag); | ||
|
||
//Assert | ||
Assert.AreEqual(tag, richTextTag.TagText); | ||
Assert.AreEqual("color", richTextTag.TagType); | ||
Assert.IsTrue(richTextTag.IsClosingTag); | ||
Assert.AreEqual("</color>", richTextTag.ClosingTagText); | ||
Assert.AreEqual(string.Empty, richTextTag.Parameter); | ||
[Test] | ||
public void Constructor_OpeningTag_Parses() | ||
{ | ||
//Arrange | ||
var tag = "<b>"; | ||
|
||
//Act | ||
var richTextTag = new RichTextTag(tag); | ||
|
||
//Assert | ||
Assert.AreEqual(tag, richTextTag.TagText); | ||
Assert.AreEqual("b", richTextTag.TagType); | ||
Assert.IsFalse(richTextTag.IsClosingTag); | ||
Assert.AreEqual("</b>", richTextTag.ClosingTagText); | ||
Assert.AreEqual(string.Empty, richTextTag.Parameter); | ||
} | ||
|
||
[Test] | ||
public void Constructor_TagAndParameter_Parses() | ||
{ | ||
//Arrange | ||
var tag = "<color=#FFFFFFFF>"; | ||
|
||
//Act | ||
var richTextTag = new RichTextTag(tag); | ||
|
||
//Assert | ||
Assert.AreEqual(tag, richTextTag.TagText); | ||
Assert.AreEqual("color", richTextTag.TagType); | ||
Assert.IsFalse(richTextTag.IsClosingTag); | ||
Assert.AreEqual("</color>", richTextTag.ClosingTagText); | ||
Assert.AreEqual("#FFFFFFFF", richTextTag.Parameter); | ||
} | ||
|
||
[Test] | ||
public void Constructor_ClosingTag_Parses() | ||
{ | ||
//Arrange | ||
var tag = "</color>"; | ||
|
||
//Act | ||
var richTextTag = new RichTextTag(tag); | ||
|
||
//Assert | ||
Assert.AreEqual(tag, richTextTag.TagText); | ||
Assert.AreEqual("color", richTextTag.TagType); | ||
Assert.IsTrue(richTextTag.IsClosingTag); | ||
Assert.AreEqual("</color>", richTextTag.ClosingTagText); | ||
Assert.AreEqual(string.Empty, richTextTag.Parameter); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.