コード例 #1
0
ファイル: LoggingTestCase.cs プロジェクト: belav/Core
        public void ExcludedNonVirtualMethods()
        {
            // Arrange
            CollectingLogger logger    = new CollectingLogger();
            ProxyGenerator   generator = new ProxyGenerator {
                Logger = logger
            };

            // Act
            generator.CreateClassProxy <NonVirtualMethodClass>();

            // Assert
            Assert.True(
                logger.RecordedMessage(
                    LoggerLevel.Debug,
                    "Excluded non-overridable method ClassMethod on "
                    + "Castle.DynamicProxy.Tests.LoggingTestCase+NonVirtualMethodClass because it cannot be intercepted."
                    )
                );
            Assert.True(
                logger.RecordedMessage(
                    LoggerLevel.Debug,
                    "Excluded non-overridable method InterfaceMethod on "
                    + "Castle.DynamicProxy.Tests.LoggingTestCase+NonVirtualMethodClass because it cannot be intercepted."
                    )
                );
        }
コード例 #2
0
ファイル: LoggingTestCase.cs プロジェクト: belav/Core
        public void ProxyGenerationOptionsEqualsAndGetHashCodeNotOverriden()
        {
            // Arrange
            CollectingLogger logger    = new CollectingLogger();
            ProxyGenerator   generator = new ProxyGenerator {
                Logger = logger
            };

            // Act
            ProxyGenerationOptions options = new ProxyGenerationOptions {
                Hook = new EmptyHook()
            };

            generator.CreateClassProxy(typeof(EmptyClass), options);

            // Assert
            Assert.True(
                logger.RecordedMessage(
                    LoggerLevel.Warn,
                    "The IProxyGenerationHook type "
                    + "Castle.DynamicProxy.Tests.LoggingTestCase+EmptyHook does not override both Equals and GetHashCode. "
                    + "If these are not correctly overridden caching will fail to work causing performance problems."
                    )
                );
        }
コード例 #3
0
ファイル: LoggingTestCase.cs プロジェクト: leloulight/Core
		public void CacheMiss()
		{
			// Arrange
			CollectingLogger logger = new CollectingLogger();
			ProxyGenerator generator = new ProxyGenerator { Logger = logger };

			// Act
			generator.CreateClassProxy<EmptyClass>();

			// Assert
			Assert.That(logger.RecordedMessage(LoggerLevel.Debug, "No cached proxy type was found for target type " +
				"CastleTests.DynamicProxy.Tests.Classes.EmptyClass."));
		}
コード例 #4
0
		public void CacheMiss()
		{
			// Arrange
			CollectingLogger logger = new CollectingLogger();
			ProxyGenerator 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 " +
				"CastleTests.DynamicProxy.Tests.Classes.EmptyClass."));
		}
コード例 #5
0
ファイル: LoggingTestCase.cs プロジェクト: leloulight/Core
		public void CacheHitInterfaceProxy()
		{
			// Arrange
			CollectingLogger logger = new CollectingLogger();
			ProxyGenerator generator = new ProxyGenerator { Logger = logger };

			// Act
			generator.CreateInterfaceProxyWithoutTarget<IEmptyInterface>();
			generator.CreateInterfaceProxyWithoutTarget<IEmptyInterface>();

			// Assert
			Assert.That(logger.RecordedMessage(LoggerLevel.Debug, "Found cached proxy type Castle.Proxies.IEmptyInterfaceProxy " +
				"for target type Castle.DynamicProxy.Tests.LoggingTestCase+IEmptyInterface."));
		}
コード例 #6
0
		public void CacheHitInterfaceProxy()
		{
			// Arrange
			CollectingLogger logger = new CollectingLogger();
			ProxyGenerator generator = new ProxyGenerator { Logger = logger };

			// Act
			generator.CreateInterfaceProxyWithoutTarget<IEmptyInterface>();
			generator.CreateInterfaceProxyWithoutTarget<IEmptyInterface>();

			// Assert
			Assert.True(logger.RecordedMessage(LoggerLevel.Debug, "Found cached proxy type Castle.Proxies.IEmptyInterfaceProxy " +
				"for target type Castle.DynamicProxy.Tests.LoggingTestCase+IEmptyInterface."));
		}
コード例 #7
0
ファイル: LoggingTestCase.cs プロジェクト: n2cms/Castle.Core
		public void CacheHitClassProxy()
		{
			// Arrange
			CollectingLogger logger = new CollectingLogger();
			ProxyGenerator generator = new ProxyGenerator { Logger = logger };

			// Act
			generator.CreateClassProxy<EmptyClass>();
			generator.CreateClassProxy<EmptyClass>();

			// Assert
			Assert.That(logger.RecordedMessage(LoggerLevel.Debug, "Found cached proxy type Castle.Proxies.EmptyClassProxy " +
				"for target type Castle.DynamicProxy.Tests.LoggingTestCase+EmptyClass."));
		}
コード例 #8
0
ファイル: LoggingTestCase.cs プロジェクト: dbones/Castle.Core
        public void CacheHitClassProxy()
        {
            // Arrange
            CollectingLogger logger    = new CollectingLogger();
            ProxyGenerator   generator = new ProxyGenerator {
                Logger = logger
            };

            // Act
            generator.CreateClassProxy <EmptyClass>();
            generator.CreateClassProxy <EmptyClass>();

            // Assert
            Assert.That(logger.RecordedMessage(LoggerLevel.Debug, "Found cached proxy type Castle.Proxies.EmptyClassProxy " +
                                               "for target type CastleTests.DynamicProxy.Tests.Classes.EmptyClass."));
        }
コード例 #9
0
        public void FoundExplicitlyImplementedInterfaceMethods()
        {
            // Arrange
            CollectingLogger logger    = new CollectingLogger();
            ProxyGenerator   generator = new ProxyGenerator {
                Logger = logger
            };

            // Act
            generator.CreateClassProxy <ClassWithInterfaceMethodExplicitlyImplemented>();

            // Assert
            Assert.That(logger.RecordedMessage(LoggerLevel.Debug, "Excluded explicitly implemented interface method " +
                                               "Castle.DynamicProxy.Tests.LoggingTestCase.ISingleMethodInterface.InterfaceMethod on type " +
                                               "Castle.DynamicProxy.Tests.LoggingTestCase+ClassWithInterfaceMethodExplicitlyImplemented " +
                                               "because it cannot be intercepted."));
        }
コード例 #10
0
ファイル: LoggingTestCase.cs プロジェクト: leloulight/Core
		public void ExcludedNonVirtualMethods()
		{
			// Arrange
			CollectingLogger logger = new CollectingLogger();
			ProxyGenerator generator = new ProxyGenerator { Logger = logger };

			// Act
			generator.CreateClassProxy<NonVirtualMethodClass>();

			// Assert
			Assert.That(logger.RecordedMessage(LoggerLevel.Debug, "Excluded non-virtual method ClassMethod on " +
				"Castle.DynamicProxy.Tests.LoggingTestCase+NonVirtualMethodClass because it cannot be intercepted."));
			Assert.That(logger.RecordedMessage(LoggerLevel.Debug, "Excluded sealed method InterfaceMethod on " +
				"Castle.DynamicProxy.Tests.LoggingTestCase+NonVirtualMethodClass because it cannot be intercepted."));
		}
コード例 #11
0
ファイル: LoggingTestCase.cs プロジェクト: leloulight/Core
		public void ProxyGenerationOptionsEqualsAndGetHashCodeNotOverriden()
		{
			// Arrange
			CollectingLogger logger = new CollectingLogger();
			ProxyGenerator generator = new ProxyGenerator { Logger = logger };

			// Act
			ProxyGenerationOptions options = new ProxyGenerationOptions {
				Hook = new EmptyHook()
			};
			generator.CreateClassProxy(typeof(EmptyClass), options);

			// Assert
			Assert.That(logger.RecordedMessage(LoggerLevel.Warn, "The IProxyGenerationHook type " +
				"Castle.DynamicProxy.Tests.LoggingTestCase+EmptyHook does not override both Equals and GetHashCode. " +
				"If these are not correctly overridden caching will fail to work causing performance problems."));
		}
コード例 #12
0
		public void FoundExplicitlyImplementedInterfaceMethods()
		{
			// Arrange
			CollectingLogger logger = new CollectingLogger();
			ProxyGenerator generator = new ProxyGenerator { Logger = logger };

			// Act
			generator.CreateClassProxy<ClassWithInterfaceMethodExplicitlyImplemented>();

			// Assert
			Assert.That(logger.RecordedMessage(LoggerLevel.Debug, "Excluded explicitly implemented interface method " +
				"Castle.DynamicProxy.Tests.LoggingTestCase.ISingleMethodInterface.InterfaceMethod on type " +
				"Castle.DynamicProxy.Tests.LoggingTestCase+ClassWithInterfaceMethodExplicitlyImplemented " +
				"because it cannot be intercepted."));
		}