Ejemplo n.º 1
0
        public void CheckBadInPath()
        {
            string xml = String.Format(
                @"<?xml version='1.0'?>" +
                @"<Obfuscator>" +
                @"<Var name='InPath' value='{0}' />" +
                @"</Obfuscator>", BadPath);
            var exception = Assert.Throws <ObfuscarException>(() => { Obfuscator.CreateFromXml(xml); });

            Assert.AreEqual("Path specified by InPath variable must exist:Q:\\Does\\Not\\Exist", exception.Message);
        }
Ejemplo n.º 2
0
        public void CheckBadModuleFile()
        {
            string xml = String.Format(
                @"<?xml version='1.0'?>" +
                @"<Obfuscator>" +
                @"<Module file='{0}\ObfuscarTests.dll' />" +
                @"</Obfuscator>", BadPath);
            var exception = Assert.Throws <ObfuscarException>(() => { Obfuscator.CreateFromXml(xml); });

            Assert.Equal("Unable to find assembly:  Q:\\Does\\Not\\Exist\\ObfuscarTests.dll", exception.Message);
        }
Ejemplo n.º 3
0
        public void CheckGoodDependency()
        {
            string xml = String.Format(
                @"<?xml version='1.0'?>" +
                @"<Obfuscator>" +
                @"<Var name='InPath' value='{0}' />" +
                @"<Module file='$(InPath){1}AssemblyB.dll' />" +
                @"</Obfuscator>", TestHelper.InputPath, Path.DirectorySeparatorChar);

            Obfuscator obfuscator = Obfuscator.CreateFromXml(xml);
        }
Ejemplo n.º 4
0
        public void CheckMissingDependency()
        {
            string xml = String.Format(
                @"<?xml version='1.0'?>" +
                @"<Obfuscator>" +
                @"<Module file='{0}{1}AssemblyD.dll' />" +
                @"</Obfuscator>", TestHelper.InputPath, Path.DirectorySeparatorChar);

            // InPath defaults to '.', which doesn't contain AssemblyA
            File.Copy(Path.Combine(TestHelper.InputPath, @"..", "AssemblyD.dll"), Path.Combine(TestHelper.InputPath, "AssemblyD.dll"), true);
            var exception = Assert.Throws <ObfuscarException> (() => { Obfuscator.CreateFromXml(xml); });

            Assert.Equal("Unable to resolve dependency:  AssemblyC", exception.Message);
        }
Ejemplo n.º 5
0
        public void CheckDeletedDependency()
        {
            string xml = String.Format(
                @"<?xml version='1.0'?>" +
                @"<Obfuscator>" +
                @"<Var name='InPath' value='{0}' />" +
                @"<Module file='$(InPath){1}AssemblyB.dll' />" +
                @"</Obfuscator>", TestHelper.InputPath, Path.DirectorySeparatorChar);

            // explicitly delete AssemblyA
            File.Delete(Path.Combine(TestHelper.InputPath, "AssemblyA.dll"));
            var exception = Assert.Throws <ObfuscarException>(() => { Obfuscator.CreateFromXml(xml); });

            Assert.Equal("Unable to resolve dependency:  AssemblyA", exception.Message);
        }
Ejemplo n.º 6
0
        public void TestInclude()
        {
            string xml = String.Format(
                @"<?xml version='1.0'?>" +
                @"<Obfuscator>" +
                @"<Var name='InPath' value='{0}' />" +
                @"<Var name='OutPath' value='{1}' />" +
                @"<Var name='KeepPublicApi' value='false' />" +
                @"<Var name='HidePrivateApi' value='true' />" +
                @"<Include path='$(InPath){2}TestInclude.xml' />" +
                @"<Module file='$(InPath){2}AssemblyWithCustomAttr.dll'>" +
                @"<Include path='$(InPath){2}TestIncludeModule.xml' />" +
                @"</Module>" +
                @"</Obfuscator>", TestHelper.InputPath, TestHelper.OutputPath, Path.DirectorySeparatorChar);

            Obfuscator obfuscator = Obfuscator.CreateFromXml(xml);
        }
Ejemplo n.º 7
0
        public void CheckInclude()
        {
            string outputPath = TestHelper.OutputPath;
            string xml        = string.Format(
                @"<?xml version='1.0'?>" +
                @"<Obfuscator>" +
                @"  <Var name='InPath' value='{0}' />" +
                @"  <Var name='OutPath' value='{1}' />" +
                @"  <Include path='$(InPath){2}TestInclude.xml' />" +
                @"  <Module file='$(InPath){2}AssemblyWithProperties.dll' />" +
                @"</Obfuscator>", TestHelper.InputPath, outputPath, Path.DirectorySeparatorChar);

            File.Copy(Path.Combine(TestHelper.InputPath, @"..", "TestInclude.xml"),
                      Path.Combine(TestHelper.InputPath, "TestInclude.xml"), true);
            Obfuscator obfuscator = Obfuscator.CreateFromXml(xml);

            Assert.False(obfuscator.Project.Settings.KeepPublicApi);
        }
Ejemplo n.º 8
0
        public void CheckBadInPath()
        {
            Type t = Type.GetType("Mono.Runtime");

            if (t != null)
            {
                return;
            }

            string xml = string.Format(
                @"<?xml version='1.0'?>" +
                @"<Obfuscator>" +
                @"<Var name='InPath' value='{0}' />" +
                @"</Obfuscator>", BadPath);
            var exception = Assert.Throws <ObfuscarException>(() => { Obfuscator.CreateFromXml(xml); });

            Assert.Equal("Path specified by InPath variable must exist:Q:\\Does\\Not\\Exist", exception.Message);
        }