public void TestAppealToSuccessfulPayment() { SendMessageResult sendMessage = mTelegramBot.SendMessage(mChatId, "TestAppealToTheEmptySuccessfulPayment()"); SuccessfulPaymentInfo successfulPaymentInfo = sendMessage.Result.SuccessfulPayment; ConsoleUtlis.PrintResult(successfulPaymentInfo); Assert.Multiple(() => { //SuccessfulPaymentInfo field Assert.IsInstanceOf(typeof(SuccessfulPaymentInfo), successfulPaymentInfo); Assert.IsNull(successfulPaymentInfo.Currency); Assert.AreEqual(0, successfulPaymentInfo.TotalAmmount); Assert.IsNull(successfulPaymentInfo.InvoicePayload); Assert.IsNull(successfulPaymentInfo.ShippingOptionId); Assert.IsNull(successfulPaymentInfo.TelegramPaymentChargeId); Assert.IsNull(successfulPaymentInfo.ProviderPaymentChargeId); //OrderInfo fields Assert.IsInstanceOf(typeof(OrderInfo), successfulPaymentInfo.OrderInfo); Assert.IsNull(successfulPaymentInfo.OrderInfo.Name); Assert.IsNull(successfulPaymentInfo.OrderInfo.PnoneNumber); Assert.IsNull(successfulPaymentInfo.OrderInfo.Email); //ShippingAddressInfo fields Assert.IsInstanceOf(typeof(ShippingAddressInfo), successfulPaymentInfo.OrderInfo.ShippingAddress); Assert.IsNull(successfulPaymentInfo.OrderInfo.ShippingAddress.CountryCode); Assert.IsNull(successfulPaymentInfo.OrderInfo.ShippingAddress.State); Assert.IsNull(successfulPaymentInfo.OrderInfo.ShippingAddress.City); Assert.IsNull(successfulPaymentInfo.OrderInfo.ShippingAddress.StreetLineOne); Assert.IsNull(successfulPaymentInfo.OrderInfo.ShippingAddress.StreetLineTwo); Assert.IsNull(successfulPaymentInfo.OrderInfo.ShippingAddress.PostCode); }); }
public void EditMessageTextTest() { mBotOkResponse.EditMessageText("TestText", "testChatId", 123, "testInlineMessageId", ParseMode.HTML, true, Keyboards.GetInlineKeyboard()); var request = MockServer.ServerOkResponse.SearchLogsFor( Requests.WithUrl("/botToken/editMessageText").UsingPost()); ConsoleUtlis.PrintResult(request); Assert.AreEqual("text=TestText&" + "chat_id=testChatId&" + "message_id=123&" + "inline_message_id=testInlineMessageId&" + "parse_mode=HTML&" + "disable_web_page_preview=True&" + "reply_markup=%7B%0D%0A%20%20%22inline_keyboard" + "%22%3A%20%5B%0D%0A%20%20%20%20%5B%0D%0A%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%22text" + "%22%3A%20%221%22%0D%0A%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%22text" + "%22%3A%20%222%22%0D%0A%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%5D%2C%0D%0A%20%20%20%20%5B%0D%0A%20%20%20%20%20%" + "20%7B%0D%0A%20%20%20%20%20%20%20%20%22text%22%3A%20%223%22%0D%0A%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%" + "20%7B%0D%0A%20%20%20%20%20%20%20%20%22text%22%3A%20%224%22%0D%0A%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%5D%0D%" + "0A%20%20%5D%0D%0A%7D", request.FirstOrDefault()?.Body); Assert.AreEqual("/botToken/editMessageText", request.FirstOrDefault()?.Url); Assert.Throws <Exception>( () => mBotBadResponse.EditMessageText("TestText", "testChatId", 123, "testInlineMessageId", ParseMode.HTML, true, Keyboards.GetInlineKeyboard())); }
public void SendMessageTest() { mBotOkResponse.SendMessage(123, "123", ParseMode.HTML, false, false, 123, new ForceReplyMarkup()); var request = MockServer.ServerOkResponse.SearchLogsFor(Requests.WithUrl("/botToken/sendMessage").UsingPost()); ConsoleUtlis.PrintResult(request); Assert.Multiple(() => { Assert.AreEqual("chat_id=123&" + "text=123&parse_mode=HTML&" + "disable_web_page_preview=False&" + "disable_notification=False&" + "reply_to_message_id=123&" + "reply_markup=%7B%0D%0A%20%20%22force_reply%22%3A%20true%0D%0A%7D", request.FirstOrDefault()?.Body); Assert.AreEqual("/botToken/sendMessage", request.FirstOrDefault()?.Url); Assert.Throws <Exception>( () => mBotBadResponse.SendMessage(123, "123", ParseMode.HTML, false, false, 123, new ForceReplyMarkup())); }); }
public void TestAppealToTheEmptySticker() { SendMessageResult sendMessage = mTelegramBot.SendMessage(mChatId, "TestAppealToTheEmptySticker()"); StickerInfo sticker = sendMessage.Result.Sticker; ConsoleUtlis.PrintResult(sticker); ConsoleUtlis.PrintResult(sticker.Thumb); Assert.Multiple(() => { Assert.True(sendMessage.Ok); Assert.IsInstanceOf(typeof(StickerInfo), sticker); Assert.IsNull(sticker.FileId); Assert.AreEqual(sticker.Width, 0); Assert.AreEqual(sticker.Height, 0); Assert.IsNull(sticker.Emoji); Assert.AreEqual(sticker.FileSize, 0); Assert.IsInstanceOf(typeof(PhotoSizeInfo), sticker.Thumb); Assert.AreEqual(sticker.Thumb.Width, 0); Assert.AreEqual(sticker.Thumb.Height, 0); Assert.IsNull(sticker.Thumb.FileId); Assert.AreEqual(sticker.Thumb.FileSize, 0); }); }
public void SendVideoNoteTest() { mBotOkResponse.SendVideoNote(123, new ExistingFile { FileId = "123" }, 123, 123, true, 123, new ForceReplyMarkup()); var request = MockServer.ServerOkResponse.SearchLogsFor(Requests.WithUrl("/botToken/sendVideoNote").UsingPost()); ConsoleUtlis.PrintResult(request); Assert.Multiple(() => { Assert.AreEqual("chat_id=123&" + "video_note=123&" + "duration=123&" + "length=123&" + "disable_notification=True&" + "reply_to_message_id=123&" + "reply_markup=%7B%0D%0A%20%20%22force_reply%22%3A%20true%0D%0A%7D", request.FirstOrDefault()?.Body); Assert.AreEqual("/botToken/sendVideoNote", request.FirstOrDefault()?.Url); Assert.Throws <Exception>(() => mBotBadResponse.SendVideoNote(123, new ExistingFile { FileId = "123" }, 123, 123, true, 123, new ForceReplyMarkup())); }); }
public void TestAppealToTheEmptyVideoNote() { SendMessageResult sendMessage = mTelegramBot.SendMessage(mChatId, "TestAppealToTheEmptyVideoNote"); VideoNoteInfo videoNote = sendMessage.Result.VideoNote; ConsoleUtlis.PrintResult(videoNote); Assert.Multiple(() => { Assert.True(sendMessage.Ok); Assert.IsInstanceOf(typeof(VideoNoteInfo), videoNote); Assert.IsNull(videoNote.FileId); Assert.AreEqual(videoNote.Length, 0); Assert.AreEqual(videoNote.Duration, 0); Assert.AreEqual(videoNote.FileSize, 0); Assert.IsInstanceOf(typeof(PhotoSizeInfo), videoNote.Thumb); Assert.AreEqual(videoNote.Thumb.Width, 0); Assert.AreEqual(videoNote.Thumb.Height, 0); Assert.IsNull(videoNote.Thumb.FileId); Assert.AreEqual(videoNote.Thumb.FileSize, 0); }); }
public void TestAppealToTheEmptyForwardFromChat() { SendMessageResult sendMessage = mTelegramBot.SendMessage(mChatId, "TestAppealToTheEmptyForwardFrom()"); ChatInfo forwardFromChat = sendMessage.Result.ForwardFromChat; ConsoleUtlis.PrintResult(forwardFromChat); ConsoleUtlis.PrintResult(forwardFromChat.Photo); Assert.Multiple(() => { Assert.True(sendMessage.Ok); Assert.IsInstanceOf(typeof(ChatInfo), forwardFromChat); Assert.AreEqual(forwardFromChat.Id, 0); Assert.IsNull(forwardFromChat.Type); Assert.IsNull(forwardFromChat.Title); Assert.IsNull(forwardFromChat.Username); Assert.IsNull(forwardFromChat.FirstName); Assert.IsNull(forwardFromChat.LastName); Assert.IsFalse(forwardFromChat.AllMembersAreAdministrators); Assert.IsNull(forwardFromChat.Description); Assert.IsNull(forwardFromChat.InviteLink); Assert.IsNull(forwardFromChat.Photo.BigFileId); Assert.IsNull(forwardFromChat.Photo.SmallFileId); }); }
public void EditMessageEditMessageReplyMarkupTest() { mBotOkResponse.EditMessageReplyMarkup("TestChatId", 123, "TestInlineMessageId", Keyboards.GetInlineKeyboard()); var request = MockServer.ServerOkResponse.SearchLogsFor( Requests.WithUrl("/botToken/editMessageReplyMarkup").UsingPost()); ConsoleUtlis.PrintResult(request); Assert.AreEqual("chat_id=TestChatId&" + "message_id=123&" + "inline_message_id=TestInlineMessageId&" + "reply_markup=%7B%0D%0A%20%20%22inline_keyboard" + "%22%3A%20%5B%0D%0A%20%20%20%20%5B%0D%0A%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%22text" + "%22%3A%20%221%22%0D%0A%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%22text" + "%22%3A%20%222%22%0D%0A%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%5D%2C%0D%0A%20%20%20%20%5B%0D%0A%20%20%20%20%20%20%" + "7B%0D%0A%20%20%20%20%20%20%20%20%22text%22%3A%20%223%22%0D%0A%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%7B%" + "0D%0A%20%20%20%20%20%20%20%20%22text%22%3A%20%224%22%0D%0A%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%5D%0D%0A%20%20%" + "5D%0D%0A%7D", request.FirstOrDefault()?.Body); Assert.AreEqual("/botToken/editMessageReplyMarkup", request.FirstOrDefault()?.Url); Assert.Throws <Exception>( () => mBotBadResponse.EditMessageReplyMarkup("TestChatId", 123, "TestInlineMessageId", Keyboards.GetInlineKeyboard())); }
public void SendMessageWithForceReplyTest() { mBotOkResponse.SendMessage(123, "Test", replyMarkup: new ForceReplyMarkup { Selective = true }); var request = MockServer.ServerOkResponse.SearchLogsFor(Requests.WithUrl("/botToken/sendMessage").UsingPost()); ConsoleUtlis.PrintResult(request); Assert.AreEqual(request.FirstOrDefault()?.Body, "chat_id=123&" + "text=Test&reply_markup=%" + "7B%0D%0A%20%20%22force_reply%22%3A%20true%2C%0D%0A%20%20%22selective%22%3A%20true%0D%0A%7D"); MockServer.ServerOkResponse.ResetRequestLogs(); mBotOkResponse.SendMessage(123, "Test", replyMarkup: new ForceReplyMarkup { Selective = false }); Assert.AreEqual(request.FirstOrDefault()?.Body, "chat_id=123&" + "text=Test&reply_markup=%" + "7B%0D%0A%20%20%22force_reply%22%3A%20true%2C%0D%0A%20%20%22selective%22%3A%20false%0D%0A%7D"); ConsoleUtlis.PrintResult(request); MockServer.ServerOkResponse.ResetRequestLogs(); }
public void SendPhotoTest() { mBotOkResponse.SendPhoto(123, new ExistingFile { FileId = "123", Url = "url" }, "caption", false, 123, new ForceReplyMarkup()); var request = MockServer.ServerOkResponse.SearchLogsFor(Requests.WithUrl("/botToken/sendPhoto").UsingPost()); ConsoleUtlis.PrintResult(request); Assert.Multiple(() => { Assert.AreEqual("chat_id=123&" + "photo=123&" + "caption=caption&" + "disable_notification=False&" + "reply_to_message_id=123&" + "reply_markup=%7B%0D%0A%20%20%22force_reply%22%3A%20true%0D%0A%7D", request.FirstOrDefault()?.Body); Assert.AreEqual("/botToken/sendPhoto", request.FirstOrDefault()?.Url); Assert.Throws <Exception>(() => mBotBadResponse.SendPhoto(123, new ExistingFile { FileId = "123" }, "caption", false, 123, new ForceReplyMarkup())); }); }
public void SendContactTest() { mBotOkResponse.SendContact(123, "123", "firstName", "lastName", true, 123, new ForceReplyMarkup()); var request = MockServer.ServerOkResponse.SearchLogsFor(Requests.WithUrl("/botToken/sendContact").UsingPost()); ConsoleUtlis.PrintResult(request); Assert.Multiple(() => { Assert.AreEqual("chat_id=123&" + "phone_number=123&" + "first_name=firstName&" + "last_name=lastName&" + "disable_notification=True&" + "reply_to_message_id=123&" + "reply_markup=%7B%0D%0A%20%20%22force_reply%22%3A%20true%0D%0A%7D", request.FirstOrDefault()?.Body); Assert.AreEqual("/botToken/sendContact", request.FirstOrDefault()?.Url); Assert.Throws <Exception>( () => mBotBadResponse.SendContact(123, "123", "firstName", "lastName", true, 123, new ForceReplyMarkup())); }); }
public void TestAppealToTheEmptyNewChatMember() { SendMessageResult sendMessage = mTelegramBot.SendMessage(mChatId, "TestAppealToTheEmptyNewChatMember()"); UserInfo newChatMember = sendMessage.Result.NewChatMember; var id = sendMessage.Result.NewChatMember.Id; var firstName = sendMessage.Result.NewChatMember.FirstName; var lastName = sendMessage.Result.NewChatMember.LastName; var userName = sendMessage.Result.NewChatMember.UserName; var languageCode = sendMessage.Result.NewChatMember.LanguageCode; ConsoleUtlis.PrintResult(newChatMember); Assert.Multiple(() => { Assert.True(sendMessage.Ok); Assert.IsInstanceOf(typeof(UserInfo), newChatMember); Assert.AreEqual(id, 0); Assert.IsNull(firstName); Assert.IsNull(lastName); Assert.IsNull(userName); Assert.IsNull(languageCode); }); }
public void SendVenueTest() { mBotOkResponse.SendVenue(123, 0, 0, "TestTitle", "TestAddress", "TestFoursquareId", true, 123, new ForceReplyMarkup()); var request = MockServer.ServerOkResponse.SearchLogsFor(Requests.WithUrl("/botToken/sendVenue").UsingPost()); ConsoleUtlis.PrintResult(request); Assert.Multiple(() => { Assert.AreEqual("chat_id=123&" + "latitude=0&" + "longitude=0&" + "title=TestTitle&address=TestAddress&" + "foursquare_id=TestFoursquareId&" + "disable_notification=True&" + "reply_to_message_id=123&" + "reply_markup=%7B%0D%0A%20%20%22force_reply%22%3A%20true%0D%0A%7D", request.FirstOrDefault()?.Body); Assert.AreEqual("/botToken/sendVenue", request.FirstOrDefault()?.Url); Assert.Throws <Exception>( () => mBotBadResponse.SendVenue(123, 0, 0, "TestTitle", "TestAddress", "TestFoursquareId", true, 123, new ForceReplyMarkup())); }); }
public void TestAppealToTheEmptyGame() { SendMessageResult sendMessage = mTelegramBot.SendMessage(mChatId, "TestAppealToTheEmptyGame()"); GameInfo gameInfo = sendMessage.Result.Game; ConsoleUtlis.PrintResult(gameInfo); Assert.Multiple(() => { //Game Assert.IsInstanceOf(typeof(GameInfo), gameInfo); Assert.IsNull(gameInfo.Title); Assert.IsNull(gameInfo.Description); Assert.IsNull(gameInfo.Text); //Game.Photo Assert.IsInstanceOf(typeof(PhotoSizeInfo[]), gameInfo.Photo); //Game.Entities Assert.IsInstanceOf(typeof(MessageEntityInfo[]), gameInfo.Entities); //Game.Animation Assert.IsNull(gameInfo.Animation.FileId); Assert.IsNull(gameInfo.Animation.FileName); Assert.IsNull(gameInfo.Animation.MimeType); Assert.AreEqual(0, gameInfo.Animation.FileSize); //Game.Animation.Thumb Assert.IsNull(gameInfo.Animation.Thumb.FileId); Assert.AreEqual(0, gameInfo.Animation.Thumb.Height); Assert.AreEqual(0, gameInfo.Animation.Thumb.Width); Assert.AreEqual(0, gameInfo.Animation.Thumb.FileSize); }); }
public void TestAppealToTheEmptyDocument() { SendMessageResult sendMessage = mTelegramBot.SendMessage(mChatId, "TestAppealToTheEmptyDocument()"); DocumentInfo document = sendMessage.Result.Document; ConsoleUtlis.PrintResult(document); ConsoleUtlis.PrintResult(document.Thumb); Assert.Multiple(() => { Assert.True(sendMessage.Ok); Assert.IsInstanceOf(typeof(DocumentInfo), document); Assert.IsNull(document.FileId); Assert.IsNull(document.FileName); Assert.IsNull(document.MimeType); Assert.AreEqual(document.FileSize, 0); Assert.IsInstanceOf(typeof(PhotoSizeInfo), document.Thumb); Assert.AreEqual(document.Thumb.Width, 0); Assert.AreEqual(document.Thumb.Height, 0); Assert.IsNull(document.Thumb.FileId); Assert.AreEqual(document.Thumb.FileSize, 0); }); }
public void TestAppealToMigrateFromPinnedMessage() { SendMessageResult sendMessage = mTelegramBot.SendMessage(mChatId, "TestAppealToMigrateFromPinnedMessage()"); MessageInfo pinnedMessage = sendMessage.Result.PinnedMessage; ConsoleUtlis.PrintResult(pinnedMessage); CommonAsserts(pinnedMessage); }
public void GetChatMemberCountTest() { IntegerResult getChatMemberCount = mTelegramBot.GetChatMembersCount(mChatGroupId); ConsoleUtlis.PrintResult(getChatMemberCount); Assert.Multiple(() => { Assert.True(getChatMemberCount.Ok); Assert.AreEqual(3, getChatMemberCount.Result); }); }
public void SendInvoiceWithOptionalParametersTest() { MockServer.ServerOkResponse.ResetRequestLogs(); var labelPrice = new[] { new LabeledPriceInfo { Label = "LableTest1", Amount = 123 }, new LabeledPriceInfo { Label = "LabelTest2", Amount = 456 } }; mBotOkResponse.SendInvoice("TestChatId", "TestTitle", "TestDescription", "TestPayload", "TestProviderToken", "TestStartParameter", Currency.USD, labelPrice, "TestPhotoUrl", 123, 456, 789, true, true, true, true, true, true, 123, new ForceReplyMarkup()); var request = MockServer.ServerOkResponse.SearchLogsFor(Requests.WithUrl("/botToken/sendInvoice").UsingPost()); ConsoleUtlis.PrintResult(request); Assert.AreEqual("chat_id=TestChatId&" + "title=TestTitle&" + "description=TestDescription&" + "payload=TestPayload&" + "provider_token=TestProviderToken&" + "start_parameter=TestStartParameter&" + "currency=USD&" + "prices=%5B%0D%0A%20%20%7B%0D%0A%20%20%20%20%22label" + "%22%3A%20%22LableTest1" + "%22%2C%0D%0A%20%20%20%20%22amount" + "%22%3A%20123%0D%0A%20%20%7D%2C%0D%0A%20%20%7B%0D%0A%20%20%20%20%22label" + "%22%3A%20%22LabelTest" + "2%22%2C%0D%0A%20%20%20%20%22amount" + "%22%3A%20456%0D%0A%20%20%7D%0D%0A%5D&photo_url=TestPhotoUrl&" + "photo_size=123&" + "photo_width=456&" + "photo_height=789&" + "need_name=True&" + "need_phone_number=True&" + "need_email=True&" + "need_shipping_address=True&" + "is_flexible=True&" + "disable_notification=True&" + "reply_to_message_id=123&" + "reply_markup=%7B%0D%0A%20%20%22force_reply" + "%22%3A%20true" + "%0D%0A%7D", request.FirstOrDefault()?.Body); Assert.AreEqual("/botToken/sendInvoice", request.FirstOrDefault()?.Url); }
public void GetsMeTest() { UserInfoResult getMe = mTelegramBot.GetsMe(); ConsoleUtlis.PrintResult(getMe.Result); Assert.Multiple(() => { Assert.True(getMe.Ok); Assert.AreEqual(getMe.Result.FirstName, "NetTelebotTestedBot"); }); }
public void SendMessageToPublicChannelTest() { SendMessageResult sendMessage = mTelegramBot.SendMessage("@telebotTestChannel", "Test"); ConsoleUtlis.PrintResult(sendMessage.Result.Chat); Assert.Multiple(() => { Assert.IsInstanceOf <long>(sendMessage.Result.Chat.Id); Assert.AreEqual(sendMessage.Result.Chat.Type, ChatType.channel); }); }
public void SendMessageToSuperGroupTest() { SendMessageResult sendMessage = mTelegramBot.SendMessage(mChatSuperGroupId, "Test"); ConsoleUtlis.PrintResult(sendMessage.Result.Chat); Assert.Multiple(() => { Assert.AreEqual(sendMessage.Result.Chat.Id, mChatSuperGroupId); Assert.AreEqual(sendMessage.Result.Chat.Type, ChatType.supergroup); Assert.IsFalse(sendMessage.Result.Chat.AllMembersAreAdministrators); }); }
public void SendMessageWithReplyKeyboardMarkupTest() { KeyboardButton line1 = new KeyboardButton { Text = "Button1", RequestContact = true, RequestLocation = false }; KeyboardButton line2 = new KeyboardButton { Text = "Button2", RequestContact = false, RequestLocation = true }; KeyboardButton line3 = new KeyboardButton { Text = "Button3" }; KeyboardButton line4 = new KeyboardButton { Text = "Button4" }; KeyboardButton[] lines1 = { line1, line2, line3, line4 }; KeyboardButton[] lines2 = { line3, line4 }; KeyboardButton[][] keyboard = { lines1, lines2 }; ReplyKeyboardMarkup replyMarkup = new ReplyKeyboardMarkup { Keyboard = keyboard, ResizeKeyboard = true, Selective = false, OneTimeKeyboard = true }; mBotOkResponse.SendMessage(123, "Test", replyMarkup: replyMarkup); var request = MockServer.ServerOkResponse.SearchLogsFor(Requests.WithUrl("/botToken/sendMessage").UsingPost()); Assert.AreEqual(request.FirstOrDefault()?.Body, "chat_id=123&" + "text=Test&" + "reply_markup=%7B%0D%0A%20%20%22keyboard%22%3A%20%5B%0D%0A%20%20%20%20%5B%0D%0A%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%22text%22%3A%20%22Button1" + "%22%2C%0D%0A%20%20%20%20%20%20%20%20%22request_contact%22%3A%20true%2C%0D%0A%20%20%20%20%20%20%20%20%22request_location%22%3A%20false" + "%0D%0A%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%22text%22%3A%20%22Button2%22%2C%0D%0A%20%20%20%20%20%20%20%20%22request_contact" + "%22%3A%20false%2C%0D%0A%20%20%20%20%20%20%20%20%22request_location%22%3A%20true%0D%0A%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%22text" + "%22%3A%20%22Button3%22%0D%0A%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%22text%22%3A%20%22Button4" + "%22%0D%0A%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%5D%2C%0D%0A%20%20%20%20%5B%0D%0A%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%22text%22%3A%20%22Button3" + "%22%0D%0A%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%22text%22%3A%20%22Button4" + "%22%0D%0A%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%5D%0D%0A%20%20%5D%2C%0D%0A%20%20%22resize_keyboard%22%3A%20true%2C%0D%0A%20%20%22" + "one_time_keyboard%22%3A%20true%2C%0D%0A%20%20%22selective%22%3A%20false%0D%0A%7D"); ConsoleUtlis.PrintResult(request); MockServer.ServerOkResponse.ResetRequestLogs(); }
public void SendInvoiceWithoutOptionalParametersTest() { MockServer.ServerOkResponse.ResetRequestLogs(); var labelPrice = new[] { new LabeledPriceInfo { Label = "LableTest1", Amount = 123 }, new LabeledPriceInfo { Label = "LabelTest2", Amount = 456 } }; mBotOkResponse.SendInvoice("TestChatId", "TestTitle", "TestDescription", "TestPayload", "TestProviderToken", "TestStartParameter", Currency.USD, labelPrice); var request = MockServer.ServerOkResponse.SearchLogsFor(Requests.WithUrl("/botToken/sendInvoice").UsingPost()); ConsoleUtlis.PrintResult(request); Assert.Multiple(() => { Assert.AreEqual("chat_id=TestChatId&" + "title=TestTitle&" + "description=TestDescription&" + "payload=TestPayload&" + "provider_token=TestProviderToken&" + "start_parameter=TestStartParameter&" + "currency=USD&" + "prices=%5B%0D%0A%20%20%7B%0D%0A%20%20%20%20%22label" + "%22%3A%20%22LableTest1" + "%22%2C%0D%0A%20%20%20%20%22amount" + "%22%3A%20123" + "%0D%0A%20%20%7D%2C%0D%0A%20%20%7B%0D%0A%20%20%20%20%22label" + "%22%3A%20%22LabelTest2" + "%22%2C%0D%0A%20%20%20%20%22amount" + "%22%3A%20456%0D%0A%20%20%7D%0D%0A%5D&" + "need_name=False&" + "need_phone_number=False&" + "need_email=False&" + "need_shipping_address=False&" + "is_flexible=False", request.FirstOrDefault()?.Body); Assert.AreEqual("/botToken/sendInvoice", request.FirstOrDefault()?.Url); Assert.Throws <Exception>( () => mBotBadResponse.SendInvoice("TestChatId", "TestTitle", "TestDescription", "TestPayload", "TestProviderToken", "TestStartParameter", Currency.USD, labelPrice)); }); }
public static void GetUpdatesWithTimeout() { MockServer.ServerOkResponse.ResetRequestLogs(); MockServer.AddNewRouter("/botToken/getUpdates*", ResponseStringGetUpdatesResult.ExpectedBodyWithObjectMessage); mBotOkResponse.GetUpdates(timeout: 10); var request = MockServer.ServerOkResponse.SearchLogsFor(Requests.WithUrl("/botToken/getUpdates*").UsingPost()); ConsoleUtlis.PrintResult(request); Assert.AreEqual("/botToken/getUpdates?timeout=10", request.FirstOrDefault()?.Url); }
public void GetChatFromGroupTest() { ChatInfoResult getChatResult = mTelegramBot.GetChat(mChatGroupId); ConsoleUtlis.PrintResult(getChatResult.Result); Assert.Multiple(() => { Assert.True(getChatResult.Ok); Assert.AreEqual(getChatResult.Result.Id, mChatGroupId); Assert.AreEqual(getChatResult.Result.Type, ChatType.@group); Assert.AreEqual(getChatResult.Result.AllMembersAreAdministrators, true); }); }
public void SendLocationTest() { const float latitude = 1.00000095f; const float longitude = 1.00000203f; SendMessageResult sendLocation = mTelegramBot.SendLocation(mChatGroupId, latitude, longitude); ConsoleUtlis.PrintResult(sendLocation.Result.Location); Assert.Multiple(() => { Assert.AreEqual(sendLocation.Result.Location.Latitude, latitude); Assert.AreEqual(sendLocation.Result.Location.Longitude, longitude); }); }
public void GetFileTest() { mBotOkResponse.GetFile("jksdfjlskdjlaf"); var request = MockServer.ServerOkResponse.SearchLogsFor(Requests.WithUrl("/botToken/getFile").UsingPost()); ConsoleUtlis.PrintResult(request); Assert.Multiple(() => { Assert.AreEqual("file_id=jksdfjlskdjlaf", request.FirstOrDefault()?.Body); Assert.AreEqual("/botToken/getFile", request.FirstOrDefault()?.Url); Assert.Throws <Exception>(() => mBotBadResponse.GetFile("jksdfjlskdjlaf")); }); }
public void GetChatTest() { mBotOkResponse.GetChat(123); var request = MockServer.ServerOkResponse.SearchLogsFor(Requests.WithUrl("/botToken/getChat").UsingPost()); ConsoleUtlis.PrintResult(request); Assert.Multiple(() => { Assert.AreEqual("chat_id=123", request.FirstOrDefault()?.Body); Assert.AreEqual("/botToken/getChat", request.FirstOrDefault()?.Url); Assert.Throws <Exception>(() => mBotBadResponse.GetChat(123)); }); }
public void TestAppealToTheEmptyNewChatPhoto() { SendMessageResult sendMessage = mTelegramBot.SendMessage(mChatId, "TestAppealToTheEmptyNewChatPhoto()"); var newChatPhoto = sendMessage.Result.NewChatPhoto; ConsoleUtlis.PrintResult(newChatPhoto); Assert.Multiple(() => { Assert.True(sendMessage.Ok); Assert.IsInstanceOf(typeof(PhotoSizeInfo[]), newChatPhoto); Assert.AreEqual(sendMessage.Result.NewChatPhoto.Length, 0); }); }
private static void StartTest(string body) { MockServer.AddNewRouter("/botToken/getUpdates", body); mBotOkResponse.GetUpdates(); var request = MockServer.ServerOkResponse.SearchLogsFor(Requests.WithUrl("/botToken/getUpdates").UsingPost()); ConsoleUtlis.PrintResult(request); Assert.Multiple(() => { Assert.AreEqual("/botToken/getUpdates", request.FirstOrDefault()?.Url); Assert.Throws <Exception>(() => mBotBadResponse.GetUpdates()); }); }