Пример #1
0
        public void TestObjectGet()
        {
            var host    = "localhost:8080";
            var key     = "KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr".LoadWif();
            var cid     = ContainerID.FromBase58String("RuzuV3RDstuVtWoDzsTsuNFiakaaGGN24EbNSUFGaiQ");
            var oid     = ObjectID.FromBase58String("6VLqsZAvYTRzt8yY4NvGweWfGmqBiAfQwd6novRNFYiG");
            var address = new Address(cid, oid);
            var client  = new Client.Client(key, host);
            var source1 = new CancellationTokenSource();

            source1.CancelAfter(TimeSpan.FromMinutes(1));
            var session = client.CreateSession(source1.Token, ulong.MaxValue);

            source1.Cancel();
            var source2 = new CancellationTokenSource();

            source2.CancelAfter(TimeSpan.FromMinutes(1));
            var o = client.GetObject(source2.Token, new GetObjectParams {
                Address = address
            }, new CallOptions {
                Ttl = 2, Session = session
            }).Result;

            Assert.AreEqual(oid, o.ObjectId);
        }
 public void TestObjectGetException()
 {
     using var client = new Client.Client(key, host);
     using var source = new CancellationTokenSource();
     source.CancelAfter(TimeSpan.FromMinutes(1));
     try
     {
         var obj = client.GetObject(Address, false, new Client.CallOptions {
             Ttl = 1
         }, source.Token).Result;
     }
     catch (Exception e)
     {
         if (e is AggregateException ae)
         {
             foreach (var ie in ae.InnerExceptions)
             {
                 if (ie is RpcException re)
                 {
                     Console.WriteLine(re);
                     Assert.AreEqual(StatusCode.Internal, re.StatusCode);
                 }
             }
         }
     }
 }
Пример #3
0
        public void TestObjectGetWithoutOptions()
        {
            using var client = new Client.Client(key, host);
            using var source = new CancellationTokenSource();
            source.CancelAfter(TimeSpan.FromMinutes(1));
            var o = client.GetObject(Address, context: source.Token).Result;

            Assert.AreEqual(oid, o.ObjectId);
        }
Пример #4
0
        public void TestObjectGet()
        {
            using var client = new Client.Client(key, host);
            using var source = new CancellationTokenSource();
            source.CancelAfter(TimeSpan.FromSeconds(10));
            var o = client.GetObject(Address, false, new CallOptions {
                Ttl = 1
            }, source.Token).Result;

            Console.WriteLine(o.Header.ToString());
            Console.WriteLine(o.Payload.Length);
            Assert.AreEqual(oid, o.ObjectId);
        }
Пример #5
0
        public void TestObjectGetStream()
        {
            string path = "objectgetstream.data";
            var    file = File.Create(path);

            using var client = new Client.Client(key, host);
            using var source = new CancellationTokenSource();
            source.CancelAfter(TimeSpan.FromSeconds(10));
            client.GetObject(Address, file, false, new CallOptions {
                Ttl = 1
            }, source.Token).Wait();
            file.Flush();
            Console.WriteLine(file.Length);
            File.Delete(path);
        }