Files
Robot-Essentials/.templates/SubsystemTest.java
T

60 lines
1.8 KiB
Java
Raw Normal View History

2020-04-11 12:43:42 -06:00
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
2020-04-11 13:18:40 -06:00
package frc4388.robot.subsystems;
2020-04-11 12:43:42 -06:00
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
2020-04-11 13:18:40 -06:00
import org.junit.*;
2020-04-11 12:43:42 -06:00
2020-04-11 13:18:40 -06:00
import edu.wpi.first.wpilibj.Spark;
import frc4388.robot.Constants.LEDConstants;
import frc4388.utility.LEDPatterns;
2020-04-11 12:43:42 -06:00
/**
2020-04-11 13:18:40 -06:00
* Based off the LEDSubsystemTest class
2020-04-11 12:43:42 -06:00
*/
2020-04-11 13:18:40 -06:00
public class SubsystemTest {
2020-04-11 12:43:42 -06:00
@Test
public void testConstructor() {
// Arrange
Spark ledController = mock(Spark.class);
// Act
LED led = new LED(ledController);
// Assert
assertEquals(LEDConstants.DEFAULT_PATTERN.getValue(), led.getPattern().getValue(), 0.0001);
}
@Test
public void testPatterns() {
// Arrange
Spark ledController = mock(Spark.class);
LED led = new LED(ledController);
// Act
led.setPattern(LEDPatterns.RAINBOW_RAINBOW);
// Assert
assertEquals(LEDPatterns.RAINBOW_RAINBOW.getValue(), led.getPattern().getValue(), 0.0001);
// Act
led.setPattern(LEDPatterns.BLUE_BREATH);
// Assert
assertEquals(LEDPatterns.BLUE_BREATH.getValue(), led.getPattern().getValue(), 0.0001);
// Act
led.setPattern(LEDPatterns.SOLID_BLACK);
// Assert
assertEquals(LEDPatterns.SOLID_BLACK.getValue(), led.getPattern().getValue(), 0.0001);
}
}