public void GivenEmptyClass_WhenVisitingClassDeclarationSyntax_TempltePathExceptionThrown()
        {
            //Assign
            var tree = CSharpSyntaxTree.ParseFile(TestClassPath + "EmptyClass.cs");
            var root = tree.GetRoot();
            //Act
            var ex = Assert.Throws <Roslyn.FurnaceObjectTypes.FurnaceTypeWriter.BaseClassException>(() => Sut.Visit(root));

            //Assert
            Assert.That(ex.InvalidReasons, Contains.Item(Roslyn.FurnaceObjectTypes.FurnaceTypeWriter.BaseClassException.EmptyBaseClass));
        }
Exemplo n.º 2
0
        public void GivenOneClass_WhenVisitingClassDeclarationSyntax_TempltePathExceptionNotThrown()
        {
            //Assign
            const string className = "OneClass";
            var          sut       = new Roslyn.FurnaceObjectTypes.FurnaceTypeWriter(BaseClass + className);
            var          tree      = CSharpSyntaxTree.ParseFile(TestClassPath + className + ".cs");
            var          root      = tree.GetRoot();

            //Act
            sut.Visit(root);
        }
        public void GivenEmptyClass_WhenVisitingClassDeclarationSyntax_TempltePathExceptionThrown()
        {
            //Assign
            var sut = new Roslyn.FurnaceObjectTypes.FurnaceTypeWriter(BaseClass);
            var tree = CSharpSyntaxTree.ParseFile(TestClassPath + "EmptyClass.cs");
            var root = tree.GetRoot();
            //Act
            var ex = Assert.Throws<Roslyn.FurnaceObjectTypes.FurnaceTypeWriter.BaseClassException>(() => sut.Visit(root));

            //Assert
            Assert.That(ex.InvalidReasons, Contains.Item(Roslyn.FurnaceObjectTypes.FurnaceTypeWriter.BaseClassException.EmptyBaseClass));
        }
        public void GivenOneClass_WhenVisitingClassDeclarationSyntax_BaseTypeAdded()
        {
            //Assign
            const string className = "OneClass";
            var sut = new Roslyn.FurnaceObjectTypes.FurnaceTypeWriter(BaseClass + className);
            var tree = CSharpSyntaxTree.ParseFile(TestClassPath + className + ".cs");
            var root = tree.GetRoot();

            //Act
            var result = sut.Visit(root).DescendantNodes().OfType<ClassDeclarationSyntax>().First();

            //Assert
            Assert.That(result.BaseList.Types.Count(), Is.EqualTo(1));
        }
Exemplo n.º 5
0
        public void GivenClassWithInterface_WhenVisitingClassDeclarationSyntax_BaseTypeAdded()
        {
            //Assign
            const string className = "ClassWithInterface";
            var          sut       = new Roslyn.FurnaceObjectTypes.FurnaceTypeWriter(BaseClass + className);
            var          tree      = CSharpSyntaxTree.ParseFile(TestClassPath + className + ".cs");
            var          root      = tree.GetRoot();

            //Act
            var result = sut.Visit(root).DescendantNodes().OfType <ClassDeclarationSyntax>().First();

            //Assert
            Assert.That(result.BaseList.Types.Count(), Is.EqualTo(2));
        }
Exemplo n.º 6
0
        public void GivenOneClass_WhenVisitingClassDeclarationSyntax_NewTypeNameIsCorrect()
        {
            //Assign
            const string className = "OneClass";
            var          sut       = new Roslyn.FurnaceObjectTypes.FurnaceTypeWriter(BaseClass + className);
            var          tree      = CSharpSyntaxTree.ParseFile(TestClassPath + className + ".cs");
            var          root      = tree.GetRoot();

            //Act
            var result = sut.Visit(root).DescendantNodes().OfType <ClassDeclarationSyntax>().First();

            //Assert
            Assert.That(result.Identifier.Text, Is.EqualTo(Roslyn.FurnaceObjectTypes.FurnaceTypeWriter.FurnaceTypeIdentifier + className));
        }
        public void GivenOneClass_WhenVisitingClassDeclarationSyntax_TempltePathExceptionNotThrown()
        {
            //Assign
            const string className = "OneClass";
            var sut = new Roslyn.FurnaceObjectTypes.FurnaceTypeWriter(BaseClass + className);
            var tree = CSharpSyntaxTree.ParseFile(TestClassPath + className + ".cs");
            var root = tree.GetRoot();

            //Act
            sut.Visit(root);
        }