{
public class ApiLimitTest
{
- public static readonly TheoryData<object?, bool> Equals_TestCase = new TheoryData<object?, bool>
+ public static readonly TheoryData<object?, bool> EqualsTestCase = new TheoryData<object?, bool>
{
{ new ApiLimit(150, 100, new DateTimeUtc(2013, 1, 1, 0, 0, 0)), true },
{ new ApiLimit(350, 100, new DateTimeUtc(2013, 1, 1, 0, 0, 0)), false },
};
[Theory]
- [MemberData(nameof(Equals_TestCase))]
+ [MemberData(nameof(EqualsTestCase))]
public void EqualsTest(object? obj2, bool expected)
{
var obj1 = new ApiLimit(150, 100, new DateTimeUtc(2013, 1, 1, 0, 0, 0));
Assert.Equal(TwitterApiAccessLevel.Anonymous, apiStatus.AccessLevel);
}
- public static readonly TheoryData<Dictionary<string, string>, ApiLimit?> ParseRateLimit_TestCase = new TheoryData<Dictionary<string, string>, ApiLimit?>
+ public static readonly TheoryData<Dictionary<string, string>, ApiLimit?> ParseRateLimitTestCase = new TheoryData<Dictionary<string, string>, ApiLimit?>
{
{
new Dictionary<string, string> {
};
[Theory]
- [MemberData(nameof(ParseRateLimit_TestCase))]
+ [MemberData(nameof(ParseRateLimitTestCase))]
public void ParseRateLimitTest(IDictionary<string, string> header, ApiLimit? expected)
{
var limit = TwitterApiStatus.ParseRateLimit(header, "X-RateLimit-");
Assert.Equal(expected, limit);
}
- public static readonly TheoryData<Dictionary<string, string>, ApiLimit?> ParseMediaRateLimit_TestCase = new TheoryData<Dictionary<string, string>, ApiLimit?>
+ public static readonly TheoryData<Dictionary<string, string>, ApiLimit?> ParseMediaRateLimitTestCase = new TheoryData<Dictionary<string, string>, ApiLimit?>
{
{
new Dictionary<string, string> {
};
[Theory]
- [MemberData(nameof(ParseMediaRateLimit_TestCase))]
+ [MemberData(nameof(ParseMediaRateLimitTestCase))]
public void ParseMediaRateLimitTest(IDictionary<string, string> header, ApiLimit? expected)
{
var limit = TwitterApiStatus.ParseRateLimit(header, "X-MediaRateLimit-");
Assert.Equal(expected, limit);
}
- public static readonly TheoryData<Dictionary<string, string>, TwitterApiAccessLevel?> ParseAccessLevel_TestCase = new TheoryData<Dictionary<string, string>, TwitterApiAccessLevel?>
+ public static readonly TheoryData<Dictionary<string, string>, TwitterApiAccessLevel?> ParseAccessLevelTestCase = new TheoryData<Dictionary<string, string>, TwitterApiAccessLevel?>
{
{
new Dictionary<string, string> { { "X-Access-Level", "read" } },
};
[Theory]
- [MemberData(nameof(ParseAccessLevel_TestCase))]
+ [MemberData(nameof(ParseAccessLevelTestCase))]
public void ParseAccessLevelTest(IDictionary<string, string> header, TwitterApiAccessLevel? expected)
{
var accessLevel = TwitterApiStatus.ParseAccessLevel(header, "X-Access-Level");
utc.ToDateTimeUnsafe());
}
- public static readonly TheoryData<string, DateTimeUtc> Parse_Test_Fixtures = new TheoryData<string, DateTimeUtc>
+ public static readonly TheoryData<string, DateTimeUtc> ParseTestFixtures = new TheoryData<string, DateTimeUtc>
{
{ "2018-05-06T11:22:33.111", new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
{ "2018-05-06T11:22:33.111+00:00", new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
};
[Theory]
- [MemberData(nameof(Parse_Test_Fixtures))]
+ [MemberData(nameof(ParseTestFixtures))]
public void Parse_Test(string input, DateTimeUtc expected)
=> Assert.Equal(expected, DateTimeUtc.Parse(input, DateTimeFormatInfo.InvariantInfo));
public void Parse_ErrorTest()
=> Assert.Throws<FormatException>(() => DateTimeUtc.Parse("### INVALID ###", DateTimeFormatInfo.InvariantInfo));
- public static readonly TheoryData<string, bool, DateTimeUtc> TryParse_Test_Fixtures = new TheoryData<string, bool, DateTimeUtc>
+ public static readonly TheoryData<string, bool, DateTimeUtc> TryParseTestFixtures = new TheoryData<string, bool, DateTimeUtc>
{
{ "2018-05-06T11:22:33.111", true, new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
{ "2018-05-06T11:22:33.111+00:00", true, new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
};
[Theory]
- [MemberData(nameof(TryParse_Test_Fixtures))]
+ [MemberData(nameof(TryParseTestFixtures))]
public void TryParse_Test(string input, bool expectedParsed, DateTimeUtc expectedResult)
{
var parsed = DateTimeUtc.TryParse(input, DateTimeFormatInfo.InvariantInfo, out var result);
Assert.Equal(expectedResult, result);
}
- public static readonly TheoryData<string, string, bool, DateTimeUtc> TryParseExact_Test_Fixtures = new TheoryData<string, string, bool, DateTimeUtc>
+ public static readonly TheoryData<string, string, bool, DateTimeUtc> TryParseExactTestFixtures = new TheoryData<string, string, bool, DateTimeUtc>
{
{ "2018-05-06 11:22:33.111", "yyyy-MM-dd HH:mm:ss.fff", true, new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
{ "2018-05-06 11:22:33.111 +00:00", "yyyy-MM-dd HH:mm:ss.fff zzz", true, new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
};
[Theory]
- [MemberData(nameof(TryParseExact_Test_Fixtures))]
+ [MemberData(nameof(TryParseExactTestFixtures))]
public void TryParseExact_Test(string input, string format, bool expectedParsed, DateTimeUtc expectedResult)
{
var parsed = DateTimeUtc.TryParseExact(input, new[] { format }, DateTimeFormatInfo.InvariantInfo, out var result);
public void IsAnimatedGifTest(string filename, bool expected)
=> Assert.Equal(expected, MyCommon.IsAnimatedGif(filename));
- public static readonly TheoryData<string, DateTimeUtc> DateTimeParse_TestCase = new TheoryData<string, DateTimeUtc>
+ public static readonly TheoryData<string, DateTimeUtc> DateTimeParseTestCase = new TheoryData<string, DateTimeUtc>
{
{ "Sun Nov 25 06:10:00 +00:00 2012", new DateTimeUtc(2012, 11, 25, 6, 10, 0) },
{ "Sun, 25 Nov 2012 06:10:00 +00:00", new DateTimeUtc(2012, 11, 25, 6, 10, 0) },
};
[Theory]
- [MemberData(nameof(DateTimeParse_TestCase))]
+ [MemberData(nameof(DateTimeParseTestCase))]
public void DateTimeParseTest(string date, DateTimeUtc excepted)
=> Assert.Equal(excepted, MyCommon.DateTimeParse(date));
[DataMember(Name = "body")]
public string Body { get; set; }
}
- public static readonly TheoryData<string, JsonData> CreateDataFromJson_TestCase = new TheoryData<string, JsonData>
+ public static readonly TheoryData<string, JsonData> CreateDataFromJsonTestCase = new TheoryData<string, JsonData>
{
{
@"{""id"":""1"", ""body"":""hogehoge""}",
};
[Theory]
- [MemberData(nameof(CreateDataFromJson_TestCase))]
+ [MemberData(nameof(CreateDataFromJsonTestCase))]
public void CreateDataFromJsonTest<T>(string json, T expected)
=> Assert.Equal(expected, MyCommon.CreateDataFromJson<T>(json));
public void GetReadableVersionTest(string fileVersion, string expected)
=> Assert.Equal(expected, MyCommon.GetReadableVersion(fileVersion));
- public static readonly TheoryData<PostClass, string> GetStatusUrlTest1_TestCase = new TheoryData<PostClass, string>
+ public static readonly TheoryData<PostClass, string> GetStatusUrlTest1TestCase = new TheoryData<PostClass, string>
{
{
new PostClass { StatusId = 249493863826350080L, ScreenName = "Favstar_LM", RetweetedId = null, RetweetedBy = null },
};
[Theory]
- [MemberData(nameof(GetStatusUrlTest1_TestCase))]
+ [MemberData(nameof(GetStatusUrlTest1TestCase))]
public void GetStatusUrlTest1(PostClass post, string expected)
=> Assert.Equal(expected, MyCommon.GetStatusUrl(post));
class SimpleThumbnailService : IThumbnailService
{
protected Regex regex;
- protected string thumb_replacement;
- protected string? fullsize_replacement;
+ protected string thumbReplacement;
+ protected string? fullsizeReplacement;
public SimpleThumbnailService(string pattern, string replacement)
: this(pattern, replacement, null)
public SimpleThumbnailService(Regex regex, string replacement, string? file_replacement)
{
this.regex = regex;
- this.thumb_replacement = replacement;
- this.fullsize_replacement = file_replacement;
+ this.thumbReplacement = replacement;
+ this.fullsizeReplacement = file_replacement;
}
public override Task<ThumbnailInfo?> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token)
MediaPageUrl = url,
ThumbnailImageUrl = thumbnailUrl,
TooltipText = null,
- FullSizeImageUrl = this.ReplaceUrl(url, this.fullsize_replacement)
+ FullSizeImageUrl = this.ReplaceUrl(url, this.fullsizeReplacement)
};
},
token);
}
protected string? ReplaceUrl(string url)
- => this.ReplaceUrl(url, this.thumb_replacement);
+ => this.ReplaceUrl(url, this.thumbReplacement);
protected string? ReplaceUrl(string url, string? replacement)
{
private bool isColumnChanged = false;
- private const int MAX_WORKER_THREADS = 20;
- private readonly SemaphoreSlim workerSemaphore = new SemaphoreSlim(MAX_WORKER_THREADS);
+ private const int MaxWorderThreads = 20;
+ private readonly SemaphoreSlim workerSemaphore = new SemaphoreSlim(MaxWorderThreads);
private readonly CancellationTokenSource workerCts = new CancellationTokenSource();
private readonly IProgress<string> workerProgress = null!;
void DisableTasktrayAnimation()
=> this.TimerRefreshIcon.Enabled = false;
- var busyTasks = this.workerSemaphore.CurrentCount != MAX_WORKER_THREADS;
+ var busyTasks = this.workerSemaphore.CurrentCount != MaxWorderThreads;
if (busyTasks)
{
this.iconCnt += 1;
{
MatchCollection m;
// ハッシュタグの保存
- m = Regex.Matches(statusText, Twitter.HASHTAG, RegexOptions.IgnoreCase);
+ m = Regex.Matches(statusText, Twitter.Hashtag, RegexOptions.IgnoreCase);
var hstr = "";
foreach (Match hm in m)
{
/// </summary>
public static IEnumerable<TwitterEntityHashtag> ExtractHashtagEntities(string text)
{
- var matches = Regex.Matches(text, Twitter.HASHTAG);
+ var matches = Regex.Matches(text, Twitter.Hashtag);
foreach (var match in matches.Cast<Match>())
{
var groupHashtagSharp = match.Groups[2];
// permissions and limitations under the License.
// Hashtag用正規表現
- private const string LATIN_ACCENTS = @"\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253\u0254\u0256\u0257\u0259\u025b\u0263\u0268\u026f\u0272\u0289\u028b\u02bb\u1e00-\u1eff";
- private const string NON_LATIN_HASHTAG_CHARS = @"\u0400-\u04ff\u0500-\u0527\u1100-\u11ff\u3130-\u3185\uA960-\uA97F\uAC00-\uD7AF\uD7B0-\uD7FF";
- private const string CJ_HASHTAG_CHARACTERS = @"\u30A1-\u30FA\u30FC\u3005\uFF66-\uFF9F\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\u3041-\u309A\u3400-\u4DBF\p{IsCJKUnifiedIdeographs}";
- private const string HASHTAG_BOUNDARY = @"^|$|\s|「|」|。|\.|!";
- private const string HASHTAG_ALPHA = "[A-Za-z_" + LATIN_ACCENTS + NON_LATIN_HASHTAG_CHARS + CJ_HASHTAG_CHARACTERS + "]";
- private const string HASHTAG_ALPHANUMERIC = "[A-Za-z0-9_" + LATIN_ACCENTS + NON_LATIN_HASHTAG_CHARS + CJ_HASHTAG_CHARACTERS + "]";
- private const string HASHTAG_TERMINATOR = "[^A-Za-z0-9_" + LATIN_ACCENTS + NON_LATIN_HASHTAG_CHARS + CJ_HASHTAG_CHARACTERS + "]";
- public const string HASHTAG = "(" + HASHTAG_BOUNDARY + ")(#|#)(" + HASHTAG_ALPHANUMERIC + "*" + HASHTAG_ALPHA + HASHTAG_ALPHANUMERIC + "*)(?=" + HASHTAG_TERMINATOR + "|" + HASHTAG_BOUNDARY + ")";
+ private const string LatinAccents = @"\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253\u0254\u0256\u0257\u0259\u025b\u0263\u0268\u026f\u0272\u0289\u028b\u02bb\u1e00-\u1eff";
+ private const string NonLatinHashtagChars = @"\u0400-\u04ff\u0500-\u0527\u1100-\u11ff\u3130-\u3185\uA960-\uA97F\uAC00-\uD7AF\uD7B0-\uD7FF";
+ private const string CJHashtagCharacters = @"\u30A1-\u30FA\u30FC\u3005\uFF66-\uFF9F\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\u3041-\u309A\u3400-\u4DBF\p{IsCJKUnifiedIdeographs}";
+ private const string HashtagBoundary = @"^|$|\s|「|」|。|\.|!";
+ private const string HashtagAlpha = "[A-Za-z_" + LatinAccents + NonLatinHashtagChars + CJHashtagCharacters + "]";
+ private const string HashtagAlphanumeric = "[A-Za-z0-9_" + LatinAccents + NonLatinHashtagChars + CJHashtagCharacters + "]";
+ private const string HashtagTerminator = "[^A-Za-z0-9_" + LatinAccents + NonLatinHashtagChars + CJHashtagCharacters + "]";
+ public const string Hashtag = "(" + HashtagBoundary + ")(#|#)(" + HashtagAlphanumeric + "*" + HashtagAlpha + HashtagAlphanumeric + "*)(?=" + HashtagTerminator + "|" + HashtagBoundary + ")";
// URL正規表現
private const string UrlValidPrecedingChars = @"(?:[^A-Za-z0-9@@$##\ufffe\ufeff\uffff\u202a-\u202e]|^)";
public const string UrlInvalidWithoutProtocolPrecedingChars = @"[-_./]$";
private const string UrlValidCCTLD = @"(?:(?:ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)(?=[^0-9a-zA-Z]|$))";
private const string UrlValidPunycode = @"(?:xn--[0-9a-z]+)";
private const string UrlValidDomain = @"(?<domain>" + UrlValidSubdomain + "*" + UrlValidDomainName + "(?:" + UrlValidGTLD + "|" + UrlValidCCTLD + ")|" + UrlValidPunycode + ")";
- public const string UrlValidAsciiDomain = @"(?:(?:[a-z0-9" + LATIN_ACCENTS + @"]+)\.)+(?:" + UrlValidGTLD + "|" + UrlValidCCTLD + "|" + UrlValidPunycode + ")";
+ public const string UrlValidAsciiDomain = @"(?:(?:[a-z0-9" + LatinAccents + @"]+)\.)+(?:" + UrlValidGTLD + "|" + UrlValidCCTLD + "|" + UrlValidPunycode + ")";
public const string UrlInvalidShortDomain = "^" + UrlValidDomainName + UrlValidCCTLD + "$";
private const string UrlValidPortNumber = @"[0-9]+";
- private const string UrlValidGeneralPathChars = @"[a-z0-9!*';:=+,.$/%#\[\]\-_~|&" + LATIN_ACCENTS + "]";
+ private const string UrlValidGeneralPathChars = @"[a-z0-9!*';:=+,.$/%#\[\]\-_~|&" + LatinAccents + "]";
private const string UrlBalanceParens = @"(?:\(" + UrlValidGeneralPathChars + @"+\))";
- private const string UrlValidPathEndingChars = @"(?:[+\-a-z0-9=_#/" + LATIN_ACCENTS + "]|" + UrlBalanceParens + ")";
+ private const string UrlValidPathEndingChars = @"(?:[+\-a-z0-9=_#/" + LatinAccents + "]|" + UrlBalanceParens + ")";
private const string Pth = "(?:" +
"(?:" +
UrlValidGeneralPathChars + "*" +
// Boston, MA 02110-1301, USA.
#nullable enable
+#pragma warning disable SA1310
using System;
using System.Collections.Generic;