Пример #1
0
        internal void AssertResourceTest(string resourceName, TestKind kind, IAssemblyDiffVisitor visitor)
        {
            using (var tbc = ReadResource(resourceName, "cs", kind))
            {
                var cecilifierTestsFolder = Path.Combine(Path.GetTempPath(), "CecilifierTests");

                var cecilifiedAssemblyPath       = Path.Combine(cecilifierTestsFolder, resourceName + ".dll");
                var resourceCompiledAssemblyPath = CompilationServices.CompileDLL(
                    Path.Combine(Path.GetDirectoryName(cecilifiedAssemblyPath), Path.GetFileNameWithoutExtension(cecilifiedAssemblyPath) + "_expected"),
                    ReadToEnd(tbc),
                    Utils.GetTrustedAssembliesPath().ToArray());

                Console.WriteLine();
                Console.WriteLine("Compiled from res        : {0}", resourceCompiledAssemblyPath);
                Console.WriteLine("Generated from Cecilifier: {0}", cecilifiedAssemblyPath);

                AssertResourceTest(cecilifiedAssemblyPath, resourceCompiledAssemblyPath, tbc, visitor);
            }
        }
Пример #2
0
 private void AssertResourceTest(string actualAssemblyPath, string expectedAssemblyPath, Stream tbc, IAssemblyDiffVisitor visitor)
 {
     CecilifyAndExecute(tbc, actualAssemblyPath);
     CompareAssemblies(expectedAssemblyPath, actualAssemblyPath, visitor);
 }
Пример #3
0
        private void CompareAssemblies(string expectedAssemblyPath, string actualAssemblyPath, IAssemblyDiffVisitor visitor)
        {
            var comparer = new AssemblyComparer(expectedAssemblyPath, actualAssemblyPath);

            if (!comparer.Compare(visitor))
            {
                Assert.Fail("Expected and generated assemblies differs:\r\n\tExpected:  {0}\r\n\tGenerated: {1}\r\n\r\n{2}\r\n\r\nCecilified Code:\r\n{3}", comparer.First, comparer.Second, visitor.Reason, cecilifiedCode);
            }
        }