Ejemplo n.º 1
0
        public void CanStrictMockOnClassWithInternalMethod()
        {
            WithInternalMethod withInternalMethod = mocks.StrictMock <WithInternalMethod>();

            withInternalMethod.Foo();
            LastCall.Throw(new Exception("foo"));
            mocks.ReplayAll();
            try
            {
                withInternalMethod.Foo();
                Assert.False(true, "Should have thrown");
            }
            catch (Exception e)
            {
                Assert.Equal("foo", e.Message);
            }
        }
Ejemplo n.º 2
0
        public void CanStrictMockOnClassWithInternalMethod()
        {
            WithInternalMethod withInternalMethod = MockRepository.Partial <WithInternalMethod>();

            withInternalMethod.Expect(x => x.Foo())
            .Throws(new Exception("foo"));

            try
            {
                withInternalMethod.Foo();
                Assert.False(true, "Should have thrown");
            }
            catch (Exception e)
            {
                Assert.Equal("foo", e.Message);
            }
        }