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 paintRequired_Valid() { double volume = RoomMath.paintRequired(10.0, 10.0, 10.0, 10.0); Assert.AreEqual(40.0, volume); volume = RoomMath.paintRequired(1.0, 1.0, 1.0, 1.0); Assert.AreEqual(4.0, volume); }
public void paintRequired_outOfRangeInput() { RoomMath.paintRequired(-10.0, 10.0, 10.0, 10.0); RoomMath.paintRequired(10.0, -10.0, 10.0, 10.0); RoomMath.paintRequired(10.0, 10.0, -10.0, 10.0); RoomMath.paintRequired(10.0, 10.0, 10.0, -10.0); RoomMath.paintRequired(Double.PositiveInfinity, 10.0, 10.0, 10.0); RoomMath.paintRequired(10.0, Double.PositiveInfinity, 10.0, 10.0); RoomMath.paintRequired(10.0, 10.0, Double.PositiveInfinity, 10.0); RoomMath.paintRequired(10.0, 10.0, 10.0, Double.PositiveInfinity); }
public void paintRequired_InputsTooLarge() { RoomMath.paintRequired(Double.MaxValue, Double.MaxValue, Double.MaxValue, Double.MaxValue); }