Esempio n. 1
0
        public void TestMockMethodForAdd()
        {
            MockMethod add = new MockMethod(typeof(ICalculator), "Add");

            add.With(5, 3).Return(8);
            add.With(2, 7).Return(9);
            Assert.AreEqual(add.Call(5, 3), 8);
            Assert.AreEqual(add.Call(2, 7), 9);
            Assert.AreEqual(add.Call(4, 8), 0);
        }
 int Div(int a, int b)
 {
     for (int i = 0; i < mms.Length; i++)
     {
         MockMethod m = mms[i];
         if (m.Method.Name.Equals("Add"))
         {
             return((int)m.Call(a, b));
         }
     }
     throw new InvalidOperationException();
 }
 public string GetBody(string url)
 {
     for (int i = 0; i < mm.Length; i++)
     {
         MockMethod m = mm[i];
         if (m.Method.Name.Equals("GetBody"))
         {
             return((string)m.Call(url));
         }
     }
     throw new InvalidOperationException();
 }
 public void Dispose()
 {
     for (int i = 0; i < mm.Length; i++)
     {
         MockMethod m = mm[i];
         if (m.Method.Name.Equals("GetBody"))
         {
             m.Call();
         }
     }
     throw new InvalidOperationException();
 }
    void Dispose()
    {
        MockMethod m = RetrieveMethod("Dispose");

        m.Call();
    }
    string GetBody(string url)
    {
        MockMethod m = RetrieveMethod("GetBody");

        return((string)m.Call(url));
    }