1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System;
- using JCSoft.WX.Framework.Models.ApiRequests;
- using JCSoft.WX.Framework.Models.ApiResponses;
- using Xunit;
- using JCSoft.WX.Framework.Models;
- namespace FrameworkCoreTest
- {
- public class MediaUploadTest : MockPostApiBaseTest<MediaUploadRequest, MediaUploadResponse>
- {
-
- [Fact]
- public void MediaUploadReallyTest()
- {
- var response = mock_client.Object.Execute(Request);
- if (response.IsError)
- Console.WriteLine(response.ToString());
- Console.WriteLine(response.MediaId);
- }
- [Fact]
- public void MockMediaUploadTest()
- {
- IsMock = true;
- MockSetup(false);
- var response = mock_client.Object.Execute(Request);
- Assert.Equal("MEDIA_ID", response.MediaId);
- }
- [Fact]
- public void MockMediaUploadErrorTest()
- {
- IsMock = true;
- MockSetup(true);
- var response = mock_client.Object.Execute(Request);
- Assert.Equal(true, response.IsError);
- }
- protected override MediaUploadRequest InitRequestObject()
- {
- return new MediaUploadRequest
- {
- AccessToken = GetCurrentToken(),
- FilePath = @"C:\123.amr",
- MediaType = MediaType.Voice
- };
- }
- protected override string GetReturnResult(bool errResult)
- {
- if (errResult)
- return s_errmsg;
- return "{\"type\":\"Image\",\"media_id\":\"MEDIA_ID\",\"created_at\":123456789}";
- }
- }
- }
|