コード例 #1
0
 public void CustomFactoryRegistersCorrectly()
 {
     CustomFactory.Register();
     Assert.That(CustomFactory.Default, Is.Not.Null);
     ProxyFooPolicies.ClearProxyModule();
     Assert.That(CustomFactory.IsClear);
 }
コード例 #2
0
        public void CustomClearActionIsCalled()
        {
            bool clearCalled = false;

            ProxyFooPolicies.ClearProxyModule = () => { clearCalled = true; };
            ProxyFooPolicies.ClearProxyModule();
            Assert.That(clearCalled);
            ProxyFooPolicies.ClearProxyModule = OnDemandProxyModule.Clear;
        }
コード例 #3
0
        public static ProxyModule GetProxyModule()
        {
            if (_instance != null)
            {
                return(_instance);
            }

            _instance = ProxyFooPolicies.CreateProxyModule();
            return(_instance);
        }
コード例 #4
0
        /// <summary>
        /// The intent of this benchmark is to measure the raw creation and build time of a proxy type.
        /// </summary>
        public static int RawDuckProxyTypeCreation(object[] testObjects)
        {
            int sum = 0;

            for (int i = 0; i < _testSize; ++i)
            {
                var duck = (IGetAnswer)DuckFactory.Default.MakeDuckProxyForInterfaces(testObjects[i], typeof(IGetAnswer));
                sum += duck.GetAnswer();
                ProxyFooPolicies.ClearProxyModule();
            }
            return(sum);
        }
コード例 #5
0
        public void CustomFactoryIsStoredPerProxyModule()
        {
            CustomFactory.Register();
            Assert.That(CustomFactory.Default, Is.Not.Null);
            var proxyModule   = new ProxyModule();
            var customFactory = CustomFactory.FromProxyModule(proxyModule);

            Assert.That(customFactory, Is.Not.Null);
            Assert.That(customFactory, Is.Not.SameAs(CustomFactory.Default));
            ProxyFooPolicies.ClearProxyModule();
            Assert.That(CustomFactory.IsClear);
            Assert.That(CustomFactory.FromProxyModule(proxyModule), Is.Not.Null);
        }
コード例 #6
0
        public void GetProxyModuleCreatesProxyModuleFromFactory()
        {
            OnDemandProxyModule.Clear();
            bool called = false;

            ProxyFooPolicies.ProxyModuleFactory = () =>
            {
                called = true;
                return(ProxyFooPolicies.DefaultProxyModuleFactory());
            };
            Assert.That(OnDemandProxyModule.GetProxyModule(), Is.Not.Null);
            Assert.That(called);
            ProxyFooPolicies.ProxyModuleFactory = ProxyFooPolicies.DefaultProxyModuleFactory;
        }
コード例 #7
0
        public virtual void TearDown()
        {
#if FEATURE_PEVERIFY
            if (!ProxyModule.Default.IsAssemblyCreated)
            {
                return;
            }
            ProxyModule.Default.Save();
            var assemblyPath = ProxyModule.Default.AssemblyName + ".dll";
#if NUNIT3
            if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed)
#else
            if (TestContext.CurrentContext.Result.Status == TestStatus.Passed)
#endif
            {
                Assert.That(PeVerifyAssembly(".", assemblyPath), Is.EqualTo(0));
            }
#endif
            ProxyFooPolicies.ProxyModuleFactory = ProxyFooPolicies.DefaultProxyModuleFactory;
            ProxyFooPolicies.ClearProxyModule();
        }
コード例 #8
0
        public virtual void SetUp()
        {
            string assemblyName = "ZPFD." + TestContext.CurrentContext.Test.FullName.Replace("ProxyFoo.Tests.", "");

            foreach (var c in Path.GetInvalidFileNameChars())
            {
                assemblyName = assemblyName.Replace(c, '_');
            }
            var assemblyPath = assemblyName + ".dll";

#if FEATURE_PEVERIFY
            if (File.Exists(assemblyPath))
            {
                File.Delete(assemblyPath);
            }
            ProxyFooPolicies.ProxyModuleFactory = () => new ProxyModule(assemblyName, AssemblyBuilderAccess.RunAndSave);
#else
            ProxyFooPolicies.ProxyModuleFactory = () => new ProxyModule(assemblyName, AssemblyBuilderAccess.Run);
#endif
            ProxyFooPolicies.ClearProxyModule();
        }
コード例 #9
0
 public static void Register()
 {
     _accessor = ProxyFooPolicies.RegisterFactory(Clear);
 }
コード例 #10
0
 public void TearDown()
 {
     ProxyFooPolicies.ProxyModuleFactory = ProxyFooPolicies.DefaultProxyModuleFactory;
     ProxyFooPolicies.ClearProxyModule();
 }
コード例 #11
0
 public void SetUp()
 {
     _createCalled = false;
     ProxyFooPolicies.ProxyModuleFactory = ProxyFooPolicies.DefaultProxyModuleFactory;
     ProxyFooPolicies.ClearProxyModule();
 }
コード例 #12
0
 static void Reset()
 {
     ProxyFooPolicies.ClearProxyModule();
     GC.Collect();
     GC.WaitForPendingFinalizers();
 }