From 926dd07fa9ba62bb89c254d1a47f04ef6c565e52 Mon Sep 17 00:00:00 2001
From: Wizou <11647984+wiz0u@users.noreply.github.com>
Date: Sun, 15 Dec 2024 00:13:09 +0100
Subject: [PATCH] Renaming class File -> TGFile
---
README.md | 2 +-
src/Telegram.Bot/GlobalUsings.cs | 3 +--
src/Telegram.Bot/ITelegramBotClient.cs | 4 ++--
.../Get Files/GetFileRequest.cs | 4 ++--
.../Stickers/UploadStickerFileRequest.cs | 4 ++--
.../Serialization/JsonBotSerializerContext.cs | 2 +-
.../TelegramBotClientExtensions.ApiMethods.cs | 12 ++++++------
src/Telegram.Bot/Types/Sticker.cs | 2 +-
src/Telegram.Bot/Types/{File.cs => TGFile.cs} | 2 +-
.../Admin Bot/ChannelAdminBotTests.cs | 2 +-
.../Admin Bot/SupergroupAdminBotTests.cs | 2 +-
.../Inline Mode/InlineQueryTests.cs | 8 ++++----
.../Other/FileDownloadTests.cs | 13 ++++++-------
.../Sending Messages/AlbumMessageTests.cs | 18 +++++++++---------
.../Sending Messages/AnimationMessageTests.cs | 6 +++---
.../Sending Messages/AudioMessageTests.cs | 8 ++++----
.../Sending Messages/DocumentMessageTests.cs | 8 ++++----
.../SendingPhotoMessageTests.cs | 6 +++---
.../Sending Messages/VideoMessageTests.cs | 12 ++++++------
.../Stickers/StickersTests.cs | 6 +++---
.../Stickers/StickersTestsFixture.cs | 6 +++---
.../EditMessageContentTests2.cs | 2 +-
.../Update Messages/EditMessageMediaTests.cs | 2 +-
.../Update Messages/EditMessageMediaTests2.cs | 8 ++++----
24 files changed, 70 insertions(+), 72 deletions(-)
rename src/Telegram.Bot/Types/{File.cs => TGFile.cs} (94%)
diff --git a/README.md b/README.md
index b0bbd3c5f..34c3f4019 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# .NET Client for Telegram Bot API
[![Nuget](https://img.shields.io/nuget/vpre/Telegram.Bot.svg?label=Telegram.Bot&style=flat-square&color=d8b541)](https://www.nuget.org/packages/Telegram.Bot)
-[![Bot API Version](https://img.shields.io/badge/Bot_API-8.1-f36caf.svg?style=flat-square)](https://core.telegram.org/bots/api)
+[![Bot API 8.1](https://img.shields.io/badge/Bot_API-8.1-f36caf.svg?style=flat-square)](https://core.telegram.org/bots/api)
[![Documentations](https://img.shields.io/badge/Documentations-Book-orange.svg?style=flat-square)](https://telegrambots.github.io/book/)
[![Telegram Chat](https://img.shields.io/badge/Support_Chat-Telegram-blue.svg?style=flat-square)](https://t.me/joinchat/B35YY0QbLfd034CFnvCtCA)
[![Master build](https://img.shields.io/azure-devops/build/tgbots/14f9ab3f-313a-4339-8534-e8b96c7763cc/6?style=flat-square&label=master)](https://dev.azure.com/tgbots/Telegram.Bot/_build/latest?definitionId=6&branchName=master)
diff --git a/src/Telegram.Bot/GlobalUsings.cs b/src/Telegram.Bot/GlobalUsings.cs
index f40238632..a744ead31 100644
--- a/src/Telegram.Bot/GlobalUsings.cs
+++ b/src/Telegram.Bot/GlobalUsings.cs
@@ -4,6 +4,7 @@
global using System.Collections.Generic;
global using System.Diagnostics.CodeAnalysis;
global using System.Net.Http;
+global using System.IO;
global using System.Text.Json;
global using System.Text.Json.Serialization;
global using Telegram.Bot.Extensions;
@@ -15,6 +16,4 @@
global using Telegram.Bot.Types.Passport;
global using Telegram.Bot.Types.Payments;
global using Telegram.Bot.Types.ReplyMarkups;
-global using File = Telegram.Bot.Types.File;
-global using Stream = System.IO.Stream;
global using LabeledPrice = Telegram.Bot.Types.Payments.LabeledPrice;
diff --git a/src/Telegram.Bot/ITelegramBotClient.cs b/src/Telegram.Bot/ITelegramBotClient.cs
index 84f203ad8..2eae8b920 100644
--- a/src/Telegram.Bot/ITelegramBotClient.cs
+++ b/src/Telegram.Bot/ITelegramBotClient.cs
@@ -71,8 +71,8 @@ public static partial class TelegramBotClientExtensions
/// File identifier to get info about
/// Destination stream to write file to
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation
- /// On success, a object is returned.
- public static async Task GetInfoAndDownloadFile(this ITelegramBotClient botClient, string fileId, Stream destination,
+ /// On success, a object is returned.
+ public static async Task GetInfoAndDownloadFile(this ITelegramBotClient botClient, string fileId, Stream destination,
CancellationToken cancellationToken = default)
{
var file = await botClient.ThrowIfNull().SendRequest(new Requests.GetFileRequest { FileId = fileId },
diff --git a/src/Telegram.Bot/Requests/Available methods/Get Files/GetFileRequest.cs b/src/Telegram.Bot/Requests/Available methods/Get Files/GetFileRequest.cs
index 43d963d12..19f350c1b 100644
--- a/src/Telegram.Bot/Requests/Available methods/Get Files/GetFileRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Get Files/GetFileRequest.cs
@@ -1,7 +1,7 @@
namespace Telegram.Bot.Requests;
-/// Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size.Returns: A object is returned. The file can then be downloaded via DownloadFile, where <FilePath> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling GetFile again.
Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received.
-public partial class GetFileRequest() : RequestBase("getFile")
+/// Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size.Returns: A object is returned. The file can then be downloaded via DownloadFile, where <FilePath> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling GetFile again.
Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received.
+public partial class GetFileRequest() : RequestBase("getFile")
{
/// File identifier to get information about
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
diff --git a/src/Telegram.Bot/Requests/Stickers/UploadStickerFileRequest.cs b/src/Telegram.Bot/Requests/Stickers/UploadStickerFileRequest.cs
index c17f731d3..90045ca64 100644
--- a/src/Telegram.Bot/Requests/Stickers/UploadStickerFileRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/UploadStickerFileRequest.cs
@@ -1,7 +1,7 @@
namespace Telegram.Bot.Requests;
-/// Use this method to upload a file with a sticker for later use in the CreateNewStickerSet, AddStickerToSet, or ReplaceStickerInSet methods (the file can be used multiple times).Returns: The uploaded on success.
-public partial class UploadStickerFileRequest() : FileRequestBase("uploadStickerFile"), IUserTargetable
+/// Use this method to upload a file with a sticker for later use in the CreateNewStickerSet, AddStickerToSet, or ReplaceStickerInSet methods (the file can be used multiple times).Returns: The uploaded on success.
+public partial class UploadStickerFileRequest() : FileRequestBase("uploadStickerFile"), IUserTargetable
{
/// User identifier of sticker file owner
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
diff --git a/src/Telegram.Bot/Serialization/JsonBotSerializerContext.cs b/src/Telegram.Bot/Serialization/JsonBotSerializerContext.cs
index f51882839..d76da5223 100644
--- a/src/Telegram.Bot/Serialization/JsonBotSerializerContext.cs
+++ b/src/Telegram.Bot/Serialization/JsonBotSerializerContext.cs
@@ -152,7 +152,7 @@ namespace Telegram.Bot;
[JsonSerializable(typeof(ApiResponse))]
[JsonSerializable(typeof(ApiResponse))]
[JsonSerializable(typeof(ApiResponse))]
-[JsonSerializable(typeof(ApiResponse))]
+[JsonSerializable(typeof(ApiResponse))]
[JsonSerializable(typeof(ApiResponse))]
[JsonSerializable(typeof(ApiResponse))]
[JsonSerializable(typeof(ApiResponse))]
diff --git a/src/Telegram.Bot/TelegramBotClientExtensions.ApiMethods.cs b/src/Telegram.Bot/TelegramBotClientExtensions.ApiMethods.cs
index d4b388aac..3e1f9f3c0 100644
--- a/src/Telegram.Bot/TelegramBotClientExtensions.ApiMethods.cs
+++ b/src/Telegram.Bot/TelegramBotClientExtensions.ApiMethods.cs
@@ -1699,8 +1699,8 @@ public static Task SetUserEmojiStatusAsync(
/// An instance of
/// File identifier to get information about
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation
- /// A object is returned. The file can then be downloaded via DownloadFile, where <FilePath> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling GetFile again.
Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received.
- public static async Task GetFile(
+ /// A object is returned. The file can then be downloaded via DownloadFile, where <FilePath> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling GetFile again.
Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received.
+ public static async Task GetFile(
this ITelegramBotClient botClient,
string fileId,
CancellationToken cancellationToken = default
@@ -1711,7 +1711,7 @@ public static async Task GetFile(
/// We removed all Async suffix from method names. Use GetFile instead
[Obsolete("We removed all Async suffix from method names. Use GetFile instead")]
- public static Task GetFileAsync(
+ public static Task GetFileAsync(
this ITelegramBotClient botClient,
string fileId,
CancellationToken cancellationToken = default
@@ -4008,8 +4008,8 @@ public static Task GetCustomEmojiStickersAsync(
/// A file with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. See https://core.telegram.org/stickers for technical requirements. More information on Sending Files »
/// Format of the sticker, must be one of Static, Animated, Video
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation
- /// The uploaded on success.
- public static async Task UploadStickerFile(
+ /// The uploaded on success.
+ public static async Task UploadStickerFile(
this ITelegramBotClient botClient,
long userId,
InputFileStream sticker,
@@ -4024,7 +4024,7 @@ public static async Task UploadStickerFile(
/// We removed all Async suffix from method names. Use UploadStickerFile instead
[Obsolete("We removed all Async suffix from method names. Use UploadStickerFile instead")]
- public static Task UploadStickerFileAsync(
+ public static Task UploadStickerFileAsync(
this ITelegramBotClient botClient,
long userId,
InputFileStream sticker,
diff --git a/src/Telegram.Bot/Types/Sticker.cs b/src/Telegram.Bot/Types/Sticker.cs
index 2b7d3ca07..0c006c9a0 100644
--- a/src/Telegram.Bot/Types/Sticker.cs
+++ b/src/Telegram.Bot/Types/Sticker.cs
@@ -31,7 +31,7 @@ public partial class Sticker : FileBase
public string? SetName { get; set; }
/// Optional. For premium regular stickers, premium animation for the sticker
- public File? PremiumAnimation { get; set; }
+ public TGFile? PremiumAnimation { get; set; }
/// Optional. For mask stickers, the position where the mask should be placed
public MaskPosition? MaskPosition { get; set; }
diff --git a/src/Telegram.Bot/Types/File.cs b/src/Telegram.Bot/Types/TGFile.cs
similarity index 94%
rename from src/Telegram.Bot/Types/File.cs
rename to src/Telegram.Bot/Types/TGFile.cs
index f89e79671..9820e27ba 100644
--- a/src/Telegram.Bot/Types/File.cs
+++ b/src/Telegram.Bot/Types/TGFile.cs
@@ -2,7 +2,7 @@ namespace Telegram.Bot.Types;
/// This object represents a file ready to be downloaded. The file can be downloaded via DownloadFile. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling GetFile.
/// The maximum file size to download is 20 MB
-public partial class File : FileBase
+public partial class TGFile : FileBase
{
/// Optional. File path. Use DownloadFile to get the file.
public string? FilePath { get; set; }
diff --git a/test/Telegram.Bot.Tests.Integ/Admin Bot/ChannelAdminBotTests.cs b/test/Telegram.Bot.Tests.Integ/Admin Bot/ChannelAdminBotTests.cs
index 5b9211c45..913a6c4a7 100644
--- a/test/Telegram.Bot.Tests.Integ/Admin Bot/ChannelAdminBotTests.cs
+++ b/test/Telegram.Bot.Tests.Integ/Admin Bot/ChannelAdminBotTests.cs
@@ -103,7 +103,7 @@ public async Task Should_Get_Chat_With_No_Pinned_Message()
[Trait(Constants.MethodTraitName, Constants.TelegramBotApiMethods.SetChatPhoto)]
public async Task Should_Set_Chat_Photo()
{
- await using Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Photos.Logo);
+ await using Stream stream = File.OpenRead(Constants.PathToFile.Photos.Logo);
await BotClient.WithStreams(stream).SetChatPhoto(
chatId: classFixture.Chat.Id,
photo: InputFile.FromStream(stream)
diff --git a/test/Telegram.Bot.Tests.Integ/Admin Bot/SupergroupAdminBotTests.cs b/test/Telegram.Bot.Tests.Integ/Admin Bot/SupergroupAdminBotTests.cs
index d60f51754..c8a471b7d 100644
--- a/test/Telegram.Bot.Tests.Integ/Admin Bot/SupergroupAdminBotTests.cs
+++ b/test/Telegram.Bot.Tests.Integ/Admin Bot/SupergroupAdminBotTests.cs
@@ -190,7 +190,7 @@ public async Task Should_Get_Chat_With_No_Pinned_Message()
[Trait(Constants.MethodTraitName, Constants.TelegramBotApiMethods.SetChatPhoto)]
public async Task Should_Set_Chat_Photo()
{
- await using Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Photos.Logo);
+ await using Stream stream = File.OpenRead(Constants.PathToFile.Photos.Logo);
await BotClient.WithStreams(stream).SetChatPhoto(
chatId: classFixture.Chat.Id,
photo: InputFile.FromStream(stream)
diff --git a/test/Telegram.Bot.Tests.Integ/Inline Mode/InlineQueryTests.cs b/test/Telegram.Bot.Tests.Integ/Inline Mode/InlineQueryTests.cs
index dae50eb98..10e7da745 100644
--- a/test/Telegram.Bot.Tests.Integ/Inline Mode/InlineQueryTests.cs
+++ b/test/Telegram.Bot.Tests.Integ/Inline Mode/InlineQueryTests.cs
@@ -278,7 +278,7 @@ await Fixture.UpdateReceiver.GetInlineQueryResultUpdates(
public async Task Should_Answer_Inline_Query_With_Cached_Photo()
{
Message photoMessage;
- await using (FileStream stream = System.IO.File.OpenRead(Constants.PathToFile.Photos.Apes))
+ await using (FileStream stream = File.OpenRead(Constants.PathToFile.Photos.Apes))
{
photoMessage = await BotClient.WithStreams(stream).SendPhoto(
chatId: Fixture.SupergroupChat,
@@ -505,7 +505,7 @@ await Fixture.UpdateReceiver.GetInlineQueryResultUpdates(
public async Task Should_Answer_Inline_Query_With_Cached_Audio()
{
Message audioMessage;
- await using (FileStream stream = System.IO.File.OpenRead(Constants.PathToFile.Audio.CantinaRagMp3))
+ await using (FileStream stream = File.OpenRead(Constants.PathToFile.Audio.CantinaRagMp3))
{
audioMessage = await BotClient.WithStreams(stream).SendAudio(
chatId: Fixture.SupergroupChat,
@@ -595,7 +595,7 @@ await Fixture.UpdateReceiver.GetInlineQueryResultUpdates(
public async Task Should_Answer_Inline_Query_With_Cached_Voice()
{
Message voiceMessage;
- await using (FileStream stream = System.IO.File.OpenRead(Constants.PathToFile.Audio.TestOgg))
+ await using (FileStream stream = File.OpenRead(Constants.PathToFile.Audio.TestOgg))
{
voiceMessage = await BotClient.WithStreams(stream).SendVoice(
chatId: Fixture.SupergroupChat,
@@ -685,7 +685,7 @@ await Fixture.UpdateReceiver.GetInlineQueryResultUpdates(
public async Task Should_Answer_Inline_Query_With_Cached_Document()
{
Message documentMessage;
- await using (FileStream stream = System.IO.File.OpenRead(Constants.PathToFile.Documents.Hamlet))
+ await using (FileStream stream = File.OpenRead(Constants.PathToFile.Documents.Hamlet))
{
documentMessage = await BotClient.WithStreams(stream).SendDocument(
chatId: Fixture.SupergroupChat,
diff --git a/test/Telegram.Bot.Tests.Integ/Other/FileDownloadTests.cs b/test/Telegram.Bot.Tests.Integ/Other/FileDownloadTests.cs
index c5070026e..cc91ee62b 100644
--- a/test/Telegram.Bot.Tests.Integ/Other/FileDownloadTests.cs
+++ b/test/Telegram.Bot.Tests.Integ/Other/FileDownloadTests.cs
@@ -6,7 +6,6 @@
using Telegram.Bot.Types;
using Xunit;
using Xunit.Abstractions;
-using File = Telegram.Bot.Types.File;
namespace Telegram.Bot.Tests.Integ.Other;
@@ -24,7 +23,7 @@ public async Task Should_Get_File_Info()
#region Send Document
Message documentMessage;
- await using (Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Documents.Hamlet))
+ await using (FileStream stream = File.OpenRead(Constants.PathToFile.Documents.Hamlet))
{
fileSize = stream.Length;
documentMessage = await BotClient.WithStreams(stream).SendDocument(
@@ -37,7 +36,7 @@ public async Task Should_Get_File_Info()
#endregion
- File file = await BotClient.GetFile(documentMessage.Document.FileId);
+ TGFile file = await BotClient.GetFile(documentMessage.Document.FileId);
Assert.Equal(fileId, file.FileId);
Assert.NotNull(file.FileSize);
@@ -56,7 +55,7 @@ public async Task Should_Download_Write_Using_FilePath()
string destinationFilePath = $"{Path.GetTempFileName()}.{ClassFixture.FileType}";
output.WriteLine($@"Writing file to ""{destinationFilePath}""");
- await using FileStream fileStream = System.IO.File.OpenWrite(destinationFilePath);
+ await using FileStream fileStream = File.OpenWrite(destinationFilePath);
await BotClient.DownloadFile(
filePath: classFixture.File.FilePath!,
destination: fileStream
@@ -74,8 +73,8 @@ public async Task Should_Download_Write_Using_FileId()
string destinationFilePath = $"{Path.GetTempFileName()}.{ClassFixture.FileType}";
output.WriteLine($@"Writing file to ""{destinationFilePath}""");
- await using FileStream fileStream = System.IO.File.OpenWrite(destinationFilePath);
- File file = await BotClient.GetInfoAndDownloadFile(
+ await using FileStream fileStream = File.OpenWrite(destinationFilePath);
+ TGFile file = await BotClient.GetInfoAndDownloadFile(
fileId: classFixture.File.FileId,
destination: fileStream
);
@@ -114,6 +113,6 @@ public class ClassFixture
{
public const string FileType = "pdf";
- public File File { get; set; }
+ public TGFile File { get; set; }
}
}
diff --git a/test/Telegram.Bot.Tests.Integ/Sending Messages/AlbumMessageTests.cs b/test/Telegram.Bot.Tests.Integ/Sending Messages/AlbumMessageTests.cs
index 50c1dc821..3fbfd959b 100644
--- a/test/Telegram.Bot.Tests.Integ/Sending Messages/AlbumMessageTests.cs
+++ b/test/Telegram.Bot.Tests.Integ/Sending Messages/AlbumMessageTests.cs
@@ -20,8 +20,8 @@ public async Task Should_Upload_2_Photos_Album()
{
Message[] messages;
await using (Stream
- stream1 = System.IO.File.OpenRead(Constants.PathToFile.Photos.Logo),
- stream2 = System.IO.File.OpenRead(Constants.PathToFile.Photos.Bot)
+ stream1 = File.OpenRead(Constants.PathToFile.Photos.Logo),
+ stream2 = File.OpenRead(Constants.PathToFile.Photos.Bot)
)
{
messages = await BotClient.WithStreams(stream1, stream2).SendMediaGroup(
@@ -109,9 +109,9 @@ public async Task Should_Upload_2_Videos_Album()
{
Message[] messages;
await using (Stream
- stream0 = System.IO.File.OpenRead(Constants.PathToFile.Videos.GoldenRatio),
- stream1 = System.IO.File.OpenRead(Constants.PathToFile.Videos.MoonLanding),
- stream2 = System.IO.File.OpenRead(Constants.PathToFile.Photos.Bot)
+ stream0 = File.OpenRead(Constants.PathToFile.Videos.GoldenRatio),
+ stream1 = File.OpenRead(Constants.PathToFile.Videos.MoonLanding),
+ stream2 = File.OpenRead(Constants.PathToFile.Photos.Bot)
)
{
messages = await BotClient.WithStreams(stream0, stream1, stream2).SendMediaGroup(
@@ -167,8 +167,8 @@ public async Task Should_Upload_2_Videos_Album()
public async Task Should_Upload_2_Photos_Album_With_Markdown_Encoded_Captions()
{
await using Stream
- stream1 = System.IO.File.OpenRead(Constants.PathToFile.Photos.Logo),
- stream2 = System.IO.File.OpenRead(Constants.PathToFile.Photos.Bot);
+ stream1 = File.OpenRead(Constants.PathToFile.Photos.Logo),
+ stream2 = File.OpenRead(Constants.PathToFile.Photos.Bot);
Message[] messages = await BotClient.WithStreams(stream1, stream2).SendMediaGroup(
@@ -210,8 +210,8 @@ public async Task Should_Upload_2_Photos_Album_With_Markdown_Encoded_Captions()
public async Task Should_Video_With_Thumbnail_In_Album()
{
await using Stream
- stream1 = System.IO.File.OpenRead(Constants.PathToFile.Videos.GoldenRatio),
- stream2 = System.IO.File.OpenRead(Constants.PathToFile.Thumbnail.Video);
+ stream1 = File.OpenRead(Constants.PathToFile.Videos.GoldenRatio),
+ stream2 = File.OpenRead(Constants.PathToFile.Thumbnail.Video);
Message[] messages = await BotClient.WithStreams(stream1, stream2).SendMediaGroup(
chatId: Fixture.SupergroupChat.Id,
diff --git a/test/Telegram.Bot.Tests.Integ/Sending Messages/AnimationMessageTests.cs b/test/Telegram.Bot.Tests.Integ/Sending Messages/AnimationMessageTests.cs
index 8e937b033..2e4a812ed 100644
--- a/test/Telegram.Bot.Tests.Integ/Sending Messages/AnimationMessageTests.cs
+++ b/test/Telegram.Bot.Tests.Integ/Sending Messages/AnimationMessageTests.cs
@@ -17,7 +17,7 @@ public class AnimationMessageTests(TestsFixture fixture) : TestClass(fixture)
public async Task Should_Send_Animation()
{
Message message;
- await using (Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Animation.Earth))
+ await using (Stream stream = File.OpenRead(Constants.PathToFile.Animation.Earth))
{
message = await BotClient.WithStreams(stream).SendAnimation(
chatId: Fixture.SupergroupChat.Id,
@@ -62,8 +62,8 @@ public async Task Should_Send_Animation_With_Thumb()
{
Message message;
await using (Stream
- stream1 = System.IO.File.OpenRead(Constants.PathToFile.Animation.Earth),
- stream2 = System.IO.File.OpenRead(Constants.PathToFile.Thumbnail.TheAbilityToBreak)
+ stream1 = File.OpenRead(Constants.PathToFile.Animation.Earth),
+ stream2 = File.OpenRead(Constants.PathToFile.Thumbnail.TheAbilityToBreak)
)
{
message = await BotClient.WithStreams(stream1, stream2).SendAnimation(
diff --git a/test/Telegram.Bot.Tests.Integ/Sending Messages/AudioMessageTests.cs b/test/Telegram.Bot.Tests.Integ/Sending Messages/AudioMessageTests.cs
index c9c97e036..047a34e26 100644
--- a/test/Telegram.Bot.Tests.Integ/Sending Messages/AudioMessageTests.cs
+++ b/test/Telegram.Bot.Tests.Integ/Sending Messages/AudioMessageTests.cs
@@ -21,7 +21,7 @@ public async Task Should_Send_Audio()
const string caption = "Audio File in .mp3 format";
Message message;
- await using (Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Audio.CantinaRagMp3))
+ await using (Stream stream = File.OpenRead(Constants.PathToFile.Audio.CantinaRagMp3))
{
message = await BotClient.WithStreams(stream).SendAudio(
chatId: Fixture.SupergroupChat,
@@ -53,8 +53,8 @@ public async Task Should_Send_Audio_With_Thumb()
// Both audio file and its thumbnail should be uploaded
Message message;
await using (Stream
- stream1 = System.IO.File.OpenRead(Constants.PathToFile.Audio.AStateOfDespairMp3),
- stream2 = System.IO.File.OpenRead(Constants.PathToFile.Thumbnail.TheAbilityToBreak)
+ stream1 = File.OpenRead(Constants.PathToFile.Audio.AStateOfDespairMp3),
+ stream2 = File.OpenRead(Constants.PathToFile.Thumbnail.TheAbilityToBreak)
)
{
message = await BotClient.WithStreams(stream1, stream2).SendAudio(
@@ -81,7 +81,7 @@ public async Task Should_Send_Voice()
const string caption = "Test Voice in .ogg format";
Message message;
- await using (Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Audio.TestOgg))
+ await using (Stream stream = File.OpenRead(Constants.PathToFile.Audio.TestOgg))
{
message = await BotClient.WithStreams(stream).SendVoice(
chatId: Fixture.SupergroupChat,
diff --git a/test/Telegram.Bot.Tests.Integ/Sending Messages/DocumentMessageTests.cs b/test/Telegram.Bot.Tests.Integ/Sending Messages/DocumentMessageTests.cs
index 7df6ba7ec..19c71d943 100644
--- a/test/Telegram.Bot.Tests.Integ/Sending Messages/DocumentMessageTests.cs
+++ b/test/Telegram.Bot.Tests.Integ/Sending Messages/DocumentMessageTests.cs
@@ -15,7 +15,7 @@ public class SendingDocumentMessageTests(TestsFixture fixture) : TestClass(fixtu
[Trait(Constants.MethodTraitName, Constants.TelegramBotApiMethods.SendDocument)]
public async Task Should_Send_Pdf_Document()
{
- await using Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Documents.Hamlet);
+ await using Stream stream = File.OpenRead(Constants.PathToFile.Documents.Hamlet);
Message message = await BotClient.WithStreams(stream).SendDocument(
chatId: Fixture.SupergroupChat.Id,
document: InputFile.FromStream(stream, "HAMLET.pdf"),
@@ -39,7 +39,7 @@ public async Task Should_Send_Pdf_Document()
[Trait(Constants.MethodTraitName, Constants.TelegramBotApiMethods.SendDocument)]
public async Task Should_Send_Document_With_Farsi_Name()
{
- await using Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Documents.Hamlet);
+ await using Stream stream = File.OpenRead(Constants.PathToFile.Documents.Hamlet);
Message message = await BotClient.WithStreams(stream).SendDocument(
chatId: Fixture.SupergroupChat.Id,
document: InputFile.FromStream(stream, "هملت.pdf"),
@@ -62,8 +62,8 @@ public async Task Should_Send_Document_With_Farsi_Name()
public async Task Should_Send_Document_With_Thumb()
{
await using Stream
- documentStream = System.IO.File.OpenRead(Constants.PathToFile.Documents.Hamlet),
- thumbStream = System.IO.File.OpenRead(Constants.PathToFile.Thumbnail.TheAbilityToBreak);
+ documentStream = File.OpenRead(Constants.PathToFile.Documents.Hamlet),
+ thumbStream = File.OpenRead(Constants.PathToFile.Thumbnail.TheAbilityToBreak);
Message message = await BotClient.WithStreams(documentStream, thumbStream).SendDocument(
chatId: Fixture.SupergroupChat,
diff --git a/test/Telegram.Bot.Tests.Integ/Sending Messages/SendingPhotoMessageTests.cs b/test/Telegram.Bot.Tests.Integ/Sending Messages/SendingPhotoMessageTests.cs
index 733024943..e56ae2186 100644
--- a/test/Telegram.Bot.Tests.Integ/Sending Messages/SendingPhotoMessageTests.cs
+++ b/test/Telegram.Bot.Tests.Integ/Sending Messages/SendingPhotoMessageTests.cs
@@ -19,7 +19,7 @@ public class SendingPhotoMessageTests(TestsFixture fixture, EntityFixture tuple.EncodedEntity));
Message message = await BotClient.WithStreams(stream).SendPhoto(
chatId: Fixture.SupergroupChat.Id,
diff --git a/test/Telegram.Bot.Tests.Integ/Sending Messages/VideoMessageTests.cs b/test/Telegram.Bot.Tests.Integ/Sending Messages/VideoMessageTests.cs
index 2f636ef86..850ac2658 100644
--- a/test/Telegram.Bot.Tests.Integ/Sending Messages/VideoMessageTests.cs
+++ b/test/Telegram.Bot.Tests.Integ/Sending Messages/VideoMessageTests.cs
@@ -16,7 +16,7 @@ public class SendingVideoMessageTests(TestsFixture fixture) : TestClass(fixture)
public async Task Should_Send_Video()
{
Message message;
- await using (Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Videos.MoonLanding))
+ await using (Stream stream = File.OpenRead(Constants.PathToFile.Videos.MoonLanding))
{
message = await BotClient.WithStreams(stream).SendVideo(
chatId: Fixture.SupergroupChat.Id,
@@ -53,7 +53,7 @@ public async Task Should_Send_Video()
public async Task Should_Send_Video_Note()
{
Message message;
- await using (Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Videos.GoldenRatio))
+ await using (Stream stream = File.OpenRead(Constants.PathToFile.Videos.GoldenRatio))
{
message = await BotClient.WithStreams(stream).SendVideoNote(
chatId: Fixture.SupergroupChat.Id,
@@ -84,8 +84,8 @@ public async Task Should_Send_Video_With_Thumb()
{
Message message;
await using (Stream
- stream1 = System.IO.File.OpenRead(Constants.PathToFile.Videos.MoonLanding),
- stream2 = System.IO.File.OpenRead(Constants.PathToFile.Thumbnail.TheAbilityToBreak)
+ stream1 = File.OpenRead(Constants.PathToFile.Videos.MoonLanding),
+ stream2 = File.OpenRead(Constants.PathToFile.Thumbnail.TheAbilityToBreak)
)
{
message = await BotClient.WithStreams(stream1, stream2).SendVideo(
@@ -111,8 +111,8 @@ public async Task Should_Send_Video_Note_With_Thumb()
{
Message message;
await using (Stream
- stream1 = System.IO.File.OpenRead(Constants.PathToFile.Videos.GoldenRatio),
- stream2 = System.IO.File.OpenRead(Constants.PathToFile.Thumbnail.Video)
+ stream1 = File.OpenRead(Constants.PathToFile.Videos.GoldenRatio),
+ stream2 = File.OpenRead(Constants.PathToFile.Thumbnail.Video)
)
{
message = await BotClient.WithStreams(stream1, stream2).SendVideoNote(
diff --git a/test/Telegram.Bot.Tests.Integ/Stickers/StickersTests.cs b/test/Telegram.Bot.Tests.Integ/Stickers/StickersTests.cs
index 47628119e..146337016 100644
--- a/test/Telegram.Bot.Tests.Integ/Stickers/StickersTests.cs
+++ b/test/Telegram.Bot.Tests.Integ/Stickers/StickersTests.cs
@@ -23,7 +23,7 @@ public async Task Should_Upload_Static_Sticker_File()
{
await using System.IO.Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Sticker.Regular.StaticFirst);
- File file = await BotClient.UploadStickerFile(
+ TGFile file = await BotClient.UploadStickerFile(
userId: classFixture.OwnerUserId,
sticker: new(stream),
stickerFormat: StickerFormat.Static
@@ -41,7 +41,7 @@ public async Task Should_Upload_Animated_Sticker_File()
{
await using System.IO.Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Sticker.Regular.AnimatedFirst);
- File file = await BotClient.UploadStickerFile(
+ TGFile file = await BotClient.UploadStickerFile(
userId: classFixture.OwnerUserId,
sticker: new(stream),
stickerFormat: StickerFormat.Animated
@@ -59,7 +59,7 @@ public async Task Should_Upload_Video_Sticker_File()
{
await using System.IO.Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Sticker.Regular.VideoFirst);
- File file = await BotClient.UploadStickerFile(
+ TGFile file = await BotClient.UploadStickerFile(
userId: classFixture.OwnerUserId,
sticker: new(stream),
stickerFormat: StickerFormat.Video
diff --git a/test/Telegram.Bot.Tests.Integ/Stickers/StickersTestsFixture.cs b/test/Telegram.Bot.Tests.Integ/Stickers/StickersTestsFixture.cs
index 1596e9ce2..c41b21066 100644
--- a/test/Telegram.Bot.Tests.Integ/Stickers/StickersTestsFixture.cs
+++ b/test/Telegram.Bot.Tests.Integ/Stickers/StickersTestsFixture.cs
@@ -36,19 +36,19 @@ protected override IEnumerable> Initializers() =>
//Regular stickers
public string TestStaticRegularStickerSetName { get; } = $"test_static_regular_set_by_{testsFixture.BotUser.Username}";
- public File TestUploadedStaticStickerFile { get; set; }
+ public TGFile TestUploadedStaticStickerFile { get; set; }
public StickerSet TestStaticRegularStickerSet { get; set; }
public string TestAnimatedRegularStickerSetName { get; } = $"test_animated_regular_set_by_{testsFixture.BotUser.Username}";
- public File TestUploadedAnimatedStickerFile { get; set; }
+ public TGFile TestUploadedAnimatedStickerFile { get; set; }
public StickerSet TestAnimatedRegularStickerSet { get; set; }
public string TestVideoRegularStickerSetName { get; } = $"test_video_regular_set_by_{testsFixture.BotUser.Username}";
- public File TestUploadedVideoStickerFile { get; set; }
+ public TGFile TestUploadedVideoStickerFile { get; set; }
public StickerSet TestVideoRegularStickerSet { get; set; }
diff --git a/test/Telegram.Bot.Tests.Integ/Update Messages/EditMessageContentTests2.cs b/test/Telegram.Bot.Tests.Integ/Update Messages/EditMessageContentTests2.cs
index f4f1eb363..1b7554956 100644
--- a/test/Telegram.Bot.Tests.Integ/Update Messages/EditMessageContentTests2.cs
+++ b/test/Telegram.Bot.Tests.Integ/Update Messages/EditMessageContentTests2.cs
@@ -88,7 +88,7 @@ public async Task Should_Edit_Message_Markup()
public async Task Should_Edit_Message_Caption()
{
Message originalMessage;
- await using (Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Photos.Bot))
+ await using (Stream stream = File.OpenRead(Constants.PathToFile.Photos.Bot))
{
originalMessage = await BotClient.WithStreams(stream).SendPhoto(
chatId: Fixture.SupergroupChat.Id,
diff --git a/test/Telegram.Bot.Tests.Integ/Update Messages/EditMessageMediaTests.cs b/test/Telegram.Bot.Tests.Integ/Update Messages/EditMessageMediaTests.cs
index 0317ad67f..807b6586f 100644
--- a/test/Telegram.Bot.Tests.Integ/Update Messages/EditMessageMediaTests.cs
+++ b/test/Telegram.Bot.Tests.Integ/Update Messages/EditMessageMediaTests.cs
@@ -72,7 +72,7 @@ await BotClient.EditMessageMedia(
public async Task Should_Edit_Inline_Message_Document_With_FileId()
{
// Upload a GIF file to Telegram servers and obtain its file_id. This file_id will be used later in test.
- await using Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Animation.Earth);
+ await using Stream stream = File.OpenRead(Constants.PathToFile.Animation.Earth);
Message gifMessage = await BotClient.WithStreams(stream).SendDocument(
chatId: Fixture.SupergroupChat,
document: InputFile.FromStream(stream, "Earth.gif"),
diff --git a/test/Telegram.Bot.Tests.Integ/Update Messages/EditMessageMediaTests2.cs b/test/Telegram.Bot.Tests.Integ/Update Messages/EditMessageMediaTests2.cs
index 9a457cb40..b11559ba0 100644
--- a/test/Telegram.Bot.Tests.Integ/Update Messages/EditMessageMediaTests2.cs
+++ b/test/Telegram.Bot.Tests.Integ/Update Messages/EditMessageMediaTests2.cs
@@ -19,7 +19,7 @@ public async Task Should_Edit_Message_Video()
{
// Send a video to chat. This media will be changed later in test.
Message originalMessage;
- await using (Stream stream = System.IO.File.OpenRead(Constants.PathToFile.Animation.Earth))
+ await using (Stream stream = File.OpenRead(Constants.PathToFile.Animation.Earth))
{
originalMessage = await BotClient.WithStreams(stream).SendVideo(
chatId: Fixture.SupergroupChat,
@@ -33,8 +33,8 @@ public async Task Should_Edit_Message_Video()
// Replace video with a document+thumb by uploading the new file
Message editedMessage;
await using Stream
- documentStream = System.IO.File.OpenRead(Constants.PathToFile.Certificate.PublicKey),
- thumbStream = System.IO.File.OpenRead(Constants.PathToFile.Thumbnail.Video);
+ documentStream = File.OpenRead(Constants.PathToFile.Certificate.PublicKey),
+ thumbStream = File.OpenRead(Constants.PathToFile.Thumbnail.Video);
{
editedMessage = await BotClient.WithStreams(documentStream, thumbStream).EditMessageMedia(
chatId: originalMessage.Chat,
@@ -81,7 +81,7 @@ public async Task Should_Edit_Message_Photo()
await Task.Delay(500);
// Replace audio with another audio by uploading the new file. A thumbnail image is also uploaded.
- await using Stream thumbStream = System.IO.File.OpenRead(Constants.PathToFile.Thumbnail.Video);
+ await using Stream thumbStream = File.OpenRead(Constants.PathToFile.Thumbnail.Video);
Message editedMessage = await BotClient.WithStreams(thumbStream).EditMessageMedia(
chatId: originalMessage.Chat,
messageId: originalMessage.Id,