Пример #1
0
        public void ValidTest()
        {
            void Check(int SubGroup)
            {
                var ga = new KnxFreeStyleGroupAddress(SubGroup);

                Assert.AreEqual(true, ga.IsValid());
                Assert.AreEqual(SubGroup, ga.SubGroup);
            }

            Check(1);        // Min
            Check(65535);    // Max
            Check(18);
            Check(12045);
        }
Пример #2
0
        public void ValidParserTest()
        {
            void Check(string groupAddress, int SubGroup)
            {
                var ga = new KnxFreeStyleGroupAddress(groupAddress);

                Assert.AreEqual(true, ga.IsValid());
                Assert.AreEqual(SubGroup, ga.SubGroup);
            }

            Check("1", 1);
            Check("65535", 65535);
            Check("18", 18);
            Check("12045", 12045);
        }
Пример #3
0
        public void InvalidTest()
        {
            void Check(int SubGroup)
            {
                var ga = new KnxFreeStyleGroupAddress(SubGroup);

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

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

                Assert.Throws <InvalidKnxAddressException>(exceptionTest);
            }

            Check(0);        // 0/0/0 is not allowed
            Check(70565);    // Sub too high
        }
Пример #4
0
        public void InvalidParserTest()
        {
            void Check(string groupAddress)
            {
                var ga = new KnxFreeStyleGroupAddress(groupAddress);

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

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

                Assert.Throws <InvalidKnxAddressException>(exceptionTest);
            }

            Check("0/0/0");
            Check("0/0");
            Check("0");
            Check("70235");
            Check("5,6");
            Check("");
        }