@Test public void shouldReturnHypoColorIfPurpleStringIsGiven() { int expected = context.getColor(R.color.glucosio_reading_hypo); int actual = glucoseRanges.stringToColor("purple"); assertEquals(expected, actual); }
public int stringToColor(String color) { @ColorRes int colorInt; switch (color) { case "green": colorInt = R.color.glucosio_reading_ok; break; case "red": colorInt = R.color.glucosio_reading_hyper; break; case "blue": colorInt = R.color.glucosio_reading_low; break; case "orange": colorInt = R.color.glucosio_reading_high; break; default: colorInt = R.color.glucosio_reading_hypo; } return ContextCompat.getColor(mContext, colorInt); }
GlucoseRanges { public int stringToColor(String color) { @ColorRes int colorInt; switch (color) { case "green": colorInt = R.color.glucosio_reading_ok; break; case "red": colorInt = R.color.glucosio_reading_hyper; break; case "blue": colorInt = R.color.glucosio_reading_low; break; case "orange": colorInt = R.color.glucosio_reading_high; break; default: colorInt = R.color.glucosio_reading_hypo; } return ContextCompat.getColor(mContext, colorInt); } }
GlucoseRanges { public int stringToColor(String color) { @ColorRes int colorInt; switch (color) { case "green": colorInt = R.color.glucosio_reading_ok; break; case "red": colorInt = R.color.glucosio_reading_hyper; break; case "blue": colorInt = R.color.glucosio_reading_low; break; case "orange": colorInt = R.color.glucosio_reading_high; break; default: colorInt = R.color.glucosio_reading_hypo; } return ContextCompat.getColor(mContext, colorInt); } GlucoseRanges(Context context); }
GlucoseRanges { public int stringToColor(String color) { @ColorRes int colorInt; switch (color) { case "green": colorInt = R.color.glucosio_reading_ok; break; case "red": colorInt = R.color.glucosio_reading_hyper; break; case "blue": colorInt = R.color.glucosio_reading_low; break; case "orange": colorInt = R.color.glucosio_reading_high; break; default: colorInt = R.color.glucosio_reading_hypo; } return ContextCompat.getColor(mContext, colorInt); } GlucoseRanges(Context context); static int getPresetMin(String preset); static int getPresetMax(String preset); String colorFromReading(double reading); int stringToColor(String color); }
GlucoseRanges { public int stringToColor(String color) { @ColorRes int colorInt; switch (color) { case "green": colorInt = R.color.glucosio_reading_ok; break; case "red": colorInt = R.color.glucosio_reading_hyper; break; case "blue": colorInt = R.color.glucosio_reading_low; break; case "orange": colorInt = R.color.glucosio_reading_high; break; default: colorInt = R.color.glucosio_reading_hypo; } return ContextCompat.getColor(mContext, colorInt); } GlucoseRanges(Context context); static int getPresetMin(String preset); static int getPresetMax(String preset); String colorFromReading(double reading); int stringToColor(String color);  }