//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void testCanPackAndUnpackMapStream() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void TestCanPackAndUnpackMapStream() { // Given Machine machine = new Machine(); // When PackStream.Packer packer = machine.Packer(); packer.PackMapStreamHeader(); packer.Pack("one"); packer.pack(1); packer.Pack("two"); packer.pack(2); packer.PackEndOfStream(); packer.Flush(); PackStream.Unpacker unpacker = NewUnpacker(machine.Output()); // Then assertThat(unpacker.UnpackMapHeader(), equalTo(PackStream.UNKNOWN_SIZE)); assertThat(unpacker.UnpackString(), equalTo("one")); assertThat(unpacker.UnpackLong(), equalTo(1L)); assertThat(unpacker.UnpackString(), equalTo("two")); assertThat(unpacker.UnpackLong(), equalTo(2L)); unpacker.UnpackEndOfStream(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void testCanPackAndUnpackListStream() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void TestCanPackAndUnpackListStream() { // Given Machine machine = new Machine(); // When PackStream.Packer packer = machine.Packer(); packer.PackListStreamHeader(); packer.Pack("eins"); packer.Pack("zwei"); packer.Pack("drei"); packer.PackEndOfStream(); packer.Flush(); PackStream.Unpacker unpacker = NewUnpacker(machine.Output()); // Then assertThat(unpacker.UnpackListHeader(), equalTo(PackStream.UNKNOWN_SIZE)); assertThat(unpacker.UnpackString(), equalTo("eins")); assertThat(unpacker.UnpackString(), equalTo("zwei")); assertThat(unpacker.UnpackString(), equalTo("drei")); unpacker.UnpackEndOfStream(); }
//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); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void testCanPackAndUnpackStruct() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void TestCanPackAndUnpackStruct() { // Given Machine machine = new Machine(); // When PackStream.Packer packer = machine.Packer(); packer.PackStructHeader(3, ( sbyte )'N'); packer.pack(12); packer.PackListHeader(2); packer.Pack("Person"); packer.Pack("Employee"); packer.PackMapHeader(2); packer.Pack("name"); packer.Pack("Alice"); packer.Pack("age"); packer.pack(33); packer.Flush(); PackStream.Unpacker unpacker = NewUnpacker(machine.Output()); // Then assertThat(unpacker.UnpackStructHeader(), equalTo(3L)); assertThat(unpacker.UnpackStructSignature(), equalTo('N')); assertThat(unpacker.UnpackLong(), equalTo(12L)); assertThat(unpacker.UnpackListHeader(), equalTo(2L)); assertThat(unpacker.UnpackString(), equalTo("Person")); assertThat(unpacker.UnpackString(), equalTo("Employee")); assertThat(unpacker.UnpackMapHeader(), equalTo(2L)); assertThat(unpacker.UnpackString(), equalTo("name")); assertThat(unpacker.UnpackString(), equalTo("Alice")); assertThat(unpacker.UnpackString(), equalTo("age")); assertThat(unpacker.UnpackLong(), equalTo(33L)); }