Ejemplo n.º 1
0
        public void TestCollectArgsFromFile()
        {
            using (var f = DisposingFile.CreateTempFileWithTail(".nd")) {
                using (var sw = new StreamWriter(f.FileName)) {
                    sw.WriteLine(@"
a b                        // 1 2
c d { e1 e2                // 3 4 5 6 7 // line starting { is split!
    f1 f2 f3               // 8
    g {                    // 9
      h1 h2                // 10
      i1 i2 i3             // 11
    }                      // 12
    j { k1 k2 } l m n o {  // 13
      p } } q              // 14
r s");                     // 15 16
                }
                string[] result = Option.CollectArgsFromFile(f.FileName);
                Assert.AreEqual(16, result.Length);
                Assert.IsTrue(result.Contains("e1"));
                Assert.IsTrue(result.Contains("    f1 f2 f3               // 8"));
                Assert.IsTrue(result.Contains("      i1 i2 i3             // 11"));
                Assert.IsTrue(result.Contains("      p } } q              // 14"));
                Assert.IsTrue(result.Contains("r"));
                Assert.IsTrue(result.Contains("s"));
            }
        }
Ejemplo n.º 2
0
        public void TestDipWithProxies()
        {
            var          gc    = new GlobalContext();
            WorkingGraph graph = gc.CurrentGraph;

            using (var f = DisposingFile.CreateTempFileWithTail(".dip")) {
                using (TextWriter tw = new StreamWriter(f.FileName)) {
                    tw.Write(@"$ NKK(Name:Key1:Key2)
                        NKK:a:keyA1:?     => ;1;0;0;src.abc|1            => NKK:?:keyA1:?
                        NKK:?:keyA1:?     => ;2;1;0;src.abc|3;example123 => NKK:a:keyA2:?
                        NKK:a:keyA2:?     => ;3;0;0;src.abc|5            => NKK:a:keyA1:KEYa1
                        NKK:?:?:KEYa2     => ;4;0;0;src.abc|7            => NKK:a:keyA2:KEYa2
                        NKK:?:keyA2:KEYa2 => ;5;1;0;src.abc|9            => NKK:b::KEYb
                        NKK:?:?:KEYb      => ;6;0;0;src.abc|11           => NKK:?:?:KEYa1
                        NKK:?::KEYb       => ;7;0;0;src.abc|13           => NKK:?:keyA2:?");
                }

                IEnumerable <Dependency> dependencies =
                    new DipReaderFactory().CreateReader(f.FileName, false).ReadDependencies(gc.CurrentGraph, 0, ignoreCase: false);
                Assert.IsNotNull(dependencies);
                Item[] items = dependencies.SelectMany(d => new[] { d.UsingItem, d.UsedItem }).Distinct().ToArray();
                Assert.AreEqual(3, items.Length);
                Assert.IsTrue(items.Contains(graph.CreateItem(ItemType.Find("NKK"), "a", "keyA1", "KEYa1")));
                Assert.IsTrue(items.Contains(graph.CreateItem(ItemType.Find("NKK"), "a", "keyA2", "KEYa2")));
                Assert.IsTrue(items.Contains(graph.CreateItem(ItemType.Find("NKK"), "b", "", "KEYb")));
            }
        }
Ejemplo n.º 3
0
        public void TestIncludeExclude()
        {
            using (var f = DisposingFile.CreateTempFileWithTail("Mark.dip")) {
                Assert.AreEqual(0,
                                Program.Main(new[] {
                    Program.DoResetOption.Opt,
                    Program.TransformTestDataOption.Opt, ".", typeof(MarkDeps).Name, "{",
                    MarkDeps.DependencyMatchOptions.DependencyMatchOption.Opt, "'M--",
                    MarkDeps.DependencyMatchOptions.NoMatchOption.Opt, "->B",

                    MarkDeps.MarkLeftItemOption.Opt, "LeftMatch",
                    MarkDeps.MarkRightItemOption.Opt, "RightMatch",
                    MarkDeps.MarkDependencyItemOption.Opt, "DepMatch",
                    "}",

                    Program.WriteDipOption.Opt, f.FileName
                }));

                using (var sw = new StreamReader(f.FileName)) {
                    string o = sw.ReadToEnd();

                    Assert.IsTrue(Regex.IsMatch(o, "SIMPLE:A[^:=]*RightMatch"));
                    Assert.IsFalse(Regex.IsMatch(o, "SIMPLE:B[^:=]*RightMatch"));
                    Assert.IsTrue(Regex.IsMatch(o, "SIMPLE:C[^:=]*RightMatch"));

                    Assert.IsTrue(Regex.IsMatch(o, "SIMPLE:A[^:=]*LeftMatch"));
                    Assert.IsTrue(Regex.IsMatch(o, "SIMPLE:B[^:=]*LeftMatch"));
                    Assert.IsFalse(Regex.IsMatch(o, "SIMPLE:C[^:=]*LeftMatch"));
                }
            }
        }
Ejemplo n.º 4
0
        public void ExitException()
        {
            using (var d = DisposingFile.CreateTempFileWithTail(".dll.dep")) {
                using (TextWriter tw = new StreamWriter(d.FileName)) {
                    tw.Write(@"$ DOTNETITEM ---> DOTNETITEM

                    // Bad - contains --->
                    =---> :=    
                       : ---> blabla
                    =:

                    // Bad - contains --->
                    --->> :=    
                       ** ---> blabla
                    =:
                ");
                }
                Assert.AreEqual(Program.EXCEPTION_RESULT, Program.Main(CreateCheckDepsArgs(d)));
            }
            using (var d = DisposingFile.CreateTempFileWithTail(".dll.dep")) {
                using (TextWriter tw = new StreamWriter(d.FileName)) {
                    tw.Write(@"$ DOTNETITEM ---> DOTNETITEM

                    --> :=    
                       ** ---> blabla
                    =:
                ");
                }
                Assert.AreEqual(Program.EXCEPTION_RESULT, Program.Main(CreateCheckDepsArgs(d)));
            }
        }
Ejemplo n.º 5
0
        public void NestedMacroTest1()
        {
            using (var d = DisposingFile.CreateTempFileWithTail(".dll.dep")) {
                using (TextWriter tw = new StreamWriter(d.FileName)) {
                    tw.Write(@"
                    $ DOTNETITEM ---> DOTNETITEM

                    ** ---> :ExcludeFromCodeCoverageAttribute
                  
                    _B.** ---> _B.**
                    _B.** ---> System.**
                    _B.dir1.dir2:SomeClass ---? -:NamespacelessTestClassForNDepCheck::I
                    -:* ---? System:*

                    $ DOTNETASSEMBLY ---> DOTNETASSEMBLY
                    * ---> *");
                }
                Assert.AreEqual(Program.OK_RESULT,
                                Program.Main(
                                    new[] {
                    Program.DoDefineOption.Opt, "_A", "NDepCheck.TestAssembly", Program.DoDefineOption.Opt,
                    "_B", "_A"
                }.Concat(CreateCheckDepsArgs(d)).ToArray()));
            }
        }
Ejemplo n.º 6
0
        public void TestMarkFromTo()
        {
            using (var f = DisposingFile.CreateTempFileWithTail("Mark.dip")) {
                Assert.AreEqual(0,
                                Program.Main(new[] {
                    Program.DoResetOption.Opt,
                    Program.TransformTestDataOption.Opt, ".", typeof(MarkDeps).Name, "{",
                    MarkDeps.DependencyMatchOptions.DependencyMatchOption.Opt, "'M--->'N",
                    MarkDeps.DependencyMatchOptions.DependencyMatchOption.Opt, "A--->A",

                    MarkDeps.MarkLeftItemOption.Opt, "LeftMatch",
                    MarkDeps.MarkRightItemOption.Opt, "RightMatch",
                    MarkDeps.MarkDependencyItemOption.Opt, "DepMatch",

                    MarkDeps.UnmarkLeftItemOption.Opt, "N",         // does nothing
                    MarkDeps.UnmarkRightItemOption.Opt, "M",        // removes M from A because of match of 2nd pattern
                    "}",

                    Program.WriteDipOption.Opt, f.FileName
                }));

                using (var sw = new StreamReader(f.FileName)) {
                    string o = sw.ReadToEnd();

                    Assert.IsTrue(o.Contains("SIMPLE:A'LeftMatch+RightMatch "));
                    Assert.IsTrue(o.Contains("SIMPLE:B'M "));
                    Assert.IsTrue(o.Contains("SIMPLE:C'N+RightMatch"));
                    Assert.IsTrue(o.Contains("=> 'DepMatch"));
                }
            }
        }
Ejemplo n.º 7
0
        public void ExitOkAspects()
        {
            using (var d = DisposingFile.CreateTempFileWithTail(".dll.dep")) {
                using (TextWriter tw = new StreamWriter(d.FileName)) {
                    tw.Write(@"
                    $ DOTNETITEM ---> DOTNETITEM
                  
                    ::* ---> ::mscorlib

                    ** ---> **

                    // Schlägt fehlt, weil eine SpecialMethod auch auf YetAnotherMethod zugreift!
                    **::*SpecialMethod* ---> : {
                        ---> System:*
                        ---> **::*SpecialMethod*
                        ---> **::*ExtraordinaryMethod*
                    }

                    $ DOTNETASSEMBLY ---> DOTNETASSEMBLY
                    * ---> *
                    ");
                }
                Assert.AreEqual(Program.OK_RESULT, Program.Main(CreateCheckDepsArgs(d)));
            }
        }
Ejemplo n.º 8
0
 private static string[] CreateCheckDepsArgs(DisposingFile d)
 {
     return(new[] {
         TestAssemblyPath,
         Program.ConfigureOption.Opt, typeof(CheckDeps).Name, "{", CheckDeps.DefaultRuleFileOption + "=" + d.FileName, "}",
         Program.TransformOption.Opt, typeof(CheckDeps).Name,
         Program.WriteDipOption.Opt, "yyy",
     });
 }
Ejemplo n.º 9
0
 public void ExitNoRuleGroupsFoundForEmptyDepFile()
 {
     using (var d = DisposingFile.CreateTempFileWithTail(".dll.dep")) {
         using (TextWriter tw = new StreamWriter(d.FileName)) {
             tw.Write("");
         }
         Assert.AreEqual(Program.NO_RULE_GROUPS_FOUND, Program.Main(CreateCheckDepsArgs(d)));
     }
 }
Ejemplo n.º 10
0
 public void TestWriteTestDataOption()
 {
     using (var d = DisposingFile.CreateTempFileWithTail(".gif")) {
         // The usage typeof(...).FullName forces copying of assembly to bin directory.
         Assert.AreEqual(0,
                         Program.Main(new[] {
             TestAssemblyPath, Program.WriteTestDataOption.Opt, "NDepCheck.TestRenderer.dll",
             typeof(TestRendererForLoadFromAssembly).Name, d.FileName
         }));
     }
 }
Ejemplo n.º 11
0
 public void TestWriteTestDataOptionWithModulesAndInterfacesRenderer()
 {
     using (var d = DisposingFile.CreateTempFileWithTail(".gif")) {
         Assert.AreEqual(0,
                         Program.Main(new[] {
             TestAssemblyPath, Program.WriteTestDataOption.Opt, ".",
             typeof(ModulesAndInterfacesRenderer).Name,
             $"{{ {GraphicsRenderer.WidthOption} 1500 {GraphicsRenderer.HeightOption} 1000 {GraphicsRenderer.TitleOption} TestGOption {ModulesAndInterfacesRenderer.InterfaceSelectorOption} MI }}",
             d.FileName
         }));
     }
 }
Ejemplo n.º 12
0
        public void ExitFileNotFound()
        {
            using (var d = DisposingFile.CreateTempFileWithTail(".dll.dep")) {
                using (TextWriter tw = new StreamWriter(d.FileName)) {
                    tw.Write(@"$ DOTNETITEM ---> DOTNETITEM

                    : ---> blabla
                ");
                }
                Assert.AreEqual(Program.FILE_NOT_FOUND_RESULT,
                                Program.Main(CreateCheckDepsArgs(d).Concat(new[] { "nonexistingfile.dll" }).ToArray()));
            }
        }
Ejemplo n.º 13
0
        public void WriteAndReadDotNetDependencies()
        {
            using (DisposingFile dipFile = DisposingFile.CreateTempFileWithTail(".dip")) {
                int result =
                    Program.Main(new[] {
                    MainTests.TestAssemblyPath, Program.WriteDipOption.Opt, dipFile.FileName,
                    Program.DoResetOption.Opt, dipFile.FileName, Program.CountDependenciesOption.Opt
                });
                Assert.AreEqual(Program.OK_RESULT, result);

                Console.WriteLine(dipFile.FileName);
            }
        }
Ejemplo n.º 14
0
        public void ExitDependenciesNotOk()
        {
            using (var d = DisposingFile.CreateTempFileWithTail(".dll.dep")) {
                // The rules are not enough for the test assembly - we expect return result 3
                using (TextWriter tw = new StreamWriter(d.FileName)) {
                    tw.Write(@"
                   $ DOTNETITEM ---> DOTNETITEM
                  
                   ** ---> blabla
                ");
                }

                Assert.AreEqual(Program.DEPENDENCIES_NOT_OK, Program.Main(CreateCheckDepsArgs(d)));
            }
        }
Ejemplo n.º 15
0
        public void ExitOk()
        {
            using (var d = DisposingFile.CreateTempFileWithTail(".dll.dep")) {
                using (TextWriter tw = new StreamWriter(d.FileName)) {
                    tw.Write(@"
                    $ DOTNETITEM ---> DOTNETITEM

                    ** ---> :ExcludeFromCodeCoverageAttribute

                    NDepCheck.TestAssembly.** ---> NDepCheck.TestAssembly.**
                    NDepCheck.TestAssembly.**::NDepCheck.TestAssembly ---> System.**::mscorlib
                    NDepCheck.TestAssembly.dir1.dir2:SomeClass ---? -:NamespacelessTestClassForNDepCheck::I
                    -:* ---? System:*
                    NDepCheck.TestAssembly.** ---> NDepCheck.TestAssembly.**

                    $ DOTNETASSEMBLY ---> DOTNETASSEMBLY
                    * ---> *
                ");
                }
                Assert.AreEqual(Program.OK_RESULT, Program.Main(CreateCheckDepsArgs(d)));
            }
        }
Ejemplo n.º 16
0
        public void TestBackProjectSmallCycle()
        {
            ItemType     generic2 = ItemType.Generic(2, ignoreCase: false);
            var          gc       = new GlobalContext();
            WorkingGraph graph    = gc.CurrentGraph;

            Item a1 = graph.CreateItem(generic2, "a:1");
            Item b1 = graph.CreateItem(generic2, "b:1");
            Item a2 = graph.CreateItem(generic2, "a:2");
            Item b2 = graph.CreateItem(generic2, "b:2");
            Item b3 = graph.CreateItem(generic2, "b:3");

            var deps = new[] {
                Dep(graph, a1, b1), Dep(graph, b1, a2), Dep(graph, b2, a2), Dep(graph, a1, b3)
            };

            List <Dependency> backProjectedDeps = ProjectMarkCyclesAndBackProject(deps, gc);

            Assert.IsTrue(Find(backProjectedDeps, a1, b1).MarkersContain("C0"));
            Assert.IsTrue(Find(backProjectedDeps, a1, b3).MarkersContain("C0"));
            Assert.IsTrue(Find(backProjectedDeps, b1, a2).MarkersContain("C0"));
            Assert.IsTrue(Find(backProjectedDeps, b2, a2).MarkersContain("C0"));

            var pw = new FlatPathWriter();

            using (var t = DisposingFile.CreateTempFileWithTail(".txt")) {
                pw.Render(gc, backProjectedDeps, $"{{ {FlatPathWriter.PathMarkerOption} C* }}".Replace(" ", Environment.NewLine),
                          new WriteTarget(t.FileName, append: false, limitLinesForConsole: 100), ignoreCase: false);

                using (var sr = new StreamReader(t.FileName)) {
                    var o = sr.ReadToEnd();

                    //Console.WriteLine(o);
                    Assert.IsTrue(o.Contains("a:1"));
                    Assert.IsTrue(o.Contains("<= a:2 $"));
                }
            }
        }
Ejemplo n.º 17
0
        public void ExitDependenciesNotOkAspects()
        {
            using (var d = DisposingFile.CreateTempFileWithTail(".dll.dep")) {
                using (TextWriter tw = new StreamWriter(d.FileName)) {
                    tw.Write(@"$ DOTNETITEM ---> DOTNETITEM

                    NDepCheck.TestAssembly.** ---> NDepCheck.TestAssembly.**
                    NDepCheck.TestAssembly.** ---> System.**
                    NDepCheck.TestAssembly.dir1.dir2:SomeClass ---? -:NamespacelessTestClassForNDepCheck::I
                    -:* ---? System:*

                    // Schlägt fehlt, weil eine SpecialMethod auch auf ExtraordinaryMethod zugreift!
                    :::*SpecialMethod* ---> : {
                       : ---> System:*
                         ---> :::*SpecialMethod*
                    }
                    ");
                }

                Assert.AreEqual(Program.DEPENDENCIES_NOT_OK,
                                Program.Main(new[] { Program.LogChattyOption.Opt }.Concat(CreateCheckDepsArgs(d)).ToArray()));
            }
        }
        public void TestAddImplementsDependencies()
        {
            using (var dipFile = DisposingFile.CreateTempFileWithTail(".dip").Keep) {
                int result =
                    Program.Main(new[] {
                    MainTests.TestAssemblyPath,
                    Program.TransformOption.Opt, typeof(PathMarker).Name, "{",
                    PathMarker.DefineItemMatchOption.Opt, "C", "'_class",
                    PathMarker.DefineItemMatchOption.Opt, "I", "'_interface",
                    PathMarker.DefineDependencyMatchOption.Opt, "i", "'_directlyimplements",
                    PathMarker.DefineDependencyMatchOption.Opt, "d", "'_directlyderivedfrom",
                    PathMarker.RegexOption.Opt, "C#([id]:)*[id]I",
                    PathMarker.AddDependencyOption.Opt,
                    PathMarker.AddMarkerOption.Opt, "implements",
                    //PathMarker.AddIndexedMarkerOption.Opt, "implements",
                    "}",
                    Program.WriteDipOption.Opt, dipFile.FileName,
                    //typeof(FlatPathWriter).Name, "{",
                    //    FlatPathWriter.PathMarkerOption.Opt, "_directlyimplements*",
                    //    FlatPathWriter.ShowItemMarkersOption.Opt,
                    //"}", dipFile.FileName,
                });
                Assert.AreEqual(Program.OK_RESULT, result);

                using (var tr = new StreamReader(dipFile.FileName)) {
                    string o = tr.ReadToEnd().Trim();

                    AssertImplements(o, "AbstractImplementingClass", "ISomeBaseInterface");
                    AssertImplements(o, "ImplementingClass1", "ISomeBaseInterface");
                    AssertImplements(o, "ImplementingClass2", "ISomeBaseInterface");
                    AssertImplements(o, "AbstractImplementingClass", "ISomeInterface");
                    AssertImplements(o, "ImplementingClass1", "ISomeInterface");
                    AssertImplements(o, "ImplementingClass2", "ISomeInterface");
                    AssertImplements(o, "ISomeInterface", "ISomeBaseInterface", false);
                }
            }
        }
Ejemplo n.º 19
0
        public void TestWritePluginption()
        {
            using (var d = DisposingFile.CreateTempFileWithTail(".dll.dep")) {
                using (TextWriter tw = new StreamWriter(d.FileName)) {
                    tw.Write(@"
                    $ DOTNETITEM ---> DOTNETITEM
                  
                    NDepCheck.TestAssembly.** ---> NDepCheck.TestAssembly.**
                    NDepCheck.TestAssembly.**::NDepCheck.TestAssembly ---> System.**::mscorlib
                    NDepCheck.TestAssembly.dir1.dir2:SomeClass        ---? -:NamespacelessTestClassForNDepCheck::I
                    -:*                       ---? System:**
                    NDepCheck.TestAssembly.** ---> NDepCheck.TestAssembly.**

                    $ DOTNETASSEMBLY ---> DOTNETASSEMBLY
                    **          ---> **

                    $ DOTNETITEM      ---> SIMPLE(Name)
                    ! System**:**     ---> .Net
                    ! Microsoft**:**  ---> .Net
                    ! (**):(**)       ---> \1#\2
                ");
                }

                using (var e = DisposingFile.CreateTempFileWithTail(".gif")) {
                    // typeof(FullName) forces copying to known directory ...
                    Assert.AreEqual(0,
                                    Program.Main(
                                        CreateCheckDepsArgs(d)
                                        .Concat(new[] {
                        Program.WritePluginOption.Opt, "NDepCheck.TestRenderer.dll",
                        typeof(TestRendererForLoadFromAssembly).FullName, e.FileName
                    })
                                        .ToArray()));
                }
            }
        }
Ejemplo n.º 20
0
        public void TestParams()
        {
            const string mainScript = "main.nd";
            const string script1    = "script1.nd";
            const string script1a   = "script1a.nd";
            const string script2    = "script2.nd";
            string       resultTxt  = Path.GetFullPath("result.txt");

            Console.WriteLine($"Writing to {resultTxt}");

            using (DisposingFile m = DisposingFile.Create(mainScript)) {
                using (DisposingFile s1 = DisposingFile.Create(script1)) {
                    using (DisposingFile s1a = DisposingFile.Create(script1a)) {
                        using (DisposingFile s2 = DisposingFile.Create(script2)) {
                            using (DisposingFile result = DisposingFile.Create(resultTxt)) {
                                using (var tw = new StreamWriter(m.FileName)) {
                                    tw.WriteLine($"-dc cmd.exe 2 {{ /c echo START > {result} }} " +
                                                 "-dd VALUE1 value1 " +
                                                 $"-ds {script1} VALUE1 : value3 " +
                                                                            // passes value1, null, value3
                                                 $"-ds {script2} VALUE1 " + // passes value1
                                                 $"-dc cmd.exe 2 {{ /c echo END >> {result} }} ");
                                }
                                using (var tw = new StreamWriter(s1.FileName)) {
                                    tw.WriteLine(
                                        "-fp F1 -fp F2 defaultValue2 -fp F3 defaultValue3 -fp F4 defaultValue4 " +
                                        // receives value1, [null->]defaultValue2, value3, [null->]defaultValue4
                                        $"-dc cmd.exe 2 {{ /c echo {script1} F1 F2 F3 F4 F5 >> {result} }} " +
                                        // first line: value1, defaultValue2, value3, defaultValue4, F5
                                        $"-ds {script1a} value1a 2=F3 " +
                                        // passed value1a, 2=value3
                                        $"-dc cmd.exe 2 {{ /c echo {script1} F1 F2 F3 F4 F5 >> {result} }}");
                                    // third result line: write same as above, but globalF5 at the end
                                }
                                using (var tw = new StreamWriter(s1a.FileName)) {
                                    tw.WriteLine(
                                        "-fp F1 -fp F2 defaultValue2 -fp F3 defaultValue3 -fp F4 defaultValue4 " +
                                        // receives value1a 2=value3 [null->]defaultValue3 [null->]defaultValue4
                                        "-dd F5 globalF5 " +
                                        $"-dc cmd.exe 2 {{ /c echo {script1a} F1 F2 F3 F4 F5 >> {result} }} ");
                                    // second result line: value1a, 2=value3, defaultValue3, defaultValue4, globalF5
                                }
                                using (var tw = new StreamWriter(s2.FileName)) {
                                    tw.WriteLine(
                                        "-fp F1 -fp F2 defaultValue2 -fp F3 defaultValue3 -fp F4 defaultValue4 " +
                                        // receives value1, [null->]defaultValue2, [null->]defaultValue3, [null->]defaultValue4
                                        $"-dc cmd.exe 2 {{ /c echo {script2} F1 F2 F3 F4 F5 >> {result} }} ");
                                    // fourth result line: value1, defaultValue2, defaultValue3, defaultValue4, globalF5
                                }

                                int returnValue = Program.Main(new[] { "-ds", mainScript });
                                Assert.AreEqual(0, returnValue);

                                using (var tr = new StreamReader(result.FileName)) {
                                    string resultContents = tr.ReadToEnd().Trim();
                                    Assert.IsTrue(resultContents.StartsWith("START"));
                                    Assert.IsTrue(resultContents.EndsWith("END"));

                                    Assert.IsTrue(
                                        resultContents.Contains(
                                            @"script1.nd value1 defaultValue2 value3 defaultValue4 F5 
script1a.nd value1a 2=value3 defaultValue3 defaultValue4 globalF5 
script1.nd value1 defaultValue2 value3 defaultValue4 globalF5 
script2.nd value1 defaultValue2 defaultValue3 defaultValue4 globalF5"));
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 21
0
        public void GeneralSucceedingTest()
        {
            using (var ruleFile = DisposingFile.CreateTempFileWithTail(".dll.dep")) {
                using (TextWriter tw = new StreamWriter(ruleFile.FileName, false, Encoding.Default)) {
                    tw.Write(@"
// Test dependencies for NDepCheck

$ DOTNETITEM ---> DOTNETITEM
                  
    // Every class may use all classes from its own namespace.
(**): ---> \1:

    // Special dependency for classes from global namespace
    // A class from the global namespace may use
    // all classes from that namespace.
-:** ---> -:**

    // Every class may use all classes from child namespaces
    // of its own namespace.
(**): ---> \1.**:

    // Every class may use all of System.
** ---> System.**:


    // NDepCheck may use antlr and itself.
NDepCheck ---> antlr

    // NDepCheck must not use Windows Forms.
NDepCheck.** ---! System.Windows.Forms.**

_TES  := asdasdasdasdasdasd
_TESTS := NDepCheck.TestAssembly
_TEST_OTHERS := xxxxxxxxxxxxx
_TEST := asdasdasdasdasdasd

    // Test declarations from dir1.dir2 may use declarations from dir1.dir3.
_TESTS.dir1.dir2:* ---> _TESTS.dir1.dir3:*


_TESTS.dir1:* ---> _TESTS.dir1.dir3:*
    
    // ...SomeClass.AnotherMethod may use -:NamespacelessTestClassForNDepCheck -
    // but this is questionable.
_TESTS.dir1.dir2:SomeClass::AnotherMethod ---? -:NamespacelessTestClassForNDepCheck

    // A questionable rule that never fires - it should be output.
asdlkfj.* ---? askdjf.*;

    // Umlautmatching rules
_TESTS.dirümläut.** ---> _TESTS.dirümläutö.** 
_TESTS.dirümläut.** ---> _TESTS.dirümläutß.** 
_TESTS.dirumlaut.** ---> _TESTS.dirumlauts.** 

    // Test case for ""open item 5""
    // Methods called InnerClassMethod may call each other
:::InnerClassMethod ---> :::InnerClassMethod 

    // Tests must be able to see tested classes
_TESTS.** ---> NDepCheck.**

    // Tests may use Microsoft.VisualStudio.TestTools.
_TESTS.** ---> Microsoft.VisualStudio.TestTools.**

// ------------------

    // In these tests, we ignore everything in the
    // current test class.
NDepCheck:Tests ---> **

//////// ------------------

//////    // All of system is ignored
//////% ()System.**

//////    // Classes in NDepCheck.Tests are shown separately, without the namespace
//////% NDepCheck.Tests.(**)

//////    // Classes in NDepCheck are also shown separately, but with the namespace
//////% (NDepCheck)

//////    // antlr classes are shown by namespace
//////% (antlr)
//////% (antlr.**)

//////    // Top level classes are shown as their class name
//////% -:(*)
                ");
                }

                string outFile = Path.GetTempFileName();
                int    result;
                //string workingDir = Path.GetTempPath();
                using (TextWriter tw = new StreamWriter(outFile)) {
                    TextWriter oldOut = Console.Out;
                    Console.SetOut(tw);
                    string[] args =
                    {
                        Program.LogVerboseOption.Opt,
                        Program.ConfigureOption.Opt,
                        typeof(CheckDeps).Name,             "<.",
                        CheckDeps.DefaultRuleFileOption.Opt,ruleFile.FileName,
                        ".>",
                        Program.ReadOption.Opt,
                        TestAssemblyPath
                    };
                    result = Program.Main(args);
                    Console.SetOut(oldOut);
                }
                AssertNotContains(outFile, "****");
                File.Delete(outFile);
                Assert.AreEqual(Program.OK_RESULT, result);
            }
        }