Files
JIMRI/java/test/jmri/SectionTest.java
T
2026-06-17 14:00:51 +02:00

60 lines
1.5 KiB
Java

package jmri;
import jmri.util.JUnitUtil;
import jmri.implementation.DefaultSection;
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Tests for Section class.
*
* @author Bob Jacobsen Copyright (C) 2017
* @author Paul Bender Copyright (C) 2016
**/
public class SectionTest {
@Test
public void testSectionSysNameConstructorTest(){
assertNotNull( new DefaultSection("TS1"), "Constructor");
}
@Test
public void testSectionTwoNameStringConstructorTest(){
assertNotNull( new DefaultSection("TS1", "user name"), "Constructor");
}
@Test
public void testWarnOnBlockAdd() {
Section s = new DefaultSection("TS1");
assertEquals(0, s.getBlockList().size());
s.addBlock(new Block("IB1", "user"));
assertEquals(1, s.getBlockList().size());
}
@Test
public void testWarnOnBlockAddWithNoUserName() {
Section s = new DefaultSection("TS1");
assertEquals(0, s.getBlockList().size());
s.addBlock(new Block("IB1"));
jmri.util.JUnitAppender.assertWarnMessage("Block IB1 does not have a user name, may not work correctly in Section TS1");
assertEquals(1, s.getBlockList().size());
}
@BeforeEach
public void setUp() {
JUnitUtil.setUp();
JUnitUtil.initDefaultUserMessagePreferences();
}
@AfterEach
public void tearDown(){
JUnitUtil.tearDown();
}
}