public void OverrideInternalMethod( TypeWithInternalMethod fake, Exception exception) { "establish" .x(() => fake = A.Fake<TypeWithInternalMethod>()); "when trying to override internal method on type" .x(() => exception = Record.Exception(() => A.CallTo(() => fake.InternalMethod()).Returns(17))); "it should throw an exception with a message complaining about accessibility" .x(() => exception.Should().BeAnExceptionOfType<FakeConfigurationException>() .And.Message.Should().Contain("not accessible to DynamicProxyGenAssembly2")); }
public static void OverrideInternalMethod( TypeWithInternalMethod fake, Exception exception) { "establish" .x(() => fake = A.Fake <TypeWithInternalMethod>()); "when trying to override internal method on type" .x(() => exception = Record.Exception(() => A.CallTo(() => fake.InternalMethod()).Returns(17))); "it should throw an exception with a message complaining about accessibility" .x(() => exception.Should().BeAnExceptionOfType <FakeConfigurationException>() .And.Message.Should().Contain("not accessible to DynamicProxyGenAssembly2")); }
public static void OverrideInternalMethod( TypeWithInternalMethod fake, Exception exception) { const string ExpectedMessage = @"The current proxy generator can not intercept the method FakeItEasy.Specs.TypeWithInternalMethod.InternalMethod() for the following reason: - Can not create proxy for method Int32 InternalMethod() because it or its declaring type is not accessible. Make it public, or internal and mark your assembly with [assembly: InternalsVisibleTo(""DynamicProxyGenAssembly2"")] attribute, because assembly FakeItEasy.Specs is not strong-named."; "Given a public type with an internal method not visible to DynamicProxyGenAssembly2" .See <TypeWithInternalMethod>(); "And I create a fake of the type" .x(() => fake = A.Fake <TypeWithInternalMethod>()); "When I override the internal method" .x(() => exception = Record.Exception(() => A.CallTo(() => fake.InternalMethod()).Returns(17))); "Then it throws an exception with a message containing a hint at using internals visible to attribute" .x(() => exception.Should().BeAnExceptionOfType <FakeConfigurationException>() .And.Message.Should().Contain(ExpectedMessage)); }