Skip to content

Commit

Permalink
Test pour TextInterfaceToListeners
Browse files Browse the repository at this point in the history
  • Loading branch information
ooohhheven committed Oct 1, 2024
1 parent d0685cc commit 66fbcba
Showing 1 changed file with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.marginallyclever.makelangelo.plotter.plottercontrols;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class TestTextInterfaceToListeners {

private TextInterfaceToListeners textInterface;

@BeforeEach
public void setUp() {
textInterface = new TextInterfaceToListeners();
}

@Test
public void testSendCommand() {
ActionListener listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
assertEquals("test command", e.getActionCommand());
}
};
textInterface.addActionListener(listener);
textInterface.sendCommand("test command");
textInterface.removeActionListener(listener);
}

@Test
public void testSendNow() {
ActionListener listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
assertEquals("test command", e.getActionCommand());
}
};
textInterface.addActionListener(listener);
textInterface.setCommand("test command");
textInterface.sendNow();
textInterface.removeActionListener(listener);
}

@Test
public void testGetCommand() {
textInterface.setCommand("test command");
assertEquals("test command", textInterface.getCommand());
}
}

0 comments on commit 66fbcba

Please sign in to comment.