コード例 #1
0
        public void Upload_successfully_an_image()
        {
            GapClient  gapClient = new GapClient(Token);
            Message    msg       = new Message(MessageType.Image);
            PostResult result    = gapClient.Upload(FilesDirectory + "godzila.jpg", "godzila.jpg", UploadFileType.Image, "coolzila :)").Result;

            result.StatusCode.Should().Be(StatusCode.Success);
            File file = Utils.Deserialize <File>(result.RawBody);

            file.Should().NotBeNull();
        }
コード例 #2
0
        public void Upload_and_send_an_textFile_to_the_client()
        {
            GapClient  gapClient       = new GapClient(Token);
            string     fileDescription = "some desc";
            PostResult uploadResult    = gapClient.Upload(FilesDirectory + "sampleText.txt", "textfile.txt", UploadFileType.File, fileDescription).Result;
            File       file            = Utils.Deserialize <File>(uploadResult.RawBody);

            file.Desc = fileDescription;
            Message message = new Message(MessageType.File)
            {
                ChatId = ChatId,
                Data   = Utils.Serialize(file)
            };

            PostResult postResult = gapClient.Send(message).Result;

            postResult.StatusCode.Should().Be(StatusCode.Success);
        }
コード例 #3
0
        public void Upload_and_send_an_image_to_the_client()
        {
            GapClient  gapClient       = new GapClient(Token);
            string     fileDescription = "coolzila :)";
            PostResult uploadResult    = gapClient.Upload(FilesDirectory + "godzila.jpg", "godzila.jpg", UploadFileType.Image, fileDescription).Result;
            File       file            = Utils.Deserialize <File>(uploadResult.RawBody);

            file.Desc = fileDescription;
            Message message = new Message(MessageType.Image)
            {
                ChatId = ChatId,
                Data   = Utils.Serialize(file)
            };

            PostResult postResult = gapClient.Send(message).Result;

            postResult.StatusCode.Should().Be(StatusCode.Success);
        }
コード例 #4
0
        public void Upload_and_send_an_mp3_to_the_client()
        {
            GapClient  gapClient       = new GapClient(Token);
            string     fileDescription = "FiveFin"; // 4.7MB
            PostResult uploadResult    = gapClient.Upload(FilesDirectory + "FiveF.mp3", "haghighat_audio.mp3", UploadFileType.Audio, fileDescription).Result;
            File       file            = Utils.Deserialize <File>(uploadResult.RawBody);

            file.Desc = fileDescription;
            Message message = new Message(MessageType.Audio)
            {
                ChatId = ChatId,
                Data   = Utils.Serialize(file)
            };

            PostResult postResult = gapClient.Send(message).Result;

            postResult.StatusCode.Should().Be(StatusCode.Success);
        }