public void False_Encoded()
            {
                IByteEncodable cavh = new ConnAckVariableHeader(false, ConnectReturnCode.Accepted);

                IEnumerable <byte> encodedBytes = cavh.Encode();

                Assert.AreEqual(0x00, encodedBytes.First());
            }
            public void Not_Authorized_encoded()
            {
                IByteEncodable cavh = new ConnAckVariableHeader(false, ConnectReturnCode.NotAuthorized);

                Assert.AreEqual(0x05, cavh.Encode().Skip(1).First());
            }
            public void Authentication_Failed_encoded()
            {
                IByteEncodable cavh = new ConnAckVariableHeader(false, ConnectReturnCode.AuthenticationFailed);

                Assert.AreEqual(0x04, cavh.Encode().Skip(1).First());
            }
            public void Server_Unavailable_encoded()
            {
                IByteEncodable cavh = new ConnAckVariableHeader(false, ConnectReturnCode.ServerUnavailable);

                Assert.AreEqual(0x03, cavh.Encode().Skip(1).First());
            }
            public void Identifier_Rejected_encoded()
            {
                IByteEncodable cavh = new ConnAckVariableHeader(false, ConnectReturnCode.IdentifierRejected);

                Assert.AreEqual(0x02, cavh.Encode().Skip(1).First());
            }
            public void Unsupported_Protocol_encoded()
            {
                IByteEncodable cavh = new ConnAckVariableHeader(false, ConnectReturnCode.UnsupportedProtocol);

                Assert.AreEqual(0x01, cavh.Encode().Skip(1).First());
            }
            public void Accepted_encoded()
            {
                IByteEncodable cavh = new ConnAckVariableHeader(false, ConnectReturnCode.Accepted);

                Assert.AreEqual(0x00, cavh.Encode().Skip(1).First());
            }
示例#8
0
        public void AuthenticationFailedTest()
        {
            VariableHeader vh = new ConnAckVariableHeader(true, ConnectReturnCode.AuthenticationFailed);
            FixedHeader    fh = FixedHeader.CreateStandardHeader(ControlPacketType.CONNACK, (UInt16)(vh.Encode().Count() + pn.Encode().Count()));

            Assert.IsTrue(CheckExpectedByteEncoding(fh, AuthenticationFailed.FixedHeader));
            Assert.IsTrue(CheckExpectedByteEncoding(vh, AuthenticationFailed.VariableHeader));
            Assert.IsTrue(CheckExpectedByteEncoding(pn, AuthenticationFailed.Payload));
        }
示例#9
0
        public void ServerUnavailableTest()
        {
            VariableHeader vh = new ConnAckVariableHeader(false, ConnectReturnCode.ServerUnavailable);
            FixedHeader    fh = FixedHeader.CreateStandardHeader(ControlPacketType.CONNACK, (UInt16)(vh.Encode().Count() + pn.Encode().Count()));

            Assert.IsTrue(CheckExpectedByteEncoding(fh, ServerUnavailable.FixedHeader));
            Assert.IsTrue(CheckExpectedByteEncoding(vh, ServerUnavailable.VariableHeader));
            Assert.IsTrue(CheckExpectedByteEncoding(pn, ServerUnavailable.Payload));
        }
示例#10
0
        public void Connection_accepted_response_encoded_correctly()
        {
            VariableHeader vh = new ConnAckVariableHeader(true, ConnectReturnCode.Accepted);
            FixedHeader    fh = FixedHeader.CreateStandardHeader(ControlPacketType.CONNACK, (UInt16)(vh.Encode().Count() + pn.Encode().Count()));

            Assert.IsTrue(CheckExpectedByteEncoding(fh, Accepted.FixedHeader));
            Assert.IsTrue(CheckExpectedByteEncoding(vh, Accepted.VariableHeader));
            Assert.IsTrue(CheckExpectedByteEncoding(pn, Accepted.Payload));
        }