public PrgState OneStep(PrgState state) { IMyStack <IStatement> stack = state.Stack; if (!(stack.IsEmpty())) { IStatement statement = stack.Pop(); return(statement.Execute(state)); } return(null); }
public void MyStack_1_Constructor_1_IsEmptyReturnsTrue() { // Arrange IMyStack <string> stack = DSBuilder.CreateMyStack(); bool expected = true; // Act bool actual = stack.IsEmpty(); // Assert Assert.AreEqual(expected, actual); }
public PrgState OneStep(PrgState state) { IMyStack <IStmt> stk = state.ExeStack; if (stk.IsEmpty()) { throw new Exception("The execution stack is empty"); } IStmt crtStmt = stk.Pop(); return(crtStmt.Execute(state)); }
public void MyStack_2_Push_1_IsEmptyReturnsFalse() { // Arrange IMyStack <string> stack = DSBuilder.CreateMyStack(); bool expected = false; // Act stack.Push("a"); bool actual = stack.IsEmpty(); // Assert Assert.AreEqual(expected, actual); }
public void MyStack_4_Pop_2_IsEmptyReturnsTrueAfterTopOnOneElement() { // Arrange IMyStack <string> stack = DSBuilder.CreateMyStack(); bool expected = true; // Act stack.Push("a"); stack.Pop(); bool actual = stack.IsEmpty(); // Assert Assert.AreEqual(expected, actual); }
public void MyStack_3_Top_2_IsEmptyReturnsFalseAfterTopOnOneElement() { // Arrange IMyStack <int> stack = DSBuilder.CreateMyArrayListStack(); bool expected = false; // Act stack.Push(1); stack.Top(); bool actual = stack.IsEmpty(); // Assert Assert.AreEqual(expected, actual); }