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); } }
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); } }
public void CallNonThrowingProtectedCtor() { MockRepository mocks = new MockRepository(); ClassWithThrowingCtor mockClass1 = (ClassWithThrowingCtor)mocks.StrictMock(typeof(ClassWithThrowingCtor), CallOptions.DontCallCtor); }
public void CallNonThrowingProtectedCtor() { ClassWithThrowingCtor mockClass1 = MockRepository .Mock <ClassWithThrowingCtor>(CallOptions.DontCallCtor); }