}
public int GetHashCode(IEnumerable<T> obj)
- {
- throw new NotImplementedException();
- }
+ => throw new NotImplementedException();
}
}
public class TwitterApiTest
{
public TwitterApiTest()
- {
- this.MyCommonSetup();
- }
+ => this.MyCommonSetup();
private void MyCommonSetup()
{
[InlineData("sq", 1)]
[InlineData("ja", 67)]
public void GetLanguageEnumFromIndex_Test(string expected, int index)
- {
- Assert.Equal(expected, Bing.GetLanguageEnumFromIndex(index));
- }
+ => Assert.Equal(expected, Bing.GetLanguageEnumFromIndex(index));
[Theory]
[InlineData(0, "af")]
[InlineData(1, "sq")]
[InlineData(67, "ja")]
public void GetIndexFromLanguageEnum_Test(int expected, string lang)
- {
- Assert.Equal(expected, Bing.GetIndexFromLanguageEnum(lang));
- }
+ => Assert.Equal(expected, Bing.GetIndexFromLanguageEnum(lang));
}
}
}
public override void Flush()
- {
- throw new NotSupportedException();
- }
+ => throw new NotSupportedException();
public override int Read(byte[] buffer, int offset, int count)
- {
- throw new IOException();
- }
+ => throw new IOException();
public override long Seek(long offset, SeekOrigin origin)
- {
- throw new NotSupportedException();
- }
+ => throw new NotSupportedException();
public override void SetLength(long value)
- {
- throw new NotSupportedException();
- }
+ => throw new NotSupportedException();
public override void Write(byte[] buffer, int offset, int count)
- {
- throw new NotSupportedException();
- }
+ => throw new NotSupportedException();
protected override void Dispose(bool disposing)
{
public class TwitterApiConnectionTest
{
public TwitterApiConnectionTest()
- {
- this.MyCommonSetup();
- }
+ => this.MyCommonSetup();
private void MyCommonSetup()
{
new Queue<Func<HttpRequestMessage, Task<HttpResponseMessage>>>();
public int QueueCount
- {
- get { return this.Queue.Count; }
- }
+ => this.Queue.Count;
public void Enqueue(Func<HttpRequestMessage, Task<HttpResponseMessage>> handler)
- {
- this.Queue.Enqueue(handler);
- }
+ => this.Queue.Enqueue(handler);
public void Enqueue(Func<HttpRequestMessage, HttpResponseMessage> handler)
- {
- this.Queue.Enqueue(x => Task.Run(() => handler(x)));
- }
+ => this.Queue.Enqueue(x => Task.Run(() => handler(x)));
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
// イベント設定
var removedList = new List<string>();
- dict.CacheRemoved += (s, e) =>
- {
- removedList.Add(e.Item.Key);
- };
+ dict.CacheRemoved += (s, e) => removedList.Add(e.Item.Key);
// 2 個までに縮小
dict.TrimLimit = 2;
public class MediaSelectorTest
{
public MediaSelectorTest()
- {
- this.MyCommonSetup();
- }
+ => this.MyCommonSetup();
private void MyCommonSetup()
{
[InlineData(2L, true)]
[InlineData(3L, true)]
public void GetIsFavTest(long statusId, bool expected)
- {
- Assert.Equal(expected, PostClassTest.TestCases[statusId].IsFav);
- }
+ => Assert.Equal(expected, PostClassTest.TestCases[statusId].IsFav);
[Theory]
[InlineData(2L, true)]
public class PostFilterRuleTest
{
public PostFilterRuleTest()
- {
- PostFilterRule.AutoCompile = true;
- }
+ => PostFilterRule.AutoCompile = true;
[Fact]
public void EmptyRuleTest()
[InlineData(MyCommon.TabUsageType.PublicSearch, false)]
[InlineData(MyCommon.TabUsageType.Related, false)]
public void IsDefault_Test(MyCommon.TabUsageType tabType, bool expected)
- {
- Assert.Equal(expected, tabType.IsDefault());
- }
+ => Assert.Equal(expected, tabType.IsDefault());
[Theory]
[InlineData(MyCommon.TabUsageType.Home, false)]
[InlineData(MyCommon.TabUsageType.PublicSearch, false)]
[InlineData(MyCommon.TabUsageType.Related, false)]
public void IsDistributable_Test(MyCommon.TabUsageType tabType, bool expected)
- {
- Assert.Equal(expected, tabType.IsDistributable());
- }
+ => Assert.Equal(expected, tabType.IsDistributable());
[Theory]
[InlineData(MyCommon.TabUsageType.Home, false)]
[InlineData(MyCommon.TabUsageType.PublicSearch, true)]
[InlineData(MyCommon.TabUsageType.Related, true)]
public void IsInnerStorage_Test(MyCommon.TabUsageType tabType, bool expected)
- {
- Assert.Equal(expected, tabType.IsInnerStorage());
- }
+ => Assert.Equal(expected, tabType.IsInnerStorage());
}
}
[InlineData("http://日本語.idn.icann.org/", "http://xn--wgv71a119e.idn.icann.org/")]
[InlineData("http://例え.テスト/", "http://xn--r8jz45g.xn--zckzah/")]
public void IDNEncodeTest(string uri, string expected)
- {
- Assert.Equal(expected, MyCommon.IDNEncode(uri));
- }
+ => Assert.Equal(expected, MyCommon.IDNEncode(uri));
[Theory]
[InlineData("http://xn--wgv71a119e.idn.icann.org/", "http://日本語.idn.icann.org/")]
[InlineData("http://xn--r8jz45g.xn--zckzah/", "http://例え.テスト/")]
[InlineData("http://xn--a/", "http://xn--a/")] // 不正なpunycode
public void IDNDecodeTest(string uri, string expected)
- {
- Assert.Equal(expected, MyCommon.IDNDecode(uri));
- }
+ => Assert.Equal(expected, MyCommon.IDNDecode(uri));
[Theory]
[InlineData("http://xn--r8jz45g.xn--zckzah/", "http://例え.テスト/")]
[InlineData("http://example.com/%E3%81%82%FF", "http://example.com/あ%FF")] // 不正なUTF-8シーケンス
[InlineData("http://example.com/%E3%81%82%ED%A0%80", "http://example.com/あ%ED%A0%80")] // 不正なUTF-8シーケンス (high surrogate)
public void ConvertToReadableUrl(string url, string expected)
- {
- Assert.Equal(expected, MyCommon.ConvertToReadableUrl(url));
- }
+ => Assert.Equal(expected, MyCommon.ConvertToReadableUrl(url));
[Theory]
[InlineData(new int[] { 1, 2, 3, 4 }, 0, 3, new int[] { 2, 3, 4, 1 })] // 左ローテイト?
[InlineData(new byte[] { 0x01, 0x02 }, 2, new byte[] { 0x01, 0x02 })]
[InlineData(new byte[] { 0x01, 0x02 }, 1, new byte[] { 0x03 })]
public void ResizeBytesArrayTest(byte[] bytes, int size, byte[] expected)
- {
- Assert.Equal(expected, MyCommon.ResizeBytesArray(bytes, size));
- }
+ => Assert.Equal(expected, MyCommon.ResizeBytesArray(bytes, size));
[Theory]
[InlineData("Resources/re.gif", true)]
[InlineData("Resources/re1.gif", false)]
[InlineData("Resources/re1.png", false)]
public void IsAnimatedGifTest(string filename, bool expected)
- {
- Assert.Equal(expected, MyCommon.IsAnimatedGif(filename));
- }
+ => Assert.Equal(expected, MyCommon.IsAnimatedGif(filename));
public static readonly TheoryData<string, DateTimeUtc> DateTimeParse_TestCase = new TheoryData<string, DateTimeUtc>
{
[Theory]
[MemberData(nameof(CreateDataFromJson_TestCase))]
public void CreateDataFromJsonTest<T>(string json, T expected)
- {
- Assert.Equal(expected, MyCommon.CreateDataFromJson<T>(json));
- }
+ => Assert.Equal(expected, MyCommon.CreateDataFromJson<T>(json));
[Theory]
[InlineData("hoge123@example.com", true)]
[InlineData("foobar.@example.com", false)]
[InlineData("foo+bar@example.com", true)]
public void IsValidEmailTest(string email, bool expected)
- {
- Assert.Equal(expected, MyCommon.IsValidEmail(email));
- }
+ => Assert.Equal(expected, MyCommon.IsValidEmail(email));
[Theory]
[InlineData(Keys.Shift, new[] { Keys.Shift }, true)]
[InlineData(Keys.Control | Keys.Alt, new[] { Keys.Control, Keys.Alt }, true)]
[InlineData(Keys.Control | Keys.Alt, new[] { Keys.Shift }, false)]
public void IsKeyDownTest(Keys modifierKeys, Keys[] checkKeys, bool expected)
- {
- Assert.Equal(expected, MyCommon._IsKeyDown(modifierKeys, checkKeys));
- }
+ => Assert.Equal(expected, MyCommon._IsKeyDown(modifierKeys, checkKeys));
[Fact]
public void GetAssemblyNameTest()
[InlineData("%AppName%", "OpenTween")]
[InlineData("%AppName% %AppName%", "OpenTween OpenTween")]
public void ReplaceAppNameTest(string str, string excepted)
- {
- Assert.Equal(excepted, MyCommon.ReplaceAppName(str, "OpenTween"));
- }
+ => Assert.Equal(excepted, MyCommon.ReplaceAppName(str, "OpenTween"));
[Theory]
[InlineData("1.0.0.0", "1.0.0")]
[InlineData("1.1.0.0", "1.1.0")]
[InlineData("1.9.9.1", "1.9.10-dev")]
public void GetReadableVersionTest(string fileVersion, string expected)
- {
- Assert.Equal(expected, MyCommon.GetReadableVersion(fileVersion));
- }
+ => Assert.Equal(expected, MyCommon.GetReadableVersion(fileVersion));
public static IEnumerable<object[]> GetStatusUrlTest1_TestCase
{
[Theory]
[MemberData(nameof(GetStatusUrlTest1_TestCase))]
public void GetStatusUrlTest1(PostClass post, string expected)
- {
- Assert.Equal(expected, MyCommon.GetStatusUrl(post));
- }
+ => Assert.Equal(expected, MyCommon.GetStatusUrl(post));
[Theory]
[InlineData("Favstar_LM", 249493863826350080L, "https://twitter.com/Favstar_LM/status/249493863826350080")]
[InlineData("haru067", 200245741443235840L, "https://twitter.com/haru067/status/200245741443235840")]
public void GetStatusUrlTest2(string screenName, long statusId, string expected)
- {
- Assert.Equal(expected, MyCommon.GetStatusUrl(screenName, statusId));
- }
+ => Assert.Equal(expected, MyCommon.GetStatusUrl(screenName, statusId));
[Fact]
public void GetErrorLogPathTest()
private class TestForm : OTBaseForm { }
public OTBaseFormTest()
- {
- this.SetupSynchronizationContext();
- }
+ => this.SetupSynchronizationContext();
protected void SetupSynchronizationContext()
- {
- WindowsFormsSynchronizationContext.AutoInstall = false;
- }
+ => WindowsFormsSynchronizationContext.AutoInstall = false;
[Fact]
public async Task InvokeAsync_Test()
{
await Task.Run(async () =>
{
- await form.InvokeAsync(() => { form.Text = "hoge"; });
+ await form.InvokeAsync(() => form.Text = "hoge");
});
Assert.Equal("hoge", form.Text);
}
private HttpResponseMessage CreateRedirectResponse(string uriStr)
- {
- return this.CreateRedirectResponse(uriStr, UriKind.Absolute);
- }
+ => this.CreateRedirectResponse(uriStr, UriKind.Absolute);
private HttpResponseMessage CreateRedirectResponse(string uriStr, UriKind uriKind)
{
}
public static void FireEvent<T>(T control, string eventName) where T : Control
- {
- TestUtils.FireEvent(control, eventName, EventArgs.Empty);
- }
+ => TestUtils.FireEvent(control, eventName, EventArgs.Empty);
public static void FireEvent<T>(T control, string eventName, EventArgs e) where T : Control
{
}
public string GetApiBase()
- {
- return this.ApiBase;
- }
+ => this.ApiBase;
protected override Task<byte[]> FetchRegexAsync(string apiBase)
{
}
protected override Task<string> FetchImageUrlAsync(string url, CancellationToken token)
- {
- return Task.FromResult(this.FakeHtml);
- }
+ => Task.FromResult(this.FakeHtml);
}
[Fact]
}
protected override Task<XDocument> FetchContentInfoApiAsync(string contentId, CancellationToken token)
- {
- return Task.FromResult(XDocument.Parse(this.FakeXml));
- }
+ => Task.FromResult(XDocument.Parse(this.FakeXml));
}
[Fact]
class MockThumbnailInfo : ThumbnailInfo
{
public override Task<MemoryImage> LoadThumbnailImageAsync(HttpClient http, CancellationToken cancellationToken)
- {
- return Task.FromResult(TestUtils.CreateDummyImage());
- }
+ => Task.FromResult(TestUtils.CreateDummyImage());
}
}
[InlineData("http://twitter.com/messages/compose?recipient_id=514241801", true)]
[InlineData("https://twitter.com/messages/compose?recipient_id=514241801&text=%E3%81%BB%E3%81%92", true)]
public void AttachmentUrlRegexTest(string url, bool isMatch)
- {
- Assert.Equal(isMatch, Twitter.AttachmentUrlRegex.IsMatch(url));
- }
+ => Assert.Equal(isMatch, Twitter.AttachmentUrlRegex.IsMatch(url));
[Theory]
[InlineData("http://favstar.fm/users/twitterapi/status/22634515958", new[] { "22634515958" })]
public double[] Coordinates { get; set; }
public GeoJsonPoint()
- {
- this.Type = "Point";
- }
+ => this.Type = "Point";
}
[DataContract]
public double[][][] Coordinates { get; set; }
public GeoJsonPolygon()
- {
- this.Type = "Polygon";
- }
+ => this.Type = "Polygon";
}
}
/// <exception cref="SerializationException"/>
public static TwitterConfiguration ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterConfiguration>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterConfiguration>(json);
/// <summary>
/// 設定が取得できるまでの間に代わりに使用する適当な値を返します
/// <exception cref="SerializationException"/>
public static TwitterError ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterError>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterError>(json);
}
[DataContract]
/// <exception cref="SerializationException"/>
public static TwitterFriendship ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterFriendship>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterFriendship>(json);
}
}
/// <exception cref="SerializationException"/>
public static TwitterList ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterList>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterList>(json);
/// <exception cref="SerializationException"/>
public static TwitterList[] ParseJsonArray(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterList[]>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterList[]>(json);
}
}
[IgnoreDataMember]
public override long[] Items
- {
- get { return this.Ids; }
- }
+ => this.Ids;
/// <exception cref="SerializationException"/>
public static TwitterIds ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterIds>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterIds>(json);
}
[DataContract]
[IgnoreDataMember]
public override TwitterUser[] Items
- {
- get { return this.Users; }
- }
+ => this.Users;
/// <exception cref="SerializationException"/>
public static TwitterUsers ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterUsers>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterUsers>(json);
}
[DataContract]
[IgnoreDataMember]
public override TwitterList[] Items
- {
- get { return this.Lists; }
- }
+ => this.Lists;
/// <exception cref="SerializationException"/>
public static TwitterLists ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterLists>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterLists>(json);
}
}
/// <exception cref="SerializationException"/>
public static TwitterRateLimits ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterRateLimits>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterRateLimits>(json);
}
}
/// <exception cref="SerializationException"/>
public static TwitterSearchResult ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterSearchResult>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterSearchResult>(json);
}
}
/// <exception cref="SerializationException"/>
public static TwitterStatus ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterStatus>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterStatus>(json);
/// <exception cref="SerializationException"/>
public static TwitterStatus[] ParseJsonArray(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterStatus[]>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterStatus[]>(json);
}
[DataContract]
/// <exception cref="SerializationException"/>
public static TwitterStatusCompat ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterStatusCompat>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterStatusCompat>(json);
/// <exception cref="SerializationException"/>
public static TwitterStatusCompat[] ParseJsonArray(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterStatusCompat[]>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterStatusCompat[]>(json);
}
[DataContract]
/// <exception cref="SerializationException"/>
public static TwitterDirectMessage ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterDirectMessage>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterDirectMessage>(json);
/// <exception cref="SerializationException"/>
public static TwitterDirectMessage[] ParseJsonArray(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterDirectMessage[]>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterDirectMessage[]>(json);
}
}
/// <exception cref="SerializationException"/>
public static TwitterStreamEvent ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterStreamEvent>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterStreamEvent>(json);
}
[DataContract]
/// <exception cref="SerializationException"/>
public static new TwitterStreamEvent<T> ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterStreamEvent<T>>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterStreamEvent<T>>(json);
}
}
/// <exception cref="SerializationException"/>
public static TwitterTextConfiguration ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterTextConfiguration>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterTextConfiguration>(json);
public static TwitterTextConfiguration DefaultConfiguration()
{
/// <exception cref="SerializationException"/>
public static TwitterUser ParseJson(string json)
- {
- return MyCommon.CreateDataFromJson<TwitterUser>(json);
- }
+ => MyCommon.CreateDataFromJson<TwitterUser>(json);
}
}
/// この振り分けルールにマッチ条件が含まれているかを返します
/// </summary>
public bool HasMatchConditions()
- {
- return !string.IsNullOrEmpty(this.FilterName) ||
+ => !string.IsNullOrEmpty(this.FilterName) ||
this.FilterBody.Any(x => !string.IsNullOrEmpty(x)) ||
!string.IsNullOrEmpty(this.FilterSource) ||
this.FilterRt;
- }
/// <summary>
/// この振り分けルールに除外条件が含まれているかを返します
/// </summary>
public bool HasExcludeConditions()
- {
- return !string.IsNullOrEmpty(this.ExFilterName) ||
+ => !string.IsNullOrEmpty(this.ExFilterName) ||
this.ExFilterBody.Any(x => !string.IsNullOrEmpty(x)) ||
!string.IsNullOrEmpty(this.ExFilterSource) ||
this.ExFilterRt;
- }
public override bool Equals(object obj)
=> this.Equals(obj as PostFilterRule);
}
public override int GetHashCode()
- {
- return this.FilterName?.GetHashCode() ?? 0 ^
+ => this.FilterName?.GetHashCode() ?? 0 ^
this.FilterSource?.GetHashCode() ?? 0 ^
this.FilterBody.Select(x => x?.GetHashCode() ?? 0).Sum() ^
this.ExFilterName?.GetHashCode() ?? 0 ^
this.ExFilterSource?.GetHashCode() ?? 0 ^
this.ExFilterBody.Select(x => x?.GetHashCode() ?? 0).Sum();
- }
}
}
/// 指定されたスケールと SettingLocal.ScaleDimension のスケールとの拡大比を返します
/// </summary>
public SizeF GetConfigScaleFactor(SizeF currentSizeDimension)
- {
- return new SizeF(
+ => new SizeF(
currentSizeDimension.Width / this.ScaleDimension.Width,
currentSizeDimension.Height / this.ScaleDimension.Height);
- }
public void Dispose()
{
=> this.Equals(obj as ThumbnailInfo);
public bool Equals(ThumbnailInfo other)
- {
- return other != null &&
+ => other != null &&
other.MediaPageUrl == this.MediaPageUrl &&
other.ThumbnailImageUrl == this.ThumbnailImageUrl &&
other.TooltipText == this.TooltipText &&
other.FullSizeImageUrl == this.FullSizeImageUrl &&
other.IsPlayable == this.IsPlayable;
- }
public override int GetHashCode()
=> this.MediaPageUrl.GetHashCode() ^ this.ThumbnailImageUrl.GetHashCode();
for (var i = postList.Count - 1; i >= 0; i--)
{
var index = i;
- if (postList.FindIndex((pst) => { return pst.Post.StatusId == postList[index].Post.StatusId; }) != index)
+ if (postList.FindIndex(pst => pst.Post.StatusId == postList[index].Post.StatusId) != index)
{
postList.RemoveAt(index);
}
}
var currentIndex = this.CurrentTab.SelectedIndex;
- var post = postList.FirstOrDefault((pst) => { return pst.Tab == curTabClass && isForward ? pst.Index > currentIndex : pst.Index < currentIndex; });
- if (post == null) post = postList.FirstOrDefault((pst) => { return pst.Tab != curTabClass; });
+ var post = postList.FirstOrDefault(pst => pst.Tab == curTabClass && isForward ? pst.Index > currentIndex : pst.Index < currentIndex);
+ if (post == null) post = postList.FirstOrDefault(pst => pst.Tab != curTabClass);
if (post == null) post = postList.First();
var tabIndex = this._statuses.Tabs.IndexOf(post.Tab);
this.ListTab.SelectedIndex = tabIndex;