public void Test_ReturnValue_Getter() { MethodReturnValue mrv = new MethodReturnValue("TestMethod", 3); Assert.AreEqual(3, mrv.ReturnValue); }
public void Test_CallCount_Getter() { MethodReturnValue mrv = new MethodReturnValue("TestMethod", 3, 5); Assert.AreEqual(5, mrv.CallCount); }
public void Test_MethodName_Getter() { MethodReturnValue mrv = new MethodReturnValue("TestMethod", 3); Assert.AreEqual("TestMethod", mrv.MethodName); }
/// <summary> /// This method is used to specify the particular value to return from a method /// when it is called on the specified call count. /// </summary> /// <param name="methodName">Name of the method.</param> /// <param name="returnVal">Value to return.</param> /// <param name="callCount">Call count to return the given value.</param> public void SetMethodReturnValue(string methodName, Object returnVal, int callCount = 0) { if(methodName == null || methodName.Length == 0) { string msg = "The provided methodName cannot be empty."; throw new ArgumentException(msg); } MethodReturnValue methodReturn = null; if(callCount == 0) { methodReturn = new MethodReturnValue(methodName, returnVal); } else { methodReturn = new MethodReturnValue(methodName, returnVal, callCount); } for(int i = 0; i < this.m_methodReturns.Count; i++) { MethodReturnValue mrv = this.m_methodReturns[i]; if(mrv.MethodName == methodName && mrv.CallCount == callCount) { this.m_methodReturns[i] = methodReturn; return; } } this.m_methodReturns.Add(methodReturn); }