Exemplo n.º 1
0
        public void EmptyClass()
        {
            var source = @"
                class Class1 {
                }
            ";

            var classDeclarationNode = NodeFinder <ClassDeclarationSyntax> .GetNode(source);

            Assert.IsNotNull(classDeclarationNode);

            var translationUnitFactory = new ClassDeclarationTranslationUnitFactory(classDeclarationNode).Create();

            Assert.IsNotNull(translationUnitFactory, "Translation unit expected to be created!");

            var classDeclarationTranslationUnit = (translationUnitFactory as ClassDeclarationTranslationUnit);

            Assert.IsNotNull(classDeclarationTranslationUnit, $"Expecting a translation unit of type {typeof(ClassDeclarationTranslationUnit).Name}!");

            var translationUnit = MockedClassDeclarationTranslationUnit.Create(classDeclarationTranslationUnit);

            Assert.IsNotNull(translationUnit.ConstructorDeclarations);
            Assert.AreEqual(0, translationUnit.ConstructorDeclarations.Count(), "Expecting no ctors!");

            Assert.IsNotNull(translationUnit.MethodDeclarations);
            Assert.AreEqual(0, translationUnit.MethodDeclarations.Count(), "Expecting no methods!");

            Assert.IsNotNull(translationUnit.PropertyDeclarations);
            Assert.AreEqual(0, translationUnit.PropertyDeclarations.Count(), "Expecting no properties!");

            Assert.IsNotNull(translationUnit.MemberDeclarations);
            Assert.AreEqual(0, translationUnit.MemberDeclarations.Count(), "Expecting no members!");
        }
Exemplo n.º 2
0
        public void ClassName()
        {
            var source = @"
                class Class1 {
                }
            ";

            var classDeclarationNode = NodeFinder <ClassDeclarationSyntax> .GetNode(source);

            Assert.IsNotNull(classDeclarationNode);

            var translationUnitFactory = new ClassDeclarationTranslationUnitFactory(classDeclarationNode).Create();

            Assert.IsNotNull(translationUnitFactory, "Translation unit expected to be created!");

            var classDeclarationTranslationUnit = (translationUnitFactory as ClassDeclarationTranslationUnit);

            Assert.IsNotNull(classDeclarationTranslationUnit, $"Expecting a translation unit of type {typeof(ClassDeclarationTranslationUnit).Name}!");

            var translationUnit = MockedClassDeclarationTranslationUnit.Create(classDeclarationTranslationUnit);

            Assert.IsNotNull(translationUnit.Name);
            Assert.AreEqual("Class1", translationUnit.Name.Translate(), "Wrong name!");
        }
Exemplo n.º 3
0
 protected MockedClassASTWalker(ClassASTWalker original)
     : base(original)
 {
     // Reassigning since base class operated on it
     this.classDeclaration = MockedClassDeclarationTranslationUnit.Create(this.classDeclaration);
 }