-
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 #362 from opentween/misskey
Misskeyアカウントのホームタイムライン閲覧・投稿に対応
- Loading branch information
Showing
55 changed files
with
3,467 additions
and
21 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
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,55 @@ | ||
// 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 System; | ||
using System.Threading.Tasks; | ||
using Moq; | ||
using OpenTween.Connection; | ||
using Xunit; | ||
|
||
namespace OpenTween.Api.Misskey | ||
{ | ||
public class MeRequestTest | ||
{ | ||
[Fact] | ||
public async Task Send_Test() | ||
{ | ||
var response = TestUtils.CreateApiResponse(new MisskeyUser()); | ||
|
||
var mock = new Mock<IApiConnection>(); | ||
mock.Setup(x => | ||
x.SendAsync(It.IsAny<IHttpRequest>()) | ||
) | ||
.Callback<IHttpRequest>(x => | ||
{ | ||
var request = Assert.IsType<PostRequest>(x); | ||
Assert.Equal(new("i", UriKind.Relative), request.RequestUri); | ||
Assert.Null(request.Query); | ||
}) | ||
.ReturnsAsync(response); | ||
|
||
var request = new MeRequest(); | ||
await request.Send(mock.Object); | ||
|
||
mock.VerifyAll(); | ||
} | ||
} | ||
} |
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,58 @@ | ||
// 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 System; | ||
using System.Threading.Tasks; | ||
using Moq; | ||
using OpenTween.Connection; | ||
using Xunit; | ||
|
||
namespace OpenTween.Api.Misskey | ||
{ | ||
public class MiauthCheckRequestTest | ||
{ | ||
[Fact] | ||
public async Task Send_Test() | ||
{ | ||
var response = TestUtils.CreateApiResponse(new MiauthTokenResponse()); | ||
|
||
var mock = new Mock<IApiConnection>(); | ||
mock.Setup(x => | ||
x.SendAsync(It.IsAny<IHttpRequest>()) | ||
) | ||
.Callback<IHttpRequest>(x => | ||
{ | ||
var request = Assert.IsType<PostRequest>(x); | ||
Assert.Equal(new("miauth/abc123/check", UriKind.Relative), request.RequestUri); | ||
Assert.Null(request.Query); | ||
}) | ||
.ReturnsAsync(response); | ||
|
||
var request = new MiauthCheckRequest | ||
{ | ||
SessionNonce = "abc123", | ||
}; | ||
await request.Send(mock.Object); | ||
|
||
mock.VerifyAll(); | ||
} | ||
} | ||
} |
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,63 @@ | ||
// 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 System; | ||
using System.Threading.Tasks; | ||
using Moq; | ||
using OpenTween.Connection; | ||
using Xunit; | ||
|
||
namespace OpenTween.Api.Misskey | ||
{ | ||
public class NoteCreateRequestTest | ||
{ | ||
[Fact] | ||
public async Task Send_Test() | ||
{ | ||
var response = TestUtils.CreateApiResponse(new MisskeyNote()); | ||
|
||
var mock = new Mock<IApiConnection>(); | ||
mock.Setup(x => | ||
x.SendAsync(It.IsAny<IHttpRequest>()) | ||
) | ||
.Callback<IHttpRequest>(x => | ||
{ | ||
var request = Assert.IsType<PostJsonRequest>(x); | ||
Assert.Equal(new("notes/create", UriKind.Relative), request.RequestUri); | ||
Assert.Equal( | ||
"""{"replyId":"aaaaa","text":"tetete","visibility":"public"}""", | ||
request.JsonString | ||
); | ||
}) | ||
.ReturnsAsync(response); | ||
|
||
var request = new NoteCreateRequest | ||
{ | ||
Text = "tetete", | ||
Visibility = "public", | ||
ReplyId = new("aaaaa"), | ||
}; | ||
await request.Send(mock.Object); | ||
|
||
mock.VerifyAll(); | ||
} | ||
} | ||
} |
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,58 @@ | ||
// 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 System; | ||
using System.Threading.Tasks; | ||
using Moq; | ||
using OpenTween.Connection; | ||
using Xunit; | ||
|
||
namespace OpenTween.Api.Misskey | ||
{ | ||
public class NoteDeleteRequestTest | ||
{ | ||
[Fact] | ||
public async Task Send_Test() | ||
{ | ||
var mock = new Mock<IApiConnection>(); | ||
mock.Setup(x => | ||
x.SendAsync(It.IsAny<IHttpRequest>()) | ||
) | ||
.Callback<IHttpRequest>(x => | ||
{ | ||
var request = Assert.IsType<PostJsonRequest>(x); | ||
Assert.Equal(new("notes/delete", UriKind.Relative), request.RequestUri); | ||
Assert.Equal( | ||
"""{"noteId":"aaaaa"}""", | ||
request.JsonString | ||
); | ||
}); | ||
|
||
var request = new NoteDeleteRequest | ||
{ | ||
NoteId = new("aaaaa"), | ||
}; | ||
await request.Send(mock.Object); | ||
|
||
mock.VerifyAll(); | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
OpenTween.Tests/Api/Misskey/NoteReactionCreateRequestTest.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,59 @@ | ||
// 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 System; | ||
using System.Threading.Tasks; | ||
using Moq; | ||
using OpenTween.Connection; | ||
using Xunit; | ||
|
||
namespace OpenTween.Api.Misskey | ||
{ | ||
public class NoteReactionCreateRequestTest | ||
{ | ||
[Fact] | ||
public async Task Send_Test() | ||
{ | ||
var mock = new Mock<IApiConnection>(); | ||
mock.Setup(x => | ||
x.SendAsync(It.IsAny<IHttpRequest>()) | ||
) | ||
.Callback<IHttpRequest>(x => | ||
{ | ||
var request = Assert.IsType<PostJsonRequest>(x); | ||
Assert.Equal(new("notes/reactions/create", UriKind.Relative), request.RequestUri); | ||
Assert.Equal( | ||
"""{"noteId":"aaaaa","reaction":"❤"}""", | ||
request.JsonString | ||
); | ||
}); | ||
|
||
var request = new NoteReactionCreateRequest | ||
{ | ||
NoteId = new("aaaaa"), | ||
Reaction = "❤", | ||
}; | ||
await request.Send(mock.Object); | ||
|
||
mock.VerifyAll(); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
OpenTween.Tests/Api/Misskey/NoteReactionDeleteRequestTest.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,58 @@ | ||
// 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 System; | ||
using System.Threading.Tasks; | ||
using Moq; | ||
using OpenTween.Connection; | ||
using Xunit; | ||
|
||
namespace OpenTween.Api.Misskey | ||
{ | ||
public class NoteReactionDeleteRequestTest | ||
{ | ||
[Fact] | ||
public async Task Send_Test() | ||
{ | ||
var mock = new Mock<IApiConnection>(); | ||
mock.Setup(x => | ||
x.SendAsync(It.IsAny<IHttpRequest>()) | ||
) | ||
.Callback<IHttpRequest>(x => | ||
{ | ||
var request = Assert.IsType<PostJsonRequest>(x); | ||
Assert.Equal(new("notes/reactions/delete", UriKind.Relative), request.RequestUri); | ||
Assert.Equal( | ||
"""{"noteId":"aaaaa"}""", | ||
request.JsonString | ||
); | ||
}); | ||
|
||
var request = new NoteReactionDeleteRequest | ||
{ | ||
NoteId = new("aaaaa"), | ||
}; | ||
await request.Send(mock.Object); | ||
|
||
mock.VerifyAll(); | ||
} | ||
} | ||
} |
Oops, something went wrong.