Beispiel #1
0
        public void EchoNoLeakedUserHandles()
        {
            var process = Process.GetCurrentProcess();

            var count       = GetUserObjectCount(process);
            var interpreter = CreateInterpreter();

            try {
                var apl    = new AplGroup002.ResourceTests(interpreter);
                var result = apl.Echo(15);
            } finally {
                Assert.IsTrue(interpreter.Unload());
                Assert.AreEqual(count, GetUserObjectCount(process));
            }
        }
Beispiel #2
0
        private void TestReload(TestType testType, int count)
        {
            var process = Process.GetCurrentProcess();
            var initialGdiHandleCount  = GetGdiObjectCount(process);
            var initialUserHandleCount = GetUserObjectCount(process);
            int firstGdiHandleCount    = 0;
            int firstUserHandleCount   = 0;

            for (int i = 0; i < count; i++)
            {
                var interpreter = CreateInterpreter(testType != TestType.Gui);

                try {
                    var apl = new AplGroup002.ResourceTests(interpreter);
                    if (testType == TestType.Echo)
                    {
                        var result = apl.Echo(i);
                        Assert.AreEqual(i, result);
                    }
                    else if (testType == TestType.Gui)
                    {
                        var name   = $"form{i}";
                        var result = apl.CreateForm(name);
                        Assert.IsTrue(result);
                        //result = apl.Expunge(name);
                        //Assert.IsTrue(result);
                    }
                } finally {
                    Assert.IsTrue(interpreter.Unload());
                }
                if (i == 0)
                {
                    firstGdiHandleCount  = GetGdiObjectCount(process);
                    firstUserHandleCount = GetUserObjectCount(process);
                }
            }
            var finalGdiHandleCount  = GetGdiObjectCount(process);
            var finalUserHandleCount = GetUserObjectCount(process);

            Assert.AreEqual(finalGdiHandleCount, firstGdiHandleCount);
            Assert.AreEqual(finalUserHandleCount, firstUserHandleCount);
        }