-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
module Funogram.Tests.Deserializer | ||
|
||
open System.IO | ||
open System.Text | ||
|
||
open Xunit | ||
|
||
open Funogram | ||
open Funogram.Telegram.Types | ||
|
||
[<Fact>] | ||
let ``Deserializer should work``(): unit = | ||
let brokenUpdate = """{ | ||
"ok": true, | ||
"result": [ | ||
{ | ||
"update_id": 1, | ||
"message": { | ||
"message_id": 1, | ||
"from": { | ||
"id": 1, | ||
"is_bot": false, | ||
"first_name": "1", | ||
"last_name": "1", | ||
"username": "1" | ||
}, | ||
"chat": { | ||
"id": -1, | ||
"title": "1", | ||
"username": "1", | ||
"type": "supergroup" | ||
}, | ||
"date": 1707128434, | ||
"message_thread_id": 1, | ||
"reply_to_message": { | ||
"message_id": 1, | ||
"from": { | ||
"id": 1, | ||
"is_bot": false, | ||
"first_name": "2", | ||
"username": "2", | ||
"is_premium": true | ||
}, | ||
"chat": { | ||
"id": -1, | ||
"title": "1", | ||
"username": "1", | ||
"type": "supergroup" | ||
}, | ||
"date": 1707117257, | ||
"message_thread_id": 1, | ||
"quote": { | ||
"text": "Ins\\", | ||
"position": 9, | ||
"is_manual": true | ||
} | ||
} | ||
} | ||
} | ||
] | ||
}""" | ||
let input = Encoding.UTF8.GetBytes brokenUpdate | ||
use stream = new MemoryStream(input) | ||
match Tools.parseJsonStreamApiResponse<Update[]> stream with | ||
| Error e -> Assert.True(false, e.ToString()) | ||
| Ok result -> | ||
|
||
let update = Assert.Single result | ||
match update.Message with | ||
| None -> Assert.True(false, "No message") | ||
| Some message -> Assert.Equal(1L, message.MessageId) |
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