Exemplo n.º 1
0
        public void UserRecordUnitTest_HashKeyFromPartitionKey()
        {
            var m = make_put_record();

            KPLNET.Kinesis.Core.UserRecord ur = new KPLNET.Kinesis.Core.UserRecord(m);
            Assert.AreEqual(ur.Hash_key().ToString(), KPLNETInterface.Utils.GetDecimalHashKey(kDefaultPartitionKey).ToString());
        }
Exemplo n.º 2
0
        public void UserRecordUnitTest_ExplicitHashKey()
        {
            string explicit_hash_key = "123456789";
            var    m = make_put_record();

            m.PutRecord.ExplicitHashKey = explicit_hash_key;

            var ur = new KPLNET.Kinesis.Core.UserRecord(m);

            Assert.AreEqual(ur.Hash_key().ToString(), explicit_hash_key);
        }
Exemplo n.º 3
0
        public void UserRecordUnitTest_BasicConversion()
        {
            var m = make_put_record();

            KPLNET.Kinesis.Core.UserRecord ur = new KPLNET.Kinesis.Core.UserRecord(m);

            Assert.AreEqual(ur.Stream(), kDefaultStream);
            Assert.AreEqual(ur.Partition_key(), kDefaultPartitionKey);
            Assert.AreEqual(ur.Data().ToString(Encoding.Default), kDefaultData);
            Assert.AreEqual(ur.Source_id(), kDefaultId);
        }
Exemplo n.º 4
0
        public void UserRecordUnitTest_PutRecordResultSuccess()
        {
            var m  = make_put_record();
            var ur = new KPLNET.Kinesis.Core.UserRecord(m);

            KPLNET.Kinesis.Core.Attempt a = new KPLNET.Kinesis.Core.Attempt();
            a.set_error("code", "message");
            ur.add_attempt(a);

            KPLNET.Kinesis.Core.Attempt b = new KPLNET.Kinesis.Core.Attempt();
            b.set_result("shard-0", "123456789");
            ur.add_attempt(b);

            Aws.Kinesis.Protobuf.Message m2 = ur.to_put_record_result();
            Assert.IsNotNull(m2.PutRecordResult);
            var prr = m2.PutRecordResult;

            Assert.AreEqual(prr.Attempts.Count, 2);
            Assert.AreEqual(prr.Success, true);
            Assert.AreEqual(prr.ShardId, "shard-0");
            Assert.AreEqual(prr.SequenceNumber, "123456789");
        }
Exemplo n.º 5
0
        public void UserRecordUnitTest_PutRecordResultFail()
        {
            var m  = make_put_record();
            var ur = new KPLNET.Kinesis.Core.UserRecord(m);

            KPLNET.Kinesis.Core.Attempt a = new KPLNET.Kinesis.Core.Attempt();
            var now = DateTime.Now;

            a.set_start(now);
            a.set_end(now.AddMilliseconds(5));
            a.set_error("code", "message");
            ur.add_attempt(a);

            KPLNET.Kinesis.Core.Attempt b = new KPLNET.Kinesis.Core.Attempt();
            b.set_start(now.AddMilliseconds(11));
            b.set_end(now.AddMilliseconds(18));
            b.set_error("code2", "message2");
            ur.add_attempt(b);

            Aws.Kinesis.Protobuf.Message m2 = ur.to_put_record_result();
            Assert.IsTrue(m2.PutRecordResult != null);
            var prr = m2.PutRecordResult;

            Assert.AreEqual(prr.Attempts.Count, 2);
            Assert.AreEqual(prr.Success, false);
            Assert.AreEqual(prr.Attempts[0].Success, false);
            Assert.AreEqual(prr.Attempts[0].ErrorCode, "code");
            Assert.AreEqual(prr.Attempts[0].ErrorMessage, "message");
            //Assert.AreEqual((int)prr.Attempts[0].Delay, 0);
            Assert.AreEqual((int)prr.Attempts[0].Duration, 5);
            Assert.AreEqual(prr.Attempts[1].Success, false);
            Assert.AreEqual(prr.Attempts[1].ErrorCode, "code2");
            Assert.AreEqual(prr.Attempts[1].ErrorMessage, "message2");
            Assert.AreEqual((int)prr.Attempts[1].Delay, 6);
            Assert.AreEqual((int)prr.Attempts[1].Duration, 7);
        }