Exemplo n.º 1
0
        public void Type_ComplexAssemblyLocation()
        {
            var expected =
                @"Generic:
  NamedType:
    ""Baz""
    Assembly:
      ""Quux""
  ArrayType:
    NamedType:
      ""Foo.Bar""
      Assembly:
        ""FooBar""
        Qualification:
          ""Culture""
          ""neu""tr]al""
        Qualification:
          ""Frob""
          ""bar]x""
        Qualification:
          ""Version""
          ""3.14""
    2
";

            // Ensure we can correctly locate the start of the assembly dispite complex syntax along the way.
            Assert.That(TreeRenderer.Format(InsTypeFactory.ParseTypeName("Baz[[Foo.Bar[,], FooBar, Culture=\"neu\\\"tr]al\", Frob=bar\\]x, Version=3.14]], Quux")), Is.EqualTo(expected));
        }
        public void RewriteQualification()
        {
            var result = _allTheTypes.Apply(DummyRewriter.Instance, x => Replace(x, "Culture", "AnotherCulture"));

            const string ExpectedDiffs =
                @"~ByRef:
~  Pointer:
~    SZArrayType:
~      ArrayType:
~        Generic:
~          NamedType:
             ""Nested""
~            NamedType:
               ""TypeName""
~              Assembly:
                 ""Foo""
~                Qualification:
-                  ""Culture""
+                  ""AnotherCulture""
                   ""neutral""
           NamedType:
             ""TArg""
         1
";

            Assert.That(TreeRenderer.Diff(_allTheTypes, result), Is.EqualTo(ExpectedDiffs));
        }
Exemplo n.º 3
0
        public void Type_Unqualified()
        {
            var expected =
                @"NamedType:
  ""Foo.Bar""
";

            Assert.That(TreeRenderer.Format(InsTypeFactory.ParseTypeName("Foo.Bar")), Is.EqualTo(expected));
        }
Exemplo n.º 4
0
        public void Type_ByRef()
        {
            var expected =
                @"ByRef:
  NamedType:
    ""Foo.Bar""
    Assembly:
      ""FooBar""
";

            Assert.That(TreeRenderer.Format(InsTypeFactory.ParseTypeName("Foo.Bar&, FooBar")), Is.EqualTo(expected));
        }
Exemplo n.º 5
0
        public void Type_PointerPointer()
        {
            var expected =
                @"Pointer:
  Pointer:
    NamedType:
      ""Foo.Bar""
      Assembly:
        ""FooBar""
";

            Assert.That(TreeRenderer.Format(InsTypeFactory.ParseTypeName("Foo.Bar**, FooBar")), Is.EqualTo(expected));
        }
Exemplo n.º 6
0
        public void Type_Array2()
        {
            var expected =
                @"ArrayType:
  NamedType:
    ""Foo.Bar""
    Assembly:
      ""FooBar""
  2
";

            Assert.That(TreeRenderer.Format(InsTypeFactory.ParseTypeName("Foo.Bar[,], FooBar")), Is.EqualTo(expected));
        }
Exemplo n.º 7
0
        public void Type_Nested()
        {
            var expected =
                @"NamedType:
  ""Baz""
  NamedType:
    ""Foo.Bar""
    Assembly:
      ""FooBar""
";

            Assert.That(TreeRenderer.Format(InsTypeFactory.ParseTypeName("Foo.Bar+Baz, FooBar")), Is.EqualTo(expected));
        }
Exemplo n.º 8
0
        public void Type_GenericWithUnquolifiedArg1()
        {
            var expected =
                @"Generic:
  NamedType:
    ""Foo.Bar`1""
    Assembly:
      ""FooBar""
  NamedType:
    ""Baz""
";

            Assert.That(TreeRenderer.Format(InsTypeFactory.ParseTypeName("Foo.Bar`1[Baz], FooBar")), Is.EqualTo(expected));
        }
Exemplo n.º 9
0
        public void Type_ArrayOfGeneric()
        {
            var expected =
                @"SZArrayType:
  Generic:
    NamedType:
      ""Foo.Bar`1""
      Assembly:
        ""FooBar""
    NamedType:
      ""Baz""
";

            Assert.That(TreeRenderer.Format(InsTypeFactory.ParseTypeName("Foo.Bar`1[Baz][], FooBar")), Is.EqualTo(expected));
        }
Exemplo n.º 10
0
        public void Type_FullyQualified()
        {
            var expected =
                @"NamedType:
  ""Foo.Bar.Baz""
  Assembly:
    ""FooBar""
    Qualification:
      ""Culture""
      ""neutral""
    Qualification:
      ""Version""
      ""3.14""
";

            Assert.That(TreeRenderer.Format(InsTypeFactory.ParseTypeName("Foo.Bar.Baz, FooBar, Culture=neutral, Version=3.14")), Is.EqualTo(expected));
        }