-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #326 from opentween/account-state
ユーザー名や発言数などアカウントの可変な情報をTwitterAccountStateクラスに分離
- Loading branch information
Showing
8 changed files
with
167 additions
and
54 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
52 changes: 52 additions & 0 deletions
52
OpenTween.Tests/SocialProtocol/Twitter/TwitterAccountStateTest.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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// OpenTween - Client of Twitter | ||
// Copyright (c) 2024 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/> | ||
// All rights reserved. | ||
// | ||
// This file is part of OpenTween. | ||
// | ||
// This program is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the Free | ||
// Software Foundation; either version 3 of the License, or (at your option) | ||
// any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
// for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program. If not, see <http://www.gnu.org/licenses/>, or write to | ||
// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, | ||
// Boston, MA 02110-1301, USA. | ||
|
||
using OpenTween.Api.DataModel; | ||
using Xunit; | ||
|
||
namespace OpenTween.SocialProtocol.Twitter | ||
{ | ||
public class TwitterAccountStateTest | ||
{ | ||
[Fact] | ||
public void UpdateFromUser_Test() | ||
{ | ||
var accountState = new TwitterAccountState(); | ||
|
||
var twitterUser = new TwitterUser | ||
{ | ||
Id = 514241801L, | ||
IdStr = "514241801", | ||
ScreenName = "OpenTween", | ||
StatusesCount = 31, | ||
FriendsCount = 1, | ||
FollowersCount = 302, | ||
}; | ||
accountState.UpdateFromUser(twitterUser); | ||
|
||
Assert.Equal(514241801L, accountState.UserId); | ||
Assert.Equal("OpenTween", accountState.UserName); | ||
Assert.Equal(31, accountState.StatusesCount); | ||
Assert.Equal(1, accountState.FriendsCount); | ||
Assert.Equal(302, accountState.FollowersCount); | ||
} | ||
} | ||
} |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// OpenTween - Client of Twitter | ||
// Copyright (c) 2024 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/> | ||
// All rights reserved. | ||
// | ||
// This file is part of OpenTween. | ||
// | ||
// This program is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the Free | ||
// Software Foundation; either version 3 of the License, or (at your option) | ||
// any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
// for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program. If not, see <http://www.gnu.org/licenses/>, or write to | ||
// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, | ||
// Boston, MA 02110-1301, USA. | ||
|
||
#nullable enable | ||
|
||
using System.Collections.Generic; | ||
using OpenTween.Api.DataModel; | ||
|
||
namespace OpenTween.SocialProtocol.Twitter | ||
{ | ||
public class TwitterAccountState | ||
{ | ||
public long UserId { get; private set; } | ||
|
||
public string UserName { get; private set; } | ||
|
||
public int? FollowersCount { get; private set; } | ||
|
||
public int? FriendsCount { get; private set; } | ||
|
||
public int? StatusesCount { get; private set; } | ||
|
||
public ISet<long> FollowerIds { get; set; } = new HashSet<long>(); | ||
|
||
public ISet<long> NoRetweetUserIds { get; set; } = new HashSet<long>(); | ||
|
||
public TwitterAccountState() | ||
: this(0L, "") | ||
{ | ||
} | ||
|
||
public TwitterAccountState(long userId, string userName) | ||
{ | ||
this.UserId = userId; | ||
this.UserName = userName; | ||
} | ||
|
||
/// <summary>ユーザー情報を更新します</summary> | ||
public void UpdateFromUser(TwitterUser self) | ||
{ | ||
this.UserId = self.Id; | ||
this.UserName = self.ScreenName; | ||
this.FollowersCount = self.FollowersCount; | ||
this.FriendsCount = self.FriendsCount; | ||
this.StatusesCount = self.StatusesCount; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.