Exemplo n.º 1
0
        public void PutFileTest()
        {
            IOClient target = new IOClient();
            string   key    = NewKey;

            PrintLn(key);
            PutExtra extra = new PutExtra();              // TODO: 初始化为适当的值

            extra.MimeType = "text/plain";
            extra.Crc32    = 123;
            extra.CheckCrc = CheckCrcType.CHECK;
            extra.Params   = new System.Collections.Generic.Dictionary <string, string> ();
            PutPolicy put  = new PutPolicy(Bucket);
            TmpFIle   file = new TmpFIle(1024 * 10);

            target.PutFinished += new EventHandler <PutRet> ((o, e) => {
                file.Del();
                if (e.OK)
                {
                    RSHelper.RSDel(Bucket, file.FileName);
                }
            });

            PutRet ret = target.PutFile(put.Token(), file.FileName, file.FileName, extra);

            //error params
            //target.PutFile("error", "error", "error", null);
            Assert.IsTrue(ret.OK, "PutFileTest Failure");
        }
Exemplo n.º 2
0
 public void AfterTest()
 {
     foreach (string k in tmpKeys)
     {
         RSHelper.RSDel(Bucket, k);
     }
 }
Exemplo n.º 3
0
        public void BatchDeleteTest()
        {
            List <string> tmps = RSHelper.RSPut(Bucket, 2);

            RSClient target = new RSClient();             // TODO: 初始化为适当的值

            EntryPath[] keys = new EntryPath[2];          // TODO: 初始化为适当的值
            int         i    = 0;

            foreach (string k in tmps)
            {
                keys [i++] = new EntryPath(Bucket, k);
            }

            CallRet actual;

            actual = target.BatchDelete(keys);
            if (actual.OK)
            {
                foreach (string k in tmps)
                {
                    RSHelper.RSDel(Bucket, k);
                }
            }
            Assert.IsTrue(actual.OK, "BatchStatTest Failure");;
        }
Exemplo n.º 4
0
        public async Task BatchCopyTest()
#endif
        {
            RSClient target = new RSClient();                      // TODO: 初始化为适当的值

            EntryPathPair[] entryPathPairs = new EntryPathPair[2]; // TODO: 初始化为适当的值
            string          tmpKey         = NewKey;
            string          tmpKey2        = NewKey;

            entryPathPairs[0] = new EntryPathPair(Bucket, tmpKeys[0], tmpKey);
            entryPathPairs[1] = new EntryPathPair(Bucket, tmpKeys[1], tmpKey2);
            CallRet actual;

#if NET20 || NET40
            actual = target.BatchCopy(entryPathPairs);
            if (actual.OK)
            {
                RSHelper.RSDel(Bucket, tmpKey);
                RSHelper.RSDel(Bucket, tmpKey2);
            }
            Assert.IsTrue(actual.OK, "BatchStatTest Failure");
#else
            actual = await target.BatchCopyAsync(entryPathPairs);

            if (actual.OK)
            {
                await RSHelper.RSDel(Bucket, tmpKey);

                await RSHelper.RSDel(Bucket, tmpKey2);
            }
            Assert.True(actual.OK, "BatchStatTest Failure");
#endif
        }
Exemplo n.º 5
0
        public void PutTest()
        {
            IOClient target = new IOClient();
            string   key    = NewKey;

            PrintLn(key);
            PutExtra extra = new PutExtra(); // TODO: 初始化为适当的值

            extra.MimeType = "text/plain";
            extra.Crc32    = 123;
            extra.CheckCrc = CheckCrcType.CHECK;
            extra.Params   = new System.Collections.Generic.Dictionary <string, string>();
            PutPolicy put = new PutPolicy(Bucket);

            target.PutFinished += new EventHandler <PutRet>((o, e) =>
            {
                if (e.OK)
                {
                    RSHelper.RSDel(Bucket, key);
                }
            });
            string token = put.Token();
            PutRet ret   = target.Put(put.Token(), key, StreamEx.ToStream("Hello, Qiniu Cloud!"), extra);

            Assert.IsTrue(ret.OK, "PutFileTest Failure");
        }
