Esempio n. 1
0
        public void ConversionTest()
        {
            void Check(int area, int line, int participant, byte[] Expected)
            {
                var pa      = new KnxIndividualAddress(area, line, participant);
                var address = pa.GetAddress();
                var paNew   = new KnxIndividualAddress(address);

                Assert.AreEqual(Expected, address);
                Assert.AreEqual(pa.Area, paNew.Area);
                Assert.AreEqual(pa.Line, paNew.Line);
                Assert.AreEqual(pa.Participant, paNew.Participant);
            }

            Check(1, 1, 80, new byte[] { 0x11, 0x50 });
            Check(1, 1, 127, new byte[] { 0x11, 0x7f });
            Check(15, 15, 15, new byte[] { 0xFF, 0x0F });
        }
Esempio n. 2
0
        public void InvalidTest()
        {
            void Check(int area, int line, int participant)
            {
                var pa = new KnxIndividualAddress(area, line, participant);

                Assert.AreEqual(false, pa.IsValid());

                // Test if exception is thrown when using an invalid GA
                TestDelegate exceptionTest = () => pa.GetAddress();

                Assert.Throws <InvalidKnxAddressException>(exceptionTest);
            }

            Check(0, 0, 0);     // Not allowed
            Check(16, 1, 1);    // Area too high
            Check(10, 16, 1);   // Line too high
            Check(10, 10, 300); // Participant too high
        }
Esempio n. 3
0
        public void InvalidParserTest()
        {
            void Check(string address)
            {
                var pa = new KnxIndividualAddress(address);

                Assert.AreEqual(false, pa.IsValid());

                // Test if exception is thrown when using an invalid GA
                TestDelegate exceptionTest = () => pa.GetAddress();

                Assert.Throws <InvalidKnxAddressException>(exceptionTest);
            }

            Check("16.16.16");
            Check("0/0");
            Check("0");
            Check("15,15,15");
            Check("5,6");
            Check("");
        }