public void Test_SetMethodReturnValue_Properly_Overwrites_Previous_Sets() { Mock mock = new Mock(); mock.SetMethodReturnValue("TestMethod", "a", 1); mock.SetMethodReturnValue("TestMethod", "b", 2); mock.SetMethodReturnValue("TestMethod", "c", 1); ArrayList args = new ArrayList(); args.Add(1); args.Add(2); string retval = (string)mock.MethodCalled("TestMethod", args); Assert.AreEqual("c", retval, "with call count"); mock = new Mock(); mock.SetMethodReturnValue("TestMethod", "a"); mock.SetMethodReturnValue("TestMethod", "b"); args = new ArrayList(); args.Add(1); args.Add(2); retval = (string)mock.MethodCalled("TestMethod", args); Assert.AreEqual("b", retval, "without call count"); }
public void Test_SetMethodReturnValue_Throws_ArgumentException_On_Null_Name() { Mock mock = new Mock(); mock.SetMethodReturnValue(null, 1, 1); }
public void Test_MethodReturnValue_Getter_And_Setter() { Mock mock = new Mock(); mock.SetMethodReturnValue("TestMethod", "a", 1); mock.SetMethodReturnValue("TestMethod", "b", 2); mock.SetMethodReturnValue("TestMethod", "c", 3); mock.SetMethodReturnValue("TestMethod", "d", 4); ArrayList args = new ArrayList(); args.Add(1); args.Add(2); Assert.AreEqual("a", mock.MethodCalled("TestMethod", args)); Assert.AreEqual("b", mock.MethodCalled("TestMethod", args)); Assert.AreEqual("c", mock.MethodCalled("TestMethod", args)); Assert.AreEqual("d", mock.MethodCalled("TestMethod", args)); mock.SetMethodReturnValue("OtherMethod", "z"); Assert.AreEqual("z", mock.MethodCalled("OtherMethod", args)); Assert.AreEqual("z", mock.MethodCalled("OtherMethod", args)); Assert.AreEqual("z", mock.MethodCalled("OtherMethod", args)); }