Exemplo n.º 6
0
        public async Task BeforeTest()
        {
            #region before test
            tmpKeys = await RSHelper.RSPut(Bucket, 4);

            #endregion
        }
Exemplo n.º 7
0
        public async Task CopyTest()
#endif
        {
            RSClient      target   = new RSClient();                             // TODO: 初始化为适当的值
            string        key      = NewKey;
            EntryPathPair pathPair = new EntryPathPair(Bucket, tmpKeys[0], key); // TODO: 初始化为适当的值
            CallRet       actual;

#if NET20 || NET40
            actual = target.Copy(pathPair);
            if (actual.OK)
            {
                RSHelper.RSDel(Bucket, key);
            }
            Assert.IsTrue(actual.OK, "CopyTest Failure");
#else
            actual = await target.CopyAsync(pathPair);

            if (actual.OK)
            {
                await RSHelper.RSDel(Bucket, key);
            }
            Assert.True(actual.OK, "CopyTest Failure");
#endif
        }
        public void ResumablePutFileTest()
        {
            Settings            putSetting = new Settings();  // TODO: 初始化为适当的值
            string              key        = NewKey;
            ResumablePutExtra   extra      = new ResumablePutExtra();
            NameValueCollection nc         = new NameValueCollection();

            nc.Add("x:username", "qiniu");
            extra.CallbackParams = nc;
            extra.Notify        += new EventHandler <PutNotifyEvent>(extra_Notify);
            extra.NotifyErr     += new EventHandler <PutNotifyErrorEvent>(extra_NotifyErr);
            ResumablePut target = new ResumablePut(putSetting, extra); // TODO: 初始化为适当的值

            Console.WriteLine("extra.Bucket:" + Bucket);
            string  upToken = new PutPolicy(Bucket).Token(new Qiniu.Auth.digest.Mac());
            TmpFIle file    = new TmpFIle(1024 * 1024 * 4);

            target.PutFinished += new EventHandler <CallRet> ((o, e) => {
                file.Del();
                if (e.OK)
                {
                    RSHelper.RSDel(Bucket, key);
                }
            });
            CallRet ret = target.PutFile(upToken, file.FileName, key);

            //Action a = new Action (() =>
            //{
            //	target.PutFile (upToken, BigFile, NewKey);
            //});
            //a.BeginInvoke (null,null);
        }
Exemplo n.º 9
0
        public void ResumablePutFileTest()
        {
            Settings          putSetting = new Settings();    // TODO: 初始化为适当的值
            string            key        = NewKey;
            ResumablePutExtra extra      = new ResumablePutExtra();

            extra.Notify    += new EventHandler <PutNotifyEvent>(extra_Notify);
            extra.NotifyErr += new EventHandler <PutNotifyErrorEvent>(extra_NotifyErr);
            extra.Bucket     = Bucket;
            ResumablePut target = new ResumablePut(putSetting, extra); // TODO: 初始化为适当的值

            Console.WriteLine("extra.Bucket:" + extra.Bucket);
            string upToken = new PutPolicy(extra.Bucket).Token(new Qiniu.Auth.digest.Mac());

            target.Progress += new Action <float>(target_Progress);
            TmpFIle file = new TmpFIle(1024 * 1024 * 4);

            target.PutFinished += new EventHandler <CallRet> ((o, e) => {
                file.Del();
                if (e.OK)
                {
                    RSHelper.RSDel(Bucket, key);
                }
            });
            target.PutFile(upToken, file.FileName, key);

            //Action a = new Action (() =>
            //{
            //	target.PutFile (upToken, BigFile, NewKey);
            //});
            //a.BeginInvoke (null,null);
        }
Exemplo n.º 10
0
        public async Task AfterTest()
#endif
        {
            foreach (string k in tmpKeys)
            {
#if NET20 || NET40
                RSHelper.RSDel(Bucket, k);
#else
                await RSHelper.RSDel(Bucket, k);
#endif
            }
        }
Exemplo n.º 11
0
        public void CopyTest()
        {
            RSClient      target   = new RSClient();                             // TODO: 初始化为适当的值
            string        key      = NewKey;
            EntryPathPair pathPair = new EntryPathPair(Bucket, tmpKeys[0], key); // TODO: 初始化为适当的值
            CallRet       actual;

            actual = target.Copy(pathPair);
            if (actual.OK)
            {
                RSHelper.RSDel(Bucket, key);
            }
            Assert.IsTrue(actual.OK, "CopyTest Failure");
        }
