Exemplo n.º 1
0
        public void TestSerializeRewriteCodeFolder()
        {
            var rc       = new RewriteCodeFolder(".", "*.cs");
            var text     = rc.SerializeMe();
            var newClass = RewriteAction.UnSerializeMe(text) as RewriteCodeFolder;

            Assert.IsNotNull(newClass);
            //File.WriteAllText("a.txt", text);
            //Process.Start("notepad.exe", "a.txt");
            Assert.AreEqual(rc.FolderName, newClass.FolderName);
        }
Exemplo n.º 2
0
        public void TestSerializeRewriteCodeFolderFormatter()
        {
            var rc = new RewriteCodeFolder(".", "*.cs");

            rc.Formatter.FormatterFirstLine = "System.Console.WriteLine('andrei ignat')";
            var text     = rc.SerializeMe();
            var newClass = RewriteAction.UnSerializeMe(text) as RewriteCodeFolder;

            Assert.IsNotNull(newClass);
            //File.WriteAllText("a.txt", text);
            //Process.Start("notepad.exe", "a.txt");
            rc.Formatter.FormatterFirstLine.ShouldBe(newClass.Formatter.FormatterFirstLine);
        }
        public void TestAOPFolder()
        {
            string folderName = @"ClassesForTesting";
            int    nr         = 0;
            var    rc         = new RewriteCodeFolder(folderName, "*.cs");
            var    fileText   = new Dictionary <string, string>();

            rc.StartProcessingFile += (object sender, string fileName) =>
            {
                nr++;
                FileInfo fi = new FileInfo(fileName);
                fi.IsReadOnly      = false;
                fileText[fileName] = File.ReadAllText(fileName);
            };
            rc.EndProcessingFile += (object sender, string fileName) =>
            {
                File.WriteAllText(fileName, fileText[fileName]);
            };
            rc.Rewrite();
            Assert.IsTrue(nr > 0, "should process at least one file");
        }