public void ThrowsWhenWritingBigValueToShortVariable(double value, bool throwsException) { var variable = new Variable("A%", new short[] { }); var sut = new VariableReference(variable, new short[] { }); Test.Throws <IllegalQuantityException>(() => sut.SetValue(new Accumulator(value)), throwsException); }
public void CanWriteAndReadToShortArrayVariable() { var variable = new Variable("A%", new short[] { 6, 6 }); var sut = new VariableReference(variable, new short[] { 2, 2 }); sut.SetValue(new Accumulator(-3000.0)); Assert.AreEqual(-3000, sut.GetValue().ValueAsShort()); Assert.IsFalse(sut.IsString); }
public void CanWriteAndReadToDoubleArrayVariable() { var variable = new Variable("A", new short[] { 7, 7 }); var sut = new VariableReference(variable, new short[] { 4, 4 }); sut.SetValue(new Accumulator(40000.25)); Assert.AreEqual(40000.25, sut.GetValue().ValueAsDouble()); Assert.IsFalse(sut.IsString); }
public void CanWriteAndReadToStringVariable() { var variable = new Variable("A$", new short[] { }); var sut = new VariableReference(variable, new short[] { }); sut.SetValue(new Accumulator("HELLO")); Assert.AreEqual("HELLO", sut.GetValue().ValueAsString()); Assert.IsTrue(sut.IsString); }