Exemplo n.º 12
0
        public async Task PutFileWithoutKeyTest()
#endif
        {
            IOClient target = new IOClient();

            PutExtra extra = new PutExtra();              // TODO: 初始化为适当的值

            extra.MimeType = "text/plain";
            extra.Crc32    = 123;
            extra.CheckCrc = CheckCrcType.CHECK;
            extra.Params   = new System.Collections.Generic.Dictionary <string, string> ();
            PutPolicy put  = new PutPolicy(Bucket);
            TmpFIle   file = new TmpFIle(1024 * 10);

#if NET20 || NET40
            target.PutFinished += new EventHandler <PutRet> ((o, e) => {
                file.Del();
                if (e.OK)
                {
                    RSHelper.RSDel(Bucket, file.FileName);
                }
            });
            PutRet ret = target.PutFileWithoutKey(put.Token(), file.FileName, extra);

            Assert.AreEqual(ret.Hash, ret.key, "expected key equal to hash");
            //error params
            //target.PutFile("error", "error", "error", null);
            Assert.IsTrue(ret.OK, "PutFileTest Failure");
#else
            target.PutFinished += new EventHandler <PutRet>(async(o, e) => {
                file.Del();
                if (e.OK)
                {
                    await RSHelper.RSDel(Bucket, file.FileName);
                }
            });
            PutRet ret = await target.PutFileWithoutKeyAsync(put.Token(), file.FileName, extra);

            Assert.True(ret.Hash == ret.key, "expected key equal to hash");
            //error params
            //target.PutFile("error", "error", "error", null);
            Assert.True(ret.OK, "PutFileTest Failure");
#endif
        }
Exemplo n.º 13
0
        public void BatchCopyTest()
        {
            RSClient target = new RSClient();                      // TODO: 初始化为适当的值

            EntryPathPair[] entryPathPairs = new EntryPathPair[2]; // TODO: 初始化为适当的值
            string          tmpKey         = NewKey;
            string          tmpKey2        = NewKey;

            entryPathPairs[0] = new EntryPathPair(Bucket, tmpKeys[0], tmpKey);
            entryPathPairs[1] = new EntryPathPair(Bucket, tmpKeys[1], tmpKey2);
            CallRet actual;

            actual = target.BatchCopy(entryPathPairs);
            if (actual.OK)
            {
                RSHelper.RSDel(Bucket, tmpKey);
                RSHelper.RSDel(Bucket, tmpKey2);
            }
            Assert.IsTrue(actual.OK, "BatchStatTest Failure");;
        }
Exemplo n.º 14
0
        public async Task BatchDeleteTest()
#endif
        {
#if NET20 || NET40
            List <string> tmps = RSHelper.RSPut(Bucket, 2);
#else
            List <string> tmps = await RSHelper.RSPut(Bucket, 2);
#endif

            RSClient    target = new RSClient();   // TODO: 初始化为适当的值
            EntryPath[] keys   = new EntryPath[2]; // TODO: 初始化为适当的值
            int         i      = 0;
            foreach (string k in tmps)
            {
                keys [i++] = new EntryPath(Bucket, k);
            }

            CallRet actual;
#if NET20 || NET40
            actual = target.BatchDelete(keys);
            if (actual.OK)
            {
                foreach (string k in tmps)
                {
                    RSHelper.RSDel(Bucket, k);
                }
            }
            Assert.IsTrue(actual.OK, "BatchStatTest Failure");
#else
            actual = await target.BatchDeleteAsync(keys);

            if (actual.OK)
            {
                foreach (string k in tmps)
                {
                    await RSHelper.RSDel(Bucket, k);
                }
            }
            Assert.True(actual.OK, "BatchStatTest Failure");
#endif
        }
Exemplo n.º 15
0
 public void BeforeTest()
 {
     #region before test
     tmpKeys = RSHelper.RSPut(Bucket, 3);
     #endregion
 }