public void ExcludedNonVirtualMethods() { // Arrange var logger = new CollectingLogger(); var generator = new ProxyGenerator { Logger = logger }; // Act generator.CreateClassProxy <NonVirtualMethodClass>(); // Assert Assert.True(logger.RecordedMessage(LoggerLevel.Debug, "Excluded non-virtual method ClassMethod on " + "Castle.Core.Test.Main.LoggingTestCase+NonVirtualMethodClass because it cannot be intercepted.")); Assert.True(logger.RecordedMessage(LoggerLevel.Debug, "Excluded sealed method InterfaceMethod on " + "Castle.Core.Test.Main.LoggingTestCase+NonVirtualMethodClass because it cannot be intercepted.")); }
public void CacheMiss() { // Arrange var logger = new CollectingLogger(); var generator = new ProxyGenerator { Logger = logger }; // Act generator.CreateClassProxy <EmptyClass>(); // Assert Assert.True(logger.RecordedMessage(LoggerLevel.Debug, "No cached proxy type was found for target type " + "Castle.Core.Test.DynamicProxy.Classes.EmptyClass.")); }
public void CacheHitInterfaceProxy() { // Arrange var logger = new CollectingLogger(); var generator = new ProxyGenerator { Logger = logger }; // Act generator.CreateInterfaceProxyWithoutTarget <IEmptyInterface>(); generator.CreateInterfaceProxyWithoutTarget <IEmptyInterface>(); Console.WriteLine(logger.Length); Console.WriteLine(logger[0]); Console.WriteLine(logger[1]); // Assert Assert.True(logger.RecordedMessage(LoggerLevel.Debug, "Found cached proxy type Castle.Proxies.IEmptyInterfaceProxy " + "for target type Castle.Core.Test.Main.LoggingTestCase+IEmptyInterface.")); }
public void ProxyGenerationOptionsEqualsAndGetHashCodeNotOverriden() { // Arrange var logger = new CollectingLogger(); var generator = new ProxyGenerator { Logger = logger }; // Act var options = new ProxyGenerationOptions { Hook = new EmptyHook() }; generator.CreateClassProxy(typeof(EmptyClass), options); // Assert Assert.True(logger.RecordedMessage(LoggerLevel.Warn, "The IProxyGenerationHook type " + "Castle.Core.Test.Main.LoggingTestCase+EmptyHook does not override both Equals and GetHashCode. " + "If these are not correctly overridden caching will fail to work causing performance problems.")); }