TestingHelpData.cs
9.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
using System.Collections.Generic;
namespace Unity.PlasticSCM.Editor.Help
{
internal static class TestingHelpData
{
internal static HelpData GetSample1()
{
HelpData result = new HelpData();
result.CleanText = "There are some .private files" + System.Environment.NewLine + System.Environment.NewLine +
"Do not panic, these are copies Plastic creates to preserve files it can't overwrite." + System.Environment.NewLine + System.Environment.NewLine +
"Suppose you have a private file \"src / foo.c\", then switch your workspace to a branch where someone added \"src / foo.c\". Plastic downloads the new file because it is under source control and yours is not. But, it can't delete yours, so it renames it as .private.0." + System.Environment.NewLine + System.Environment.NewLine +
"Makes sense?" + System.Environment.NewLine + System.Environment.NewLine +
"Learn more:" + System.Environment.NewLine +
"* You have some files ready to be added to version control" + System.Environment.NewLine +
"* Are you missing any changes?" + System.Environment.NewLine +
"* Tips to work with Visual Studio projects." + System.Environment.NewLine + System.Environment.NewLine +
"This is just text after links (like this help link -> content2) to verify that the format is preserved." + System.Environment.NewLine + System.Environment.NewLine +
"And then that another link at the end works, with some bold text at the end, final!!";
// IMPORTANT! We need single EOL chars to calculate the positions,
// otherwise positions are wrong calculated
result.CleanText = result.CleanText.Replace("\r\n", "\n");
result.FormattedBlocks = new List<HelpFormat>();
result.FormattedBlocks.Add(new HelpFormat()
{
Type = HelpFormat.FormatType.Title,
Position = 0,
Length = 29
});
result.FormattedBlocks.Add(new HelpFormat()
{
Type = HelpFormat.FormatType.Bold,
Position = result.CleanText.IndexOf("not panic"),
Length = "not panic".Length
});
result.FormattedBlocks.Add(new HelpFormat()
{
Type = HelpFormat.FormatType.Underline,
Position = result.CleanText.IndexOf("overwrite"),
Length = "overwrite".Length
});
result.FormattedBlocks.Add(new HelpFormat()
{
Type = HelpFormat.FormatType.Bold,
Position = result.CleanText.IndexOf("Makes sense?"),
Length = "Makes sense?".Length
});
result.Links = new List<HelpLink>();
result.Links.Add(new HelpLink()
{
Position = result.CleanText.IndexOf("You have some files ready to be added to version control"),
Length = "You have some files ready to be added to version control".Length,
Link = HelpLinkData.AsString(HelpLink.LinkType.Action, "plasticscm-pendingchanges-filestoadd")
});
result.Links.Add(new HelpLink()
{
Position = result.CleanText.IndexOf("Are you missing any changes?"),
Length = "Are you missing any changes?".Length,
Link = HelpLinkData.AsString(HelpLink.LinkType.Action, "plasticscm-pendingchanges-missingchanges")
});
result.Links.Add(new HelpLink()
{
Position = result.CleanText.IndexOf("Tips to work with Visual Studio projects."),
Length = "Tips to work with Visual Studio projects.".Length,
Link = HelpLinkData.AsString(HelpLink.LinkType.Action, "plasticscm-pendingchanges-visualstudio")
});
result.FormattedBlocks.Add(new HelpFormat()
{
Type = HelpFormat.FormatType.Bold,
Position = result.CleanText.IndexOf("verify that the format is preserved"),
Length = "verify that the format is preserved".Length
});
result.Links.Add(new HelpLink()
{
Position = result.CleanText.IndexOf("this help link"),
Length = "this help link".Length,
Link = HelpLinkData.AsString(HelpLink.LinkType.Help, "sample2")
});
result.Links.Add(new HelpLink()
{
Position = result.CleanText.IndexOf("another link at the end"),
Length = "another link at the end".Length,
Link = HelpLinkData.AsString(HelpLink.LinkType.Link, "https://www.google.com")
});
result.FormattedBlocks.Add(new HelpFormat()
{
Type = HelpFormat.FormatType.Bold,
Position = result.CleanText.IndexOf("bold text at the end"),
Length = "bold text at the end".Length
});
return result;
}
internal static HelpData GetSample2()
{
HelpData result = new HelpData();
result.CleanText = "Alternative title to confirm that all is working" + System.Environment.NewLine + System.Environment.NewLine +
"This is just another help example to ensure that the panel replaces the helps dynamically." + System.Environment.NewLine + System.Environment.NewLine +
"If you're reading this text, means that the help changed its content dynamically, so we can navigate between help tips by clicking hyperlinks" + System.Environment.NewLine + System.Environment.NewLine +
"Makes sense?" + System.Environment.NewLine + System.Environment.NewLine +
"Learn more:" + System.Environment.NewLine +
"* You have some files ready to be added to version control" + System.Environment.NewLine +
"* Are you missing any changes?" + System.Environment.NewLine +
"* Tips to work with Visual Studio projects." + System.Environment.NewLine + System.Environment.NewLine +
"This is just text after links (like this help link -> content1) to verify that the format is preserved.";
// IMPORTANT! We need single EOL chars to calculate the positions,
// otherwise positions are wrong calculated
result.CleanText = result.CleanText.Replace("\r\n", "\n");
result.FormattedBlocks = new List<HelpFormat>();
result.FormattedBlocks.Add(new HelpFormat()
{
Type = HelpFormat.FormatType.Title,
Position = 0,
Length = "Alternative title to confirm that all is working".Length
});
result.FormattedBlocks.Add(new HelpFormat()
{
Type = HelpFormat.FormatType.Bold,
Position = result.CleanText.IndexOf("replaces the helps dynamically"),
Length = "replaces the helps dynamically".Length
});
result.Links = new List<HelpLink>();
result.Links.Add(new HelpLink()
{
Position = result.CleanText.IndexOf("You have some files ready to be added to version control"),
Length = "You have some files ready to be added to version control".Length,
Link = HelpLinkData.AsString(HelpLink.LinkType.Action, "plasticscm-pendingchanges-filestoadd")
});
result.Links.Add(new HelpLink()
{
Position = result.CleanText.IndexOf("Are you missing any changes?"),
Length = "Are you missing any changes?".Length,
Link = HelpLinkData.AsString(HelpLink.LinkType.Action, "plasticscm-pendingchanges-missingchanges")
});
result.Links.Add(new HelpLink()
{
Position = result.CleanText.IndexOf("Tips to work with Visual Studio projects."),
Length = "Tips to work with Visual Studio projects.".Length,
Link = HelpLinkData.AsString(HelpLink.LinkType.Action, "plasticscm-pendingchanges-visualstudio")
});
result.Links.Add(new HelpLink()
{
Position = result.CleanText.IndexOf("this help link"),
Length = "this help link".Length,
Link = HelpLinkData.AsString(HelpLink.LinkType.Help, "sample1")
});
return result;
}
class HelpLinkData
{
internal static string AsString(HelpLink.LinkType linkType, string linkContent)
{
string linkTypeString = string.Empty;
switch (linkType)
{
case HelpLink.LinkType.Action:
linkTypeString = ACTION;
break;
case HelpLink.LinkType.Help:
linkTypeString = HELP;
break;
case HelpLink.LinkType.Link:
linkTypeString = LINK;
break;
}
return string.Concat(linkTypeString, SEPARATOR, linkContent);
}
const string ACTION = "action";
const string HELP = "help";
const string LINK = "link";
const string SEPARATOR = ":";
}
}
}