public void Decode()
        {
            ControlResponse response = new ControlResponse();
            response.wireDecode(TestControlResponse1);

            Assert.AssertEquals(response.getStatusCode(), 404);
            Assert.AssertEquals(response.getStatusText(), "Nothing not found");
            Assert.AssertEquals(response.getBodyAsControlParameters().getFaceId(), 10);
        }
        public void Encode()
        {
            ControlResponse response = new ControlResponse();
            response.setStatusCode(404);
            response.setStatusText("Nothing not found");
            response.setBodyAsControlParameters(new ControlParameters());
            response.getBodyAsControlParameters().setFaceId(10);
            Blob wire = response.wireEncode();

            Assert.AssertEquals(wire.buf(), TestControlResponse1);
        }
        /// <summary>
        /// Decode input as a control parameters in NDN-TLV and set the fields of the
        /// controlResponse object.
        /// </summary>
        ///
        /// <param name="controlResponse"></param>
        /// <param name="input"></param>
        /// <param name="copy">unchanged while the Blob values are used.</param>
        /// <exception cref="EncodingException">For invalid encoding</exception>
        public override void decodeControlResponse(ControlResponse controlResponse,
				ByteBuffer input, bool copy)
        {
            TlvDecoder decoder = new TlvDecoder(input);
            int endOffset = decoder
                    .readNestedTlvsStart(net.named_data.jndn.encoding.tlv.Tlv.NfdCommand_ControlResponse);

            controlResponse.setStatusCode((int) decoder
                    .readNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.NfdCommand_StatusCode));
            // Set copy false since we just immediately get a string.
            Blob statusText = new Blob(
                    decoder.readBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.NfdCommand_StatusText), false);
            controlResponse.setStatusText(statusText.toString());

            // Decode the body.
            if (decoder
                    .peekType(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_ControlParameters, endOffset)) {
                controlResponse.setBodyAsControlParameters(new ControlParameters());
                // Decode into the existing ControlParameters to avoid copying.
                decodeControlParameters(
                        controlResponse.getBodyAsControlParameters(), decoder, copy);
            } else
                controlResponse.setBodyAsControlParameters(null);

            decoder.finishNestedTlvs(endOffset);
        }
        /// <summary>
        /// Encode controlResponse in NDN-TLV and return the encoding.
        /// </summary>
        ///
        /// <param name="controlResponse">The ControlResponse object to encode.</param>
        /// <returns>A Blob containing the encoding.</returns>
        public override Blob encodeControlResponse(ControlResponse controlResponse)
        {
            TlvEncoder encoder = new TlvEncoder(256);
            int saveLength = encoder.getLength();

            // Encode backwards.

            // Encode the body.
            if (controlResponse.getBodyAsControlParameters() != null)
                encodeControlParameters(
                        controlResponse.getBodyAsControlParameters(), encoder);

            encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.NfdCommand_StatusText, new Blob(
                    controlResponse.getStatusText()).buf());
            encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.NfdCommand_StatusCode,
                    controlResponse.getStatusCode());

            encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.NfdCommand_ControlResponse,
                    encoder.getLength() - saveLength);

            return new Blob(encoder.getOutput(), false);
        }