@@ -11,23 +11,30 @@ namespace Qiniu.Storage.Tests
1111 [ TestFixture ]
1212 public class OperationManagerTests : TestEnv
1313 {
14+ private OperationManager getOperationManager ( )
15+ {
16+ Mac mac = new Mac ( AccessKey , SecretKey ) ;
17+ Config config = new Config ( ) ;
18+ // config.UseHttps = true;
19+
20+ OperationManager manager = new OperationManager ( mac , config ) ;
21+ return manager ;
22+ }
1423
1524 [ Test ]
16- public void PfopTest ( )
25+ public void PfopAndPrefopTest ( )
1726 {
27+ string key = "qiniu.mp4" ;
28+ bool force = true ;
29+ string pipeline = "sdktest" ;
30+ string notifyUrl = "http://api.example.com/qiniu/pfop/notify" ;
1831 string saveMp4Entry = Base64 . UrlSafeBase64Encode ( Bucket + ":avthumb_test_target.mp4" ) ;
1932 string saveJpgEntry = Base64 . UrlSafeBase64Encode ( Bucket + ":vframe_test_target.jpg" ) ;
2033 string avthumbMp4Fop = "avthumb/mp4|saveas/" + saveMp4Entry ;
2134 string vframeJpgFop = "vframe/jpg/offset/1|saveas/" + saveJpgEntry ;
2235 string fops = string . Join ( ";" , new string [ ] { avthumbMp4Fop , vframeJpgFop } ) ;
23- Mac mac = new Mac ( AccessKey , SecretKey ) ;
24- Config config = new Config ( ) ;
25- config . UseHttps = true ;
26- OperationManager manager = new OperationManager ( mac , config ) ;
27- string pipeline = "sdktest" ;
28- string notifyUrl = "http://api.example.com/qiniu/pfop/notify" ;
29- string key = "qiniu.mp4" ;
30- bool force = true ;
36+
37+ OperationManager manager = getOperationManager ( ) ;
3138 PfopResult pfopRet = manager . Pfop ( Bucket , key , fops , pipeline , notifyUrl , force ) ;
3239 if ( pfopRet . Code != ( int ) HttpCode . OK )
3340 {
@@ -42,5 +49,32 @@ public void PfopTest()
4249 }
4350 Console . WriteLine ( ret . ToString ( ) ) ;
4451 }
52+
53+ [ Test ]
54+ public void PfopWithIdleTimeTest ( )
55+ {
56+ string key = "qiniu.mp4" ;
57+ bool force = true ;
58+ int type = 1 ;
59+ string pipeline = null ;
60+ string saveJpgEntry = Base64 . UrlSafeBase64Encode ( Bucket + ":vframe_test_target.jpg" ) ;
61+ string vframeJpgFop = "vframe/jpg/offset/1|saveas/" + saveJpgEntry ;
62+
63+ OperationManager manager = getOperationManager ( ) ;
64+ PfopResult pfopRet = manager . Pfop ( Bucket , key , vframeJpgFop , pipeline , null , force , type ) ;
65+ if ( pfopRet . Code != ( int ) HttpCode . OK )
66+ {
67+ Assert . Fail ( "pfop error: " + pfopRet . ToString ( ) ) ;
68+ }
69+
70+ PrefopResult prefopRet = manager . Prefop ( pfopRet . PersistentId ) ;
71+ if ( prefopRet . Code != ( int ) HttpCode . OK )
72+ {
73+ Assert . Fail ( "prefop error: " + prefopRet . ToString ( ) ) ;
74+ }
75+ Assert . AreEqual ( 1 , prefopRet . Result . Type ) ;
76+ Assert . IsNotNull ( prefopRet . Result . CreationDate ) ;
77+ Assert . IsNotEmpty ( prefopRet . Result . CreationDate ) ;
78+ }
4579 }
4680}
0 commit comments