Ejemplo n.º 1
0
        public void ValidTest()
        {
            void Check(int area, int line, int participant)
            {
                var pa = new KnxIndividualAddress(area, line, participant);

                Assert.AreEqual(true, pa.IsValid());
                Assert.AreEqual(area, pa.Area);
                Assert.AreEqual(line, pa.Line);
                Assert.AreEqual(participant, pa.Participant);
                Assert.AreEqual(true, pa.Equals(area, line, participant));
                Assert.AreEqual(true, pa.Equals($"{area}.{line}.{participant}"));
            }

            Check(0, 0, 1);
            Check(15, 15, 255);
            Check(10, 10, 10);
        }
Ejemplo n.º 2
0
        public void ValidParserTest()
        {
            void Check(string address, int area, int line, int participant)
            {
                var pa = new KnxIndividualAddress(address);

                Assert.AreEqual(true, pa.IsValid());
                Assert.AreEqual(area, pa.Area);
                Assert.AreEqual(line, pa.Line);
                Assert.AreEqual(participant, pa.Participant);
                Assert.AreEqual(true, pa.Equals(area, line, participant));
                Assert.AreEqual(true, pa.Equals($"{area}.{line}.{participant}"));
            }

            Check("0.0.1", 0, 0, 1);
            Check("15.15.255", 15, 15, 255);
            Check("10.10.10", 10, 10, 10);
        }
Ejemplo n.º 3
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
        }
Ejemplo n.º 4
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("");
        }