Beispiel #1
0
        public void SignatureEquals_ShouldReturnTrueOnSignatureEquality(string src, bool equals)
        {
            Assembly asm = Compile(src);

            IMethodInfo
                a1 = MetadataMethodInfo.CreateFrom(asm.GetTypes().Single(t => t.Name.Contains("ClassA")).ListMethods().Single(m => m.Name == "Foo")),
                b1 = MetadataMethodInfo.CreateFrom(asm.GetTypes().Single(t => t.Name.Contains("ClassB")).ListMethods().Single(m => m.Name == "Foo"));

            CSharpCompilation compilation = CreateCompilation(src);

            var visitor = new FindAllTypesVisitor();

            visitor.VisitNamespace(compilation.GlobalNamespace);

            IMethodInfo
                a2 = SymbolMethodInfo.CreateFrom(visitor.AllTypeSymbols.Single(t => t.Name == "ClassA").ListMethods().Single(m => m.Name == "Foo"), compilation),
                b2 = SymbolMethodInfo.CreateFrom(visitor.AllTypeSymbols.Single(t => t.Name == "ClassB").ListMethods().Single(m => m.Name == "Foo"), compilation);

            Assert.That(a1.SignatureEquals(b1), Is.EqualTo(equals));
            Assert.That(a2.SignatureEquals(b2), Is.EqualTo(equals));
            Assert.That(a1.SignatureEquals(b2), Is.EqualTo(equals));
            Assert.That(a2.SignatureEquals(b1), Is.EqualTo(equals));
        }