@Test public void testSetConsistTypeCS() { NceConsist c = new NceConsist(3, memo); // send a reply the memory read instruction trigged by the constructor above. nnis.sendTestReply(new NceReply(nnis, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"), null); c.setConsistType(jmri.Consist.CS_CONSIST); jmri.util.JUnitAppender.assertErrorMessage("Consist Type Not Supported"); c.dispose(); }
@Test public void checkAddressAllowedGoodAdvanced() { NceConsist c = new NceConsist(3, memo); // send a reply the memory read instruction trigged by the constructor above. nnis.sendTestReply(new NceReply(nnis, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"), null); c.setConsistType(jmri.Consist.ADVANCED_CONSIST); Assert.assertTrue("AddressAllowed", c.isAddressAllowed(new jmri.DccLocoAddress(200, true))); c.dispose(); }
@Test public void testSetConsistTypeAdvanced() { NceConsist c = new NceConsist(3, memo); // send a reply the memory read instruction trigged by the constructor above. nnis.sendTestReply(new NceReply(nnis, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"), null); c.setConsistType(jmri.Consist.ADVANCED_CONSIST); Assert.assertEquals("default consist type", jmri.Consist.ADVANCED_CONSIST, c.getConsistType()); c.dispose(); }
@Test public void checkSizeLimitAdvanced() { NceConsist c = new NceConsist(3, memo); // send a reply the memory read instruction trigged by the constructor above. nnis.sendTestReply(new NceReply(nnis, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"), null); c.setConsistType(jmri.Consist.ADVANCED_CONSIST); Assert.assertEquals("Advanced Consist Limit", 6, c.sizeLimit()); c.dispose(); }
@Test public void testSetConsistTypeOther() { NceConsist c = new NceConsist(3, memo); // send a reply the memory read instruction trigged by the constructor above. nnis.sendTestReply(new NceReply(nnis, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"), null); c.setConsistType(255); // make sure an error message is generated. jmri.util.JUnitAppender.assertErrorMessage("Consist Type Not Supported"); c.dispose(); }
@Test public void checkGetLocoDirectionAdvanced() { NceConsist c = new NceConsist(3, memo); // send a reply the memory read instruction trigged by the constructor above. nnis.sendTestReply(new NceReply(nnis, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"), null); c.setConsistType(jmri.Consist.ADVANCED_CONSIST); jmri.DccLocoAddress A = new jmri.DccLocoAddress(200, true); jmri.DccLocoAddress B = new jmri.DccLocoAddress(250, true); c.restore(A, true); // use restore here, as it does not send // any data to the command station nnis.sendTestReply(new NceReply(nnis, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"), null); c.restore(B, false); // revese direction. nnis.sendTestReply(new NceReply(nnis, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"), null); Assert.assertTrue("Direction in Advanced Consist", c.getLocoDirection(A)); Assert.assertFalse("Direction in Advanced Consist", c.getLocoDirection(B)); c.dispose(); }
@Test public void checkContainsAdvanced() { NceConsist c = new NceConsist(3, memo); // send a reply the memory read instruction trigged by the constructor above. nnis.sendTestReply(new NceReply(nnis, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"), null); c.setConsistType(jmri.Consist.ADVANCED_CONSIST); jmri.DccLocoAddress A = new jmri.DccLocoAddress(200, true); jmri.DccLocoAddress B = new jmri.DccLocoAddress(250, true); // nothing added, should be false for all. Assert.assertFalse("Advanced Consist Contains", c.contains(A)); Assert.assertFalse("Advanced Consist Contains", c.contains(B)); // add just A c.restore(A, true); // use restore here, as it does not send // any data to the command station nnis.sendTestReply(new NceReply(nnis, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"), null); Assert.assertTrue("Advanced Consist Contains", c.contains(A)); Assert.assertFalse("Advanced Consist Contains", c.contains(B)); // then add B c.restore(B, false); nnis.sendTestReply(new NceReply(nnis, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"), null); Assert.assertTrue("Advanced Consist Contains", c.contains(A)); Assert.assertTrue("Advanced Consist Contains", c.contains(B)); c.dispose(); }