예제 #1
0
 public void ConstructorThatThrowsInMock()
 {
     try
     {
         ClassWithThrowingCtor c = MockRepository.Mock <ClassWithThrowingCtor>();
         Assert.NotNull(c);
         Assert.False(true, "Exception expected");
     }
     catch (Exception e)
     {
         string expectedExceptionStartsWith = @"Exception was thrown in constructor: System.Exception: I'm a ctor that throws";
         string actualExceptionStartString  = e.Message.Substring(0, expectedExceptionStartsWith.Length);
         Assert.Equal(expectedExceptionStartsWith, actualExceptionStartString);
     }
 }
예제 #2
0
 public void ConstructorThatThrowsInMock()
 {
     try
     {
         ClassWithThrowingCtor c = mocks.StrictMock(typeof(ClassWithThrowingCtor)) as ClassWithThrowingCtor;
         Assert.NotNull(c);
         Assert.False(true, "Exception expected");
     }
     catch (Exception e)
     {
         string expectedExceptionStartsWith = @"Exception in constructor: System.Exception: I'm a ctor that throws";
         string actualExceptionStartString  = e.Message.Substring(0, expectedExceptionStartsWith.Length);
         Assert.Equal(expectedExceptionStartsWith, actualExceptionStartString);
     }
 }
예제 #3
0
        public void CallNonThrowingProtectedCtor()
        {
            MockRepository mocks = new MockRepository();

            ClassWithThrowingCtor mockClass1 = (ClassWithThrowingCtor)mocks.StrictMock(typeof(ClassWithThrowingCtor), CallOptions.DontCallCtor);
        }
예제 #4
0
 public void CallNonThrowingProtectedCtor()
 {
     ClassWithThrowingCtor mockClass1 = MockRepository
                                        .Mock <ClassWithThrowingCtor>(CallOptions.DontCallCtor);
 }