public bool Equals(AnalogValue other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return other.Value == Value; }
private static bool? CheckEqualBase(AnalogValue value1, AnalogValue value2) { // If both are null, or both are same instance, return true. if (System.Object.ReferenceEquals(value1, value2)) { return true; } // If one is null, but not both, return false. if (((object)value1 == null) || ((object)value2 == null)) { return false; } return null; }
/// <summary> /// Adjust the <paramref name="value"/> with this formul : (<paramref name="value"/> * <paramref name="gain"/> ) + <paramref name="offset"/> /// </summary> /// <param name="value">Input analog Value.</param> /// <param name="gain">Gain. Multiply the <paramref name="value"/>.</param> /// <param name="offset">Offset is added of the result (<paramref name="value"/> * <paramref name="gain"/>).</param> /// <returns></returns> public static AnalogValue AdjustValue(AnalogValue value, AnalogValue gain, AnalogValue offset) { return (value * gain) + offset; }
/// <summary> /// Deltas => value1 - value2. /// </summary> /// <param name="value1">The value1.</param> /// <param name="value2">The value2.</param> /// <returns></returns> public AnalogValue DeltaV1V2(AnalogValue value1, AnalogValue value2) { return value1 - value2; }
public void AnalogParamWhenOperatorBiggerThenResponseOk(AnalogValue param1, AnalogValue param2, AnalogValue responsePlus, AnalogValue responseMinus, AnalogValue reponseMultiply, AnalogValue responseDivid) { bool rep = param1.Value > param2.Value; (param1 > param2).Should().Be(rep, "{0} > {1} is {2}", param1, param2, rep); }
/// <summary> /// Adjust the <paramref name="value"/> with this formul : (<paramref name="value"/> * <paramref name="gain"/> ) + <paramref name="offset"/> /// </summary> /// <param name="value">Input analog Value.</param> /// <param name="gain">Gain. Multiply the <paramref name="value"/>.</param> /// <param name="offset">Offset is added of the result (<paramref name="value"/> * <paramref name="gain"/>).</param> /// <returns></returns> public static AnalogValue AdjustValue(IValue value, AnalogValue gain, AnalogValue offset) { var valueAnalog = value as AnalogValue; return AdjustValue(valueAnalog, gain, offset); }
public void AnalogParamWhenOperatorAddValueThenResponseOk(AnalogValue param1, AnalogValue param2, AnalogValue responsePlus, AnalogValue responseMinus, AnalogValue reponseMultiply, AnalogValue responseDivid) { (param1 + param2).Should().Be(responsePlus, "{0} * {1} = {2}", param1, param2, responsePlus); }
public AnalogValueTest() { this.testee = new AnalogValue(); }
public void EqualThenValue1EqualValue2ThenTrue(AnalogValue param1, AnalogValue param2, bool response) { param1.Equals(param2).Should().Be(response, "param1.Equal(param2) => {0} == {1} is {2}", param1, param2, response); }
public void AnalogParamWhenOperatorEqualOrLessThenResponseOk(AnalogValue param1, AnalogValue param2, AnalogValue responsePlus, AnalogValue responseMinus, AnalogValue reponseMultiply, AnalogValue responseDivid) { bool rep = param1.Value <= param2.Value; (param1 <= param2).Should().Be(rep, "{0} <= {1} is {2}", param1, param2, rep); }
public void AnalogParamWhenOperatorDivideValueThenResponseOk(AnalogValue param1, AnalogValue param2, AnalogValue responsePlus, AnalogValue responseMinus, AnalogValue reponseMultiply, AnalogValue responseDivid) { if (param2.Value != 0) { (param1 / param2).Should().Be(responseDivid, "{0} * {1} = {2}", param1, param2, responseDivid); } else { try { AnalogValue rep1 = param1 / param2; const bool REP = false; REP.Should().BeTrue("Not Exception!"); } catch (DivideByZeroException) { const bool REP = true; REP.Should().BeTrue("DivideByZeroException."); } catch (Exception) { const bool REP = false; REP.Should().BeTrue("Not DivideByZeroException!"); } } }