public void VariableRepositoryTestRedimensionThrowsException(string variableName, bool throwsException) { IVariableRepository sut = new VariableRepository(); sut.DimensionArray("AB", new short[] { 2, 3 }); Test.Throws <RedimensionedArrayException>( () => sut.DimensionArray(variableName, new short[] { 2, 3 }), throwsException); }
public void VariableRepositoryTestDimension(short first, short second, bool shouldThrow) { IVariableRepository sut = new VariableRepository(); bool exceptionThrown = false; sut.DimensionArray("AB", new short[] { 2, 3 }); var doubleArrayReference = sut.GetOrCreateVariable("AB", new short[] { first, second }); try { doubleArrayReference.SetValue(new Accumulator(2.0)); } catch (ClassicBasic.Interpreter.Exceptions.BadSubscriptException) { exceptionThrown = true; } Assert.AreEqual(shouldThrow, exceptionThrown); }