public void CleanVoteLine_LongSamplePartialColors() { string line = "[X] - Brutalize them. You haven’t had a chance to properly fight in 『/color』『i』『color=#ebebeb』years『/color』『/i』『color=#ebebeb』, and spars can only do so much. How thoughtful of the Herans to volunteer!"; string cleanLine = "[X] - Brutalize them. You haven’t had a chance to properly fight in 『i』『color=#ebebeb』years『/color』『/i』, and spars can only do so much. How thoughtful of the Herans to volunteer!"; Assert.AreEqual(cleanLine, VoteString.CleanVoteLineBBCode(line)); }
public void CleanVoteLine_InMarkerPlus() { string line = "-『b』[『b』x][Who『/b』] 『b』Vote『/b』 for stuff『/b』"; string cleanLine = "-[x][Who] 『b』Vote『/b』 for stuff"; Assert.AreEqual(cleanLine, VoteString.CleanVoteLineBBCode(line)); }
public void CleanVoteLine_ColorMarkerPlus() { string line = "『color=blue』[x]『/color』[main] 『b』『b』Vote『/b』 for stuff"; string cleanLine = "[x][main] 『b』Vote『/b』 for stuff"; Assert.AreEqual(cleanLine, VoteString.CleanVoteLineBBCode(line)); }
public void CleanVoteLine_TaskMarkup() { string line = "-[x][『b』Who『/b』] Vote for stuff"; string cleanLine = "-[x][Who] Vote for stuff"; Assert.AreEqual(cleanLine, VoteString.CleanVoteLineBBCode(line)); }
public void CleanVoteLine_NestedTaskMarkup() { string line = "-[x][『color=#15fae6』『b』Who『/b』『/color』] Vote for stuff"; string cleanLine = "-[x][Who] Vote for stuff"; Assert.AreEqual(cleanLine, VoteString.CleanVoteLineBBCode(line)); }
public void CleanVoteLine_ItalicsInContent() { string line = "[x] 『i』Vote『/i』 for stuff"; string cleanLine = "[x] 『i』Vote『/i』 for stuff"; Assert.AreEqual(cleanLine, VoteString.CleanVoteLineBBCode(line)); }
public void CleanVoteLine_NestedCodes() { string line = "[x] 『b』『i』Vote『/i』 for stuff『/b』"; string cleanLine = "[x] 『b』『i』Vote『/i』 for stuff『/b』"; Assert.AreEqual(cleanLine, VoteString.CleanVoteLineBBCode(line)); }
public void CleanVoteLine_FullLineBoldPreTask() { string line = "-[x]『b』[Who] Vote for stuff『/b』"; string cleanLine = "-[x][Who] Vote for stuff"; Assert.AreEqual(cleanLine, VoteString.CleanVoteLineBBCode(line)); }
public void CleanVoteLine_FullLineBold() { string line = "『b』[x] Vote for stuff『/b』"; string cleanLine = "[x] Vote for stuff"; Assert.AreEqual(cleanLine, VoteString.CleanVoteLineBBCode(line)); }
public void CleanVoteLine_NoBBCode() { string line = "[x] Vote for stuff"; string cleanLine = "[x] Vote for stuff"; Assert.AreEqual(cleanLine, VoteString.CleanVoteLineBBCode(line)); }
/// <summary> /// Initializes a new instance of the <see cref="VoteLine"/> class. /// Constructs the components out of the provided text line. /// </summary> /// <param name="textLine">The text line.</param> /// <exception cref="ArgumentNullException">Parameter is null.</exception> public VoteLine(string textLine) { if (string.IsNullOrEmpty(textLine)) { throw new ArgumentNullException(nameof(textLine)); } Text = VoteString.CleanVoteLineBBCode(textLine); DecomposeVoteLine(Text); }
public void CleanVoteLine_Color() { string line = "[x] 『color=blue』Vote for stuff『/color』"; string cleanLine = "[x] 『color=blue』Vote for stuff『/color』"; Assert.AreEqual(cleanLine, VoteString.CleanVoteLineBBCode(line)); line = "[x] 『color=#15fae6』Vote for stuff『/color』"; cleanLine = "[x] 『color=#15fae6』Vote for stuff『/color』"; Assert.AreEqual(cleanLine, VoteString.CleanVoteLineBBCode(line)); }
/// <summary> /// Constructor /// </summary> /// <param name="author">The author of the post.</param> /// <param name="id">The ID (string) of the post.</param> /// <param name="text">The text contents of the post.</param> public PostComponents(string author, string id, string text, int number = 0, IQuest quest = null) { if (string.IsNullOrEmpty(author)) { throw new ArgumentNullException(nameof(author)); } if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException(nameof(id)); } Text = text ?? throw new ArgumentNullException(nameof(text)); Author = author; ID = id; Number = number; if (int.TryParse(id, out int idnum)) { IDValue = idnum; } else { IDValue = 0; } if (IsTallyPost(text)) { return; } var lines = text.GetStringLines(); var voteLines = lines.Where(a => voteLineRegex.Match(VoteString.RemoveBBCode(a)).Success); if (voteLines.Any()) { var selected = voteLines.Select(a => VoteString.CleanVoteLineBBCode(a)); if (quest != null && quest.TrimExtendedText) { selected = selected.Select(a => VoteString.ModifyLinesRead(a)); } VoteStrings = selected.Select(a => VoteString.CleanVoteLineBBCode(a)).ToList(); SeparateVoteStrings(VoteStrings); } else if (lines.All(a => nominationLineRegex.Match(a).Success)) { VoteStrings = lines.Select(a => $"[X] {nominationLineRegex.Match(a).Groups["username"].Value}").ToList(); SeparateVoteStrings(VoteStrings); } }
public void Time_VoteLine_Parsing_and_Construction() { using (var rp = new RegionProfiler("Warm up")) { } string input1, input2, input3, input4; string? line1, line2, line3, line4; string? prefix, marker, task, content; VoteLine?vote1, vote2, vote3, vote4; object o1, o2, o3, o4; input1 = "It depends, but the general trend is that it's easier once you've done it once. So, one day you're at 5 San and you killed a Witch by binding it's existence to a giant, abstract clock made of your own crystallized blood, dooming it to die when it strikes twelve."; input2 = "[X][Other] Ask about the time you \"met\" before. Make sure she remembers it."; input3 = "[X] Ask about the time you \"met\" before. Make sure she remembers it."; input4 = "[x][To Do?] 『b』A 『url='http://example.com/image.jpg'』normal『/url』 day at the beach.『/b』"; using (var rp = new RegionProfiler("Baseline with empty vote lines")) { for (int i = 0; i < 2500; i++) { o1 = VoteLine.Empty; o2 = VoteLine.Empty; o3 = VoteLine.Empty; o4 = VoteLine.Empty; } } using (var rp = new RegionProfiler("Time constructing vote lines")) { for (int i = 0; i < 2500; i++) { vote1 = new VoteLine("", "X", "", "Ask about the time you \"met\" before. Make sure she remembers it.", MarkerType.Vote, 100); vote2 = new VoteLine("", "X", "", "Ask about the time you \"met\" before. Make sure she remembers it.", MarkerType.Vote, 100); vote3 = new VoteLine("", "X", "", "Ask about the time you \"met\" before. Make sure she remembers it.", MarkerType.Vote, 100); vote4 = new VoteLine("", "X", "", "Ask about the time you \"met\" before. Make sure she remembers it.", MarkerType.Vote, 100); } } using (var rp = new RegionProfiler("Time parsing lines")) { for (int i = 0; i < 2500; i++) { vote1 = VoteLineParser.ParseLine(input1); vote2 = VoteLineParser.ParseLine(input2); vote3 = VoteLineParser.ParseLine(input3); vote4 = VoteLineParser.ParseLine(input4); } } using (var rp = new RegionProfiler("Time parsing strings")) { for (int i = 0; i < 2500; i++) { if (voteLineRegex.Match(VoteString.RemoveBBCode(input1)).Success) { line1 = VoteString.CleanVoteLineBBCode(input1); VoteString.GetVoteComponents(line1, out prefix, out marker, out task, out content); } if (voteLineRegex.Match(VoteString.RemoveBBCode(input2)).Success) { line2 = VoteString.CleanVoteLineBBCode(input2); VoteString.GetVoteComponents(line2, out prefix, out marker, out task, out content); } if (voteLineRegex.Match(VoteString.RemoveBBCode(input3)).Success) { line3 = VoteString.CleanVoteLineBBCode(input3); VoteString.GetVoteComponents(line3, out prefix, out marker, out task, out content); } if (voteLineRegex.Match(VoteString.RemoveBBCode(input4)).Success) { line4 = VoteString.CleanVoteLineBBCode(input4); VoteString.GetVoteComponents(line4, out prefix, out marker, out task, out content); } } } using (var rp = new RegionProfiler("Comparing parsed lines")) { vote1 = VoteLineParser.ParseLine(input1); vote2 = VoteLineParser.ParseLine(input2); vote3 = VoteLineParser.ParseLine(input3); vote4 = VoteLineParser.ParseLine(input4); for (int i = 0; i < 2500; i++) { if (vote1 == vote4 || vote2 == vote3) { o1 = new object(); } } } using (var rp = new RegionProfiler("Comparing parsed lines")) { if (voteLineRegex.Match(VoteString.RemoveBBCode(input1)).Success) { line1 = VoteString.CleanVoteLineBBCode(input1); } else { line1 = null; } if (voteLineRegex.Match(VoteString.RemoveBBCode(input2)).Success) { line2 = VoteString.CleanVoteLineBBCode(input2); } else { line2 = null; } if (voteLineRegex.Match(VoteString.RemoveBBCode(input3)).Success) { line3 = VoteString.CleanVoteLineBBCode(input3); } else { line3 = null; } if (voteLineRegex.Match(VoteString.RemoveBBCode(input4)).Success) { line4 = VoteString.CleanVoteLineBBCode(input4); } else { line4 = null; } for (int i = 0; i < 2500; i++) { if ( //Agnostic.StringComparer.Equals(VoteString.GetVoteContent(line1), VoteString.GetVoteContent(line2)) || Agnostic.StringComparer.Equals(VoteString.GetVoteContent(line3 !), VoteString.GetVoteContent(line4 !)) ) { o1 = new object(); } } } VoteLine vote = new VoteLine("", "", "", "", MarkerType.None, 0); Assert.AreEqual(VoteLine.Empty, vote); }