Exemplo n.º 1
0
        public void Send_invoice()
        {
            BaleClient client   = new BaleClient(Token);
            Response   response = client.SendInvoice(new InvoiceMessage(ChatId, "paloadData", "pizza chicago", "pizza chicago with special souce", "my token", new Price("pizza chicago", 300_000)));

            response.Ok.Should().BeTrue();
            response.Result.Invoice.Should().NotBeNull();
        }
Exemplo n.º 2
0
        public void Should_get_updates_successfully_and_count_must_be_greater_than_zero()
        {
            BaleClient   client       = new BaleClient(Token);
            UpdateResult updateResult = client.GetUpdates();

            updateResult.Ok.Should().BeTrue();
            updateResult.Result.Count.Should().BeGreaterThan(0);
        }
Exemplo n.º 3
0
        public void Get_chat_detail()
        {
            BaleClient      client   = new BaleClient(Token);
            Response <Chat> response = client.GetChat(ChatId);

            response.Ok.Should().BeTrue();
            response.Result.Should().NotBeNull();
            response.Result.Id.Should().Be(ChatId);
        }
Exemplo n.º 4
0
        public void GetMe()
        {
            BaleClient      client   = new BaleClient(Token);
            Response <From> response = client.GetMe();

            response.Ok.Should().BeTrue();
            response.Result.Should().NotBeNull();
            response.Result.IsBot.Should().BeTrue();
        }
Exemplo n.º 5
0
        public void Should_send_a_text_message_successfully()
        {
            BaleClient client = new BaleClient(Token);

            client.SendTextMessage(new TextMessage()
            {
                ChatId = ChatId,
                Text   = "salam"
            });
        }
Exemplo n.º 6
0
        public void Should_set_webHook_successfully()
        {
            BaleClient client     = new BaleClient(Token);
            string     sampleHook = "https://myhook.com";

            Response <bool> response = client.SetWebhook(sampleHook);

            response.Ok.Should().BeTrue();
            response.Result.Should().BeTrue();
            response.Description.Should().BeNull();
        }
Exemplo n.º 7
0
        public void Should_set_webHook_fail_because_url_is_not_secure()
        {
            BaleClient client     = new BaleClient(Token);
            string     sampleHook = "http://myhook.com";

            Response <bool> response = client.SetWebhook(sampleHook);

            response.Ok.Should().BeFalse();
            response.Result.Should().BeFalse();
            response.Description.Should().NotBeNull();
        }
Exemplo n.º 8
0
        public void deleteWebhook()
        {
            BaleClient client = new BaleClient(Token);

            Response <bool> response = client.DeleteWebHook();


            response.Ok.Should().BeTrue();
            response.Result.Should().BeTrue();
            response.Description.Should().BeNull();
        }
Exemplo n.º 9
0
        public void Send_message_should_fail_because_token_is_invalid()
        {
            BaleClient client   = new BaleClient("invalid token");
            Response   response = client.SendTextMessage(new TextMessage()
            {
                ChatId = ChatId,
                Text   = "good by world!",
            });

            response.Ok.Should().BeFalse();
            response.Errorcode.Should().Be(401);
        }
Exemplo n.º 10
0
        public void Send_photo_successfully()
        {
            BaleClient client   = new BaleClient(Token);
            Response   response = client.SendPhoto(new PhotoMessage()
            {
                Caption = "image caption",
                ChatId  = ChatId,
                Photo   = Utils.ToBytes(FilePath + "lolo.png")
            });

            response.Ok.Should().BeTrue();
            response.Result.Photo.Count.Should().Be(1);
        }
Exemplo n.º 11
0
        public void Update_message_must_fail_because_messageId_is_invalid()
        {
            BaleClient client       = new BaleClient(Token);
            Response   editResponse = client.EditTextMessage(new TextMessage()
            {
                ChatId = ChatId,
                Text   = "updated text message"
            }, 1010);


            editResponse.Ok.Should().BeFalse();
            editResponse.Description.Should().NotBeNull();
        }
Exemplo n.º 12
0
        public void Send_video_successfully()
        {
            BaleClient client   = new BaleClient(Token);
            Response   response = client.SendVideo(new VideoMessage()
            {
                Caption = "video caption",
                ChatId  = ChatId,
                Video   = Utils.ToBytes(FilePath + "video.mp4"),
                Name    = "docFileName"
            });

            response.Ok.Should().BeTrue();
            response.Result.Video.Should().NotBeNull();
        }
Exemplo n.º 13
0
        public void Send_document_successfully()
        {
            BaleClient client   = new BaleClient(Token);
            Response   response = client.SendDocument(new DocumentMessage()
            {
                Caption  = "document file caption",
                ChatId   = ChatId,
                Document = Utils.ToBytes(FilePath + "document.pdf"),
                Name     = "docFileName"
            });

            response.Ok.Should().BeTrue();
            response.Result.Document.Should().NotBeNull();
        }
Exemplo n.º 14
0
        public void Send_photo_with_keyboard_successfully()
        {
            BaleClient client   = new BaleClient(Token);
            Response   response = client.SendPhoto(new PhotoMessage()
            {
                Caption     = "image caption",
                ChatId      = ChatId,
                Photo       = Utils.ToBytes(FilePath + "lolo.png"),
                ReplyMarkup = ReplyKeyboard.Create().AddButton("download file").AddButton("something else").Build()
            });

            response.Ok.Should().BeTrue();
            response.Result.Photo.Count.Should().Be(1);
        }
Exemplo n.º 15
0
        public void Send_audio_successfully()
        {
            BaleClient client   = new BaleClient(Token);
            Response   response = client.SendAudio(new AudioMessage()
            {
                Caption = "audio caption",
                ChatId  = ChatId,
                Audio   = Utils.ToBytes(FilePath + "gun_sound.mp3"),
                Title   = "audio titile"
            });

            response.Ok.Should().BeTrue();
            //response.Result.Audio.Should().NotBeNull();
        }
Exemplo n.º 16
0
        public void Send_a_textMessage_with_inlineKeyboard_via_keboard_builder()
        {
            BaleClient client   = new BaleClient(Token);
            Response   response = client.SendTextMessage(new TextMessage()
            {
                ChatId      = ChatId,
                Text        = "click on buttons",
                ReplyMarkup = ReplyKeyboard.Create().AddButton("button one").AddButton("button two")
                              .AddButton("button three").Build()
            });

            response.Ok.Should().BeTrue();
            response.Result.Should().NotBeNull();
        }
Exemplo n.º 17
0
        public void Send_location()
        {
            BaleClient client   = new BaleClient(Token);
            Response   response = client.SendLocation(new LocationMessage()
            {
                ChatId    = ChatId,
                Latitude  = 35.73122955392002,
                Longitude = 51.41714821748457
            });


            response.Ok.Should().BeTrue();
            response.Result.Location.Should().NotBeNull();
        }
Exemplo n.º 18
0
        public void DeleteMessage_successfully()
        {
            BaleClient client   = new BaleClient(Token);
            Response   response = client.SendTextMessage(new TextMessage()
            {
                ChatId = ChatId,
                Text   = "should be deleted very soon :)"
            });


            Response <bool> deleteMessageResponse = client.DeleteMessage(ChatId, response.Result.MessageId);


            deleteMessageResponse.Ok.Should().BeTrue();
        }
Exemplo n.º 19
0
        public void Send_contact()
        {
            BaleClient client   = new BaleClient(Token);
            Response   response = client.SendContact(new ContactMessage()
            {
                ChatId      = ChatId,
                FirstName   = "contact name",
                LastName    = "last name",
                PhoneNumber = "+989121212121"
            });


            response.Ok.Should().BeTrue();
            response.Result.Contact.Should().NotBeNull();
        }
Exemplo n.º 20
0
        public void Get_file_successfully()
        {
            BaleClient client            = new BaleClient(Token);
            Response   sendPhotoResponse = client.SendPhoto(new PhotoMessage()
            {
                Caption = "image caption",
                ChatId  = ChatId,
                Photo   = Utils.ToBytes(FilePath + "lolo.png")
            });

            string          fileId   = sendPhotoResponse.Result.Photo[0].FileId;
            Response <File> response = client.GetFile(fileId);

            response.Ok.Should().BeTrue();
            response.Result.FileId.Should().Be(fileId);
        }
Exemplo n.º 21
0
        public void Update_message_successfully()
        {
            BaleClient client   = new BaleClient(Token);
            Response   response = client.SendTextMessage(new TextMessage()
            {
                ChatId = ChatId,
                Text   = "salam"
            });


            Response editResponse = client.EditTextMessage(new TextMessage()
            {
                ChatId = ChatId,
                Text   = "updated text message"
            }, response.Result.MessageId);


            editResponse.Ok.Should().BeTrue();
            editResponse.Description.Should().BeNull();
        }
Exemplo n.º 22
0
        public void Send_a_textMessage_with_inlineKeyboard()
        {
            BaleClient client   = new BaleClient(Token);
            Response   response = client.SendTextMessage(new TextMessage()
            {
                ChatId      = ChatId,
                Text        = "click on buttons",
                ReplyMarkup = new ReplyKeyboard()
                {
                    InlineKeyboard = new List <List <InlineKeyboardItem> >()
                    {
                        new List <InlineKeyboardItem>()
                        {
                            new InlineKeyboardItem("button one"),
                            new InlineKeyboardItem("button two")
                        }
                    }
                }
            });

            response.Ok.Should().BeTrue();
            response.Result.Should().NotBeNull();
        }