public void Run_ThrowsException_InputStackIsIncorrect() { // Arrange string operation = "+"; CommandContext context = new CommandContext(); context.PushStack(new MutableKeyValuePair <string, object>("var1", 5)); var math = new MathCommand(operation, context); // Act void result() => math.Run(); // Assert Assert.Throws <CommandExecutionException>(result); }
public void Run_SqrtOfVariable_InputOperationIsSqrt() { // Arrange string operation = "SQRT"; CommandContext context = new CommandContext(); context.PushStack(new MutableKeyValuePair <string, object>("var1", 25)); double expectedNumber = 5; var expectedName = "ans"; var math = new MathCommand(operation, context); // Act math.Run(); // Assert Assert.Equal(expectedNumber, context.Stack.Peek().Value); Assert.Equal(expectedName, context.PeekLastStackElement().Id); }