Aws.Kinesis.Protobuf.Message make_put_record() { var m = new Aws.Kinesis.Protobuf.Message(); m.Id = kDefaultId; m.PutRecord = new Aws.Kinesis.Protobuf.PutRecord(); m.PutRecord.PartitionKey = kDefaultPartitionKey; m.PutRecord.Data = Google.Protobuf.ByteString.CopyFrom(kDefaultData, Encoding.Default); m.PutRecord.StreamName = kDefaultStream; return(m); }
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"); }
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); }