Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void testCanDoStreamingMapUnpacking() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void TestCanDoStreamingMapUnpacking()
        {
            // Given
            Machine machine = new Machine();

            PackStream.Packer packer = machine.Packer();
            packer.PackMapHeader(2);
            packer.Pack("name");
            packer.Pack("Bob");
            packer.Pack("cat_ages");
            packer.PackListHeader(2);
            packer.Pack(4.3);
            packer.Pack(true);
            packer.Flush();

            // When I unpack this value
            PackStream.Unpacker unpacker = NewUnpacker(machine.Output());

            // Then I can do streaming unpacking
            long   size = unpacker.UnpackMapHeader();
            string k1   = unpacker.UnpackString();
            string v1   = unpacker.UnpackString();
            string k2   = unpacker.UnpackString();

            long   innerSize = unpacker.UnpackListHeader();
            double d         = unpacker.UnpackDouble();
            bool   e         = unpacker.UnpackBoolean();

            // And all the values should be sane
            assertEquals(2, size);
            assertEquals(2, innerSize);
            assertEquals("name", k1);
            assertEquals("Bob", v1);
            assertEquals("cat_ages", k2);
            assertEquals(4.3, d, 0.0001);
            assertTrue(e);
        }