Beispiel #1
0
 /** Test of plus method, of class Temperature. */
 @Test
 public void testPlus() {
   Temperature other = new Temperature(10);
   Temperature instance = new Temperature(10);
   Temperature expResult = new Temperature(20);
   Temperature result = instance.plus(other);
   assertEquals(expResult, result);
 }
 @Test
 public void getUnitTest_Celsius() {
   Temperature celciusTemperature = new Temperature(0, Temperature.Units.CELSIUS);
   assertEquals(Temperature.Units.CELSIUS, celciusTemperature.getUnits());
 }
 @Test
 public void getUnitTest_Kelvin() {
   Temperature kelvinTemperature = new Temperature(0, Temperature.units.KELVIN);
   assertEquals(Temperature.Units.KELVIN, kelvinTemperature.getUnits());
 }
Beispiel #4
0
 @Test
 public void shouldConvertToDegreesCelsius() {
   Temperature t1 = new Temperature(273.15);
   assertEquals(0, t1.inCelsius(), 0.1);
 }
 @Test
 public void getValueTest_Fahrenheit_KelvinEqualToZero() {
   Temperature fahrenheitTemperature = new Temperature(-459.67, Temperature.Units.FAHRENHEIT);
   assertEquals(-459.67, fahrenheitTemperature.getValue(), 0);
 }
 @Test
 public void getValueTest_Celsius_KelvinEqualToZero() {
   Temperature celciusTemperature = new Temperature(-273.15, Temperature.Units.CELSIUS);
   assertEquals(-273.15, celciusTemperature.getValue(), 0);
 }
 // getValue() test for Kelvin
 @Test
 public void getValueTest_Kelvin() {
   Temperature kelvinTemperature = new Temperature(0, Temperature.Units.KELVIN);
   assertEquals(0, kelvinTemperature.getValue(), 0);
 }
 @Test
 public void unitToStringTest_Celsius() {
   Temperature celciusTemperature = new Temperature(0, Temperature.Units.CELSIUS);
   assertEquals("буC", celciusTemperature.unitsToString());
 }
Beispiel #9
0
 @Test
 public void hashCodeShouldBeEqualToDegreesKelvin() {
   assertEquals(786, temperature.hashCode());
 }
Beispiel #10
0
 @Test
 public void shouldNotBeEqualToWeirdThing() {
   assertFalse(temperature.equals((Object) (new String("hello"))));
 }
Beispiel #11
0
 @Test
 public void shouldBeEqualToEqualTemperatureAsObject() {
   assertTrue(temperature.equals((Object) (new Temperature(786))));
 }
Beispiel #12
0
 @Test
 public void shouldNotBeEqualToNull() {
   assertFalse(temperature.equals(null));
 }
Beispiel #13
0
 @Test
 public void shouldNotBeEqualToUnEqualTemperature() {
   assertFalse(temperature.equals(new Temperature(785)));
 }
Beispiel #14
0
 @Test
 public void shouldConvertToStringWithUnits() {
   assertEquals("512.85 degrees C", temperature.toString());
 }
Beispiel #15
0
 public void getUnitTest_Fahrenheit() {
   Temperature fahrenheitTemperature = new Temperature(0, Temperature.Units.FAHRENHEIT);
   assertEquals(Temperature.Units.FAHRENHEIT, fahrenheitTemperature.getUnits());
 }
Beispiel #16
0
 @Test
 public void changeUnitsTestForKELVINToFAHRENHEIT() {
   Temperature kelvinTemperature = new Temperature(0, Temperature.Units.KELVIN);
   kelvinTemperature.changeUnits(Temperature.Units.FAHRENHEIT);
   assertEquals(Temperature.Units.FAHRENHEIT, kelvinTemperature.getUnits());
 }
Beispiel #17
0
 @Test
 public void unitToStringTest_Kelvin() {
   Temperature kelvinTemperature = new Temperature(0, Temperature.Units.KELVIN);
   assertEquals("K", kelvinTemperature.unitsToString());
 }
Beispiel #18
0
 // changeUnits() test for Celsius
 @Test
 public void changeUnitsTestForCELSIUSToKELVIN() {
   Temperature celciusTemperature = new Temperature(0, Temperature.Units.CELSIUS);
   celciusTemperature.changeUnits(Temperature.Units.KELVIN);
   assertEquals(Temperature.Units.KELVIN, celciusTemperature.getUnits());
 }
Beispiel #19
0
 @Test
 public void unitToStringTest_Fahrenheit() {
   Temperature fahrenheitTemperature = new Temperature(0, Temperature.Units.FAHRENHEIT);
   assertEquals("буF", fahrenheitTemperature.unitsToString());
 }
Beispiel #20
0
 @Test
 public void changeUnitsTestForCELSIUSToFAHRENHEIT() {
   Temperature celciusTemperature = new Temperature(0, Temperature.Units.CELSIUS);
   celciusTemperature.changeUnits(Temperature.Units.FAHRENHEIT);
   assertEquals(Temperature.Units.FAHRENHEIT, celciusTemperature.getUnits());
 }
Beispiel #21
0
 // getValue() test for Celsius
 @Test
 public void getValueTest_Celsius() {
   Temperature celciusTemperature = new Temperature(0, Temperature.Units.CELSIUS);
   assertEquals(0, celciusTemperature.getValue(), 0);
 }
Beispiel #22
0
 // changeUnits() test for Fahrenheit
 @Test
 public void changeUnitsTestForFAHRENHEITToKELVIN() {
   Temperature fahrenheitTemperature = new Temperature(0, Temperature.Units.FAHRENHEIT);
   fahrenheitTemperature.changeUnits(Temperature.Units.KELVIN);
   assertEquals(Temperature.Units.KELVIN, fahrenheitTemperature.getUnits());
 }
Beispiel #23
0
 // getValue() test for Fahrenheit
 @Test
 public void getValueTest_Fahrenheit() {
   Temperature fahrenheitTemperature = new Temperature(0, Temperature.Units.FAHRENHEIT);
   assertEquals(0, fahrenheitTemperature.getValue(), 0);
 }
Beispiel #24
0
 @Test
 public void changeUnitsTestForFAHRENHEITToCELSIUS() {
   Temperature fahrenheitTemperature = new Temperature(0, Temperature.Units.FAHRENHEIT);
   fahrenheitTemperature.changeUnits(Temperature.Units.CELSIUS);
   assertEquals(Temperature.Units.CELSIUS, fahrenheitTemperature.getUnits());
 }
Beispiel #25
0
 // changeUnits() test for Kelvin
 @Test
 public void changeUnitsTestForKELVINToCELSIUS() {
   Temperature kelvinTemperature = new Temperature(0, Temperature.Units.KELVIN);
   kelvinTemperature.changeUnits(Temperature.Units.CELSIUS);
   assertEquals(Temperature.Units.CELSIUS, kelvinTemperature.getUnits());
 }
Beispiel #26
0
 @Test
 public void degreesKelvinShouldBeUnchanged() {
   assertEquals(786, temperature.inKelvin(), 0.00001);
 }