public void ReceivesExceptionIfParameterBandsAreInappropriate() { try { var propertyDecoder = new ResisterPropertyDecoder(); propertyDecoder.CalculateOhmValue("PK", "RD", "WH", "OG"); Assert.Fail(); } catch (Exception exc) { } try { //Tolerance value fault var propertyDecoder = new ResisterPropertyDecoder(); propertyDecoder.CalculateOhmValue("WH", "VT", "BK", "PK"); Assert.Fail(); } catch (Exception exc) { } try { //Multiplier value fault var propertyDecoder = new ResisterPropertyDecoder(); propertyDecoder.CalculateOhmValue("BK", "BN", "None", "RD"); Assert.Fail(); } catch (Exception exc) { } }
public void ReceivesExceptionIfParameterNamesAreInvalid() { try { var propertyDecoder = new ResisterPropertyDecoder(); propertyDecoder.CalculateOhmValue("", "asdfasdf", "brandBColor", "White"); Assert.Fail(); } catch (Exception exc) { } }
public void WillNotOverflowOnCalcuation() { try { var propertyDecoder = new ResisterPropertyDecoder(); propertyDecoder.CalculateOhmValue("WH", "WH", "WH", "M"); } catch (ArithmeticException exc) { Assert.Fail(exc.Message); } catch (Exception exc) { Assert.Fail(exc.Message); } }
public void ProducesNumericResultForCorrectBandConfiguration() { var propertyDecoder = new ResisterPropertyDecoder(); Assert.AreEqual(propertyDecoder.CalculateOhmValue("GN", "BU", "BN", "BN"), 565); //560 ohms + 1% truncating the decimal per Json's feedback. }