Пример #1
0
        public void PutRecordsRequetsUnitTest_StreamName()
        {
            PutRecordsRequest prr = new PutRecordsRequest();
            var kr = make_kinesis_record();

            prr.add(kr);
            Assert.AreEqual(prr.stream(), "myStream");
        }
Пример #2
0
        public void PutRecordsRequetsUnitTest_SizePrediction()
        {
            PutRecordsRequest prr = new PutRecordsRequest();

            Assert.AreEqual((int)prr.accurate_size(), 0);
            Assert.AreEqual(prr.Estimated_size(), prr.accurate_size());

            Stack <int> sizes = new Stack <int>();

            sizes.Push(0);
            int N = 100;

            for (int i = 0; i < N; i++)
            {
                var kr = make_kinesis_record();
                prr.add(kr);

                int expected_growth = kr.serialize().Length + kr.partition_key().Length;
                int expected_size   = sizes.Peek() + expected_growth;
                Assert.AreEqual((int)prr.accurate_size(), (expected_size - 16));
                Assert.AreEqual(prr.Estimated_size(), prr.accurate_size());

                sizes.Push(expected_size - 16);
            }

            for (int i = 0; i < N; i++)
            {
                Assert.AreEqual((int)prr.accurate_size(), sizes.Peek());
                Assert.AreEqual(prr.Estimated_size(), prr.accurate_size());

                sizes.Pop();
                prr.remove_last();
            }

            Assert.AreEqual((int)prr.accurate_size(), 0);
            Assert.AreEqual(prr.Estimated_size(), prr.accurate_size());
        }