private void Update() { if (roomWidthTextbox == null || roomHeightTextbox == null || roomLengthTextbox == null || paintPerLitreTextbox == null || floorAreaLabel == null || roomVolumeLabel == null || paintRequiredLabel == null) { return; } double roomWidth, roomLength, roomHeight, paintPerLitre; bool invalidValue = false; roomWidth = CheckTextbox(roomWidthTextbox, ref invalidValue); roomLength = CheckTextbox(roomLengthTextbox, ref invalidValue); roomHeight = CheckTextbox(roomHeightTextbox, ref invalidValue); paintPerLitre = CheckTextbox(paintPerLitreTextbox, ref invalidValue); if (invalidValue) { floorAreaLabel.Content = "<Invalid Input>"; roomVolumeLabel.Content = "<Invalid Input>"; paintRequiredLabel.Content = "<Invalid Input>"; } else { floorAreaLabel.Content = RoomMath.floorArea(roomWidth, roomLength) + " m²"; roomVolumeLabel.Content = RoomMath.roomVolume(roomWidth, roomLength, roomHeight) + " m³"; paintRequiredLabel.Content = RoomMath.paintRequired(roomWidth, roomLength, roomHeight, paintPerLitre).ToString("N2") + " litres"; } }
public void roomVolume_outOfRangeInput() { RoomMath.roomVolume(-10.0, 10.0, 10.0); RoomMath.roomVolume(10.0, -10.0, 10.0); RoomMath.roomVolume(10.0, 10.0, -10.0); RoomMath.roomVolume(Double.PositiveInfinity, 10.0, 10.0); RoomMath.roomVolume(10.0, Double.PositiveInfinity, 10.0); RoomMath.roomVolume(10.0, 10.0, Double.PositiveInfinity); }
public void roomVolume_Valid() { double volume = RoomMath.roomVolume(10.0, 10.0, 10.0); Assert.AreEqual(1000.0, volume); volume = RoomMath.roomVolume(1.0, 1.0, 1.0); Assert.AreEqual(1.0, volume); volume = RoomMath.roomVolume(0.5, 0.5, 0.5); Assert.AreEqual(0.125, volume); }
public void roomVolume_InputsTooLarge() { RoomMath.roomVolume(Double.MaxValue, Double.MaxValue, Double.MaxValue); }