コード例 #1
0
ファイル: OrderTest.cs プロジェクト: jefxiong/RhinoMocks
 private static void ConfigureOrderedTimesMin0WithNestedUnordered(MockRepository mocks, I1 mockObject)
 {
     using (mocks.Ordered())
     {
         mockObject.A();
         LastCall.Repeat.Times(0, 1);
         using (mocks.Unordered())
         {
             mockObject.B();
             mockObject.C();
         }
         mockObject.A();
         LastCall.Repeat.Times(0, 1);
     }
 }
コード例 #2
0
ファイル: OrderTest.cs プロジェクト: jefxiong/RhinoMocks
 private static void ConfigureOrderedTimesMinNonZeroMaxHigherThanMin(MockRepository mocks, I1 mockObject)
 {
     using (mocks.Ordered())
     {
         mockObject.A();
         mockObject.B();
         LastCall.Repeat.Times(1, 3);
         mockObject.C();
     }
 }
コード例 #3
0
ファイル: OrderTest.cs プロジェクト: jefxiong/RhinoMocks
 private static void ConfigureOrderedAtLeastOnce(MockRepository mocks, I1 mockObject)
 {
     using (mocks.Ordered())
     {
         mockObject.A();
         mockObject.B();
         LastCall.Repeat.AtLeastOnce();
         mockObject.C();
     }
 }
コード例 #4
0
ファイル: OrderTest.cs プロジェクト: jefxiong/RhinoMocks
        /// <summary>
        /// Sets up a mock, and runs through methods as specified by characters in <paramref name="methodOrder"/>.
        /// </summary>
        /// <param name="mockConfigurer">A delegate to use to configure the mock.</param>
        /// <param name="isValid">Whether the order should be valid or not.</param>
        /// <param name="methodOrder">The method order (e.g. "ABC", "ABBC").</param>
        private static void AssertOrderValidity(ConfigureMockDelegate mockConfigurer, bool isValid,
                                                string methodOrder)
        {
            MockRepository mocks = new MockRepository();

            I1 i = mocks.StrictMock(typeof(I1)) as I1;

            mockConfigurer(mocks, i);

            mocks.ReplayAll();

            try
            {
                foreach (char c in methodOrder)
                {
                    switch (c)
                    {
                    case 'A':
                        i.A();
                        break;

                    case 'B':
                        i.B();
                        break;

                    case 'C':
                        i.C();
                        break;

                    default:
                        throw new NotSupportedException();
                    }
                }
                mocks.VerifyAll();
            }
            catch (Exceptions.ExpectationViolationException ex)
            {
                if (isValid)
                {
                    Assert.False(true, string.Format("Order {0} was supposed to be ok, but got error: {1}", methodOrder, ex.Message));
                }
                else
                {
                    return;
                }
            }

            if (!isValid)
            {
                Assert.False(true, string.Format("Order {0} was supposed to fail, but did not.", methodOrder));
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: hgouw/Test
        static void Main(string[] args)
        {
            C  c  = new C();
            I1 i1 = (I1)c;
            I2 i2 = (I2)c;

            i1.A();
            i2.A();
            c.A();
            Console.ReadLine();

            D d = new D();

            i1 = (I1)d;
            i2 = (I2)d;
            i1.A();
            i2.A();
            d.A();
            Console.ReadLine();

            E e = new E();

            i1 = (I1)e;
            i2 = (I2)e;
            i1.A();
            i2.A();
            e.A();
            Console.ReadLine();

            F f = new F();

            //f.A(); --- COMPILE ERROR
            i1 = (I1)f;
            //i2 = (I2)f; --- RUNTIME ERROR
            i1.A();
            Console.ReadLine();
        }
コード例 #6
0
ファイル: OrderTest.cs プロジェクト: medmondson/RhinoMocks
 private static void ConfigureOrderedTimesMinNonZeroMaxHigherThanMin(MockRepository mocks, I1 mockObject)
 {
     using (mocks.Ordered())
     {
         mockObject.A();
         mockObject.B();
         LastCall.Repeat.Times(1, 3);
         mockObject.C();
     }
 }
コード例 #7
0
ファイル: OrderTest.cs プロジェクト: medmondson/RhinoMocks
 private static void ConfigureOrderedTimesMin0WithNestedUnordered(MockRepository mocks, I1 mockObject)
 {
     using (mocks.Ordered())
     {
         mockObject.A();
         LastCall.Repeat.Times(0, 1);
         using (mocks.Unordered())
         {
             mockObject.B();
             mockObject.C();
         }
         mockObject.A();
         LastCall.Repeat.Times(0, 1);
     }
 }
コード例 #8
0
ファイル: OrderTest.cs プロジェクト: medmondson/RhinoMocks
 private static void ConfigureOrderedAtLeastOnce(MockRepository mocks, I1 mockObject)
 {
     using (mocks.Ordered())
     {
         mockObject.A();
         mockObject.B();
         LastCall.Repeat.AtLeastOnce();
         mockObject.C();
     }
 }