Beispiel #1
0
        public void LeakTest(string filename, int expectedLeaks)
        {
            using (var copy = new InstrumentedCopy(filename))
            {
                AssemblyLauncher.Launch(copy.FileName);
            }

            Assert.AreEqual(expectedLeaks, DisposerRegistry.LeakedObjects.Count);
        }
 public void ShouldDetectAlreadyInstrumentedAssemblies()
 {
     using (InstrumentedCopy copy = new InstrumentedCopy("NonLeaking.exe"))
     {
         Assert.Throws(typeof(InvalidOperationException), () =>
         {
             new Instrumenter(Path.GetDirectoryName(copy.FileName))
                 .Instrument(copy.FileName, copy.FileName);
         });
     }
 }
Beispiel #3
0
        public void CrossBoundaryLeakTest()
        {
            // This actually works, but writing test for it is a little
            // more involved. The test runner would always resolve the
            // un-instrumented LeakerLib. We'll need to use a separate
            // AppDomain
            Assert.Ignore("Test not implemented");

            using (var lib = new InstrumentedCopy("LeakerLib.dll"))
            using (var exe = new InstrumentedCopy("CrossBoundaryLeaker.exe",
                lib.DirectoryName))
            {
                AssemblyLauncher.Launch(exe.FileName);
            }

            Assert.AreEqual(1, DisposerRegistry.LeakedObjects.Count);
        }