public void EqualTest() { var ga1 = new KnxTwoLevelGroupAddress(1, 3); var ga2 = new KnxTwoLevelGroupAddress(1, 3); var ga3 = new KnxTwoLevelGroupAddress(4, 6); Assert.AreEqual(true, ga1.Equals(ga2)); Assert.AreEqual(false, ga1.Equals(ga3)); var pa1 = new KnxIndividualAddress(1, 0, 3); var pa2 = new KnxIndividualAddress(ga1.GetAddress()); Assert.AreEqual(false, ga1.Equals(pa1)); Assert.AreEqual(false, ga1.Equals(pa2)); }
public void ConversionTest() { void Check(int MainGroup, int SubGroup, byte[] Expected) { var ga = new KnxTwoLevelGroupAddress(MainGroup, SubGroup); var address = ga.GetAddress(); var gaNew = new KnxTwoLevelGroupAddress(address); Assert.AreEqual(Expected, address); Assert.AreEqual(ga.MainGroup, gaNew.MainGroup); Assert.AreEqual(ga.MiddleGroup, gaNew.MiddleGroup); Assert.AreEqual(ga.SubGroup, gaNew.SubGroup); } Check(20, 180, new byte[] { 0xa0, 0xb4 }); Check(10, 512, new byte[] { 0x52, 0x00 }); }
public void InvalidTest() { void Check(int MainGroup, int SubGroup) { var ga = new KnxTwoLevelGroupAddress(MainGroup, 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/0 is not allowed Check(41, 5); // Main too high Check(15, 3542); // Sub too high }
public void InvalidParserTest() { void Check(string groupAddress) { var ga = new KnxTwoLevelGroupAddress(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("35/45"); Check("5,6"); Check(""); }