Пример #1
0
 private static void ConfigureOrderedTimesMinNonZeroMaxHigherThanMin(MockRepository mocks, I1 mockObject)
 {
     using (mocks.Ordered())
     {
         mockObject.A();
         mockObject.B();
         LastCall.Repeat.Times(1, 3);
         mockObject.C();
     }
 }
Пример #2
0
 private static void ConfigureOrderedAtLeastOnce(MockRepository mocks, I1 mockObject)
 {
     using (mocks.Ordered())
     {
         mockObject.A();
         mockObject.B();
         LastCall.Repeat.AtLeastOnce();
         mockObject.C();
     }
 }
Пример #3
0
 private static void ConfigureOrderedTimesMin0(MockRepository mocks, I1 mockObject)
 {
     using (mocks.Ordered())
     {
         mockObject.A();
         LastCall.Repeat.Times(0, 1);
         mockObject.B();
         LastCall.Repeat.Times(0, 1);
         mockObject.C();
         LastCall.Repeat.Times(0, 1);
     }
 }
Пример #4
0
        /// <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
 private static void ConfigureOrderedTimesMinNonZeroMaxHigherThanMin(MockRepository mocks, I1 mockObject)
 {
     using (mocks.Ordered())
     {
         mockObject.A();
         mockObject.B();
         LastCall.Repeat.Times(1, 3);
         mockObject.C();
     }
 }
Пример #6
0
 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);
     }
 }
Пример #7
0
 private static void ConfigureOrderedAtLeastOnce(MockRepository mocks, I1 mockObject)
 {
     using (mocks.Ordered())
     {
         mockObject.A();
         mockObject.B();
         LastCall.Repeat.AtLeastOnce();
         mockObject.C();
     }
 }