Exemple #1
0
        public void Setup()
        {
            var identifierHelper = Substitute.For <IIdentifierHelper>();

            identifierHelper
            .ParseIdentifier("FirstName")
            .Returns(new List <string> {
                "first", "name"
            });
            identifierHelper
            .ParseIdentifier("LastName")
            .Returns(new List <string> {
                "last", "name"
            });
            identifierHelper
            .ParseIdentifier("FullName")
            .Returns(new List <string> {
                "full", "name"
            });

            var documentationGenerator = new DocumentionGenerator(identifierHelper);

            var getSetPropertyDef = TestHelpers.GetSyntaxSymbol <PropertyDeclarationSyntax>(Code, 2);
            var setProperytDef    = TestHelpers.GetSyntaxSymbol <PropertyDeclarationSyntax>(Code, 3);
            var getProperytDef    = TestHelpers.GetSyntaxSymbol <PropertyDeclarationSyntax>(Code, 4);

            _getSetResult = documentationGenerator.GeneratePropertyDocs(getSetPropertyDef);
            _setResult    = documentationGenerator.GeneratePropertyDocs(setProperytDef);
            _getResult    = documentationGenerator.GeneratePropertyDocs(getProperytDef);
        }
Exemple #2
0
        public void Setup()
        {
            var identifierHelper = Substitute.For <IIdentifierHelper>();

            identifierHelper.ParseIdentifier("Test").Returns(new List <string> {
                "test"
            });
            identifierHelper.ParseIdentifier("testAmount").Returns(new List <string> {
                "test", "amount"
            });
            var documentationGenerator = new DocumentionGenerator(identifierHelper);

            var ctorDefClass = TestHelpers.GetSyntaxSymbol <ConstructorDeclarationSyntax>(
                @"class Test
{
    public Test(double testAmount)
    {
    }
}", 2);

            var ctorDefStruct = TestHelpers.GetSyntaxSymbol <ConstructorDeclarationSyntax>(
                @"struct Test
{
    public Test(double testAmount)
    {
    }
}", 2);

            _classResult  = documentationGenerator.GenerateConstructorDocs(ctorDefClass);
            _structResult = documentationGenerator.GenerateConstructorDocs(ctorDefStruct);
        }
        public void Setup()
        {
            var identifierHelper = Substitute.For <IIdentifierHelper>();

            identifierHelper.ParseIdentifier("Test").Returns(new List <string> {
                "test"
            });
            var documentationGenerator = new DocumentionGenerator(identifierHelper);

            var ctorDef = TestHelpers.GetSyntaxSymbol <StructDeclarationSyntax>("struct Test : IStructBase<string> { }");

            _result = documentationGenerator.GenerateStructDocs(ctorDef);
        }
        public void Setup()
        {
            var identifierHelper = Substitute.For <IIdentifierHelper>();

            identifierHelper.ParseIdentifier("EntityId").Returns(new List <string> {
                "entity", "id"
            });
            var documentationGenerator = new DocumentionGenerator(identifierHelper);

            var fieldDef = TestHelpers.GetSyntaxSymbol <FieldDeclarationSyntax>(
                @"public class TestClass
{
    public int EntityId = 123;
}", 2);

            _result = documentationGenerator.GenerateFieldDocs(fieldDef);
        }
Exemple #5
0
        public void Setup()
        {
            var identifierHelper = Substitute.For <IIdentifierHelper>();

            identifierHelper.ParseIdentifier("Test").Returns(new List <string> {
                "test"
            });
            var documentationGenerator = new DocumentionGenerator(identifierHelper);

            var enumDef = TestHelpers.GetSyntaxSymbol <EnumDeclarationSyntax>(
                @"enum Test : AnotherEnum<string>
{
    ONE = 1
}");

            _result = documentationGenerator.GenerateEnumDocs(enumDef);
        }
        public void Setup()
        {
            var identifierHelper = Substitute.For <IIdentifierHelper>();

            identifierHelper.ParseIdentifier("Test").Returns(new List <string> {
                "test"
            });
            identifierHelper.ParseIdentifier("T").Returns(new List <string> {
                "t"
            });
            var documentationGenerator = new DocumentionGenerator(identifierHelper);

            var classDef = TestHelpers.GetSyntaxSymbol <ClassDeclarationSyntax>(
                @"class Test<T> : ITest<string>
{
}");

            _result = documentationGenerator.GenerateClassDocs(classDef);
        }
        public void Setup()
        {
            var identifierHelper = Substitute.For <IIdentifierHelper>();

            identifierHelper.ParseIdentifier("ITest").Returns(new List <string> {
                "i", "test"
            });
            identifierHelper.ParseIdentifier("T").Returns(new List <string> {
                "t"
            });

            var documentationGenerator = new DocumentionGenerator(identifierHelper);

            var interfaceDef = TestHelpers.GetSyntaxSymbol <InterfaceDeclarationSyntax>(
                @"interface ITest<T> : IBase<string>
{
}");

            _result = documentationGenerator.GenerateInterfaceDocs(interfaceDef);
        }
Exemple #8
0
        public void Setup()
        {
            var identifierHelper = Substitute.For <IIdentifierHelper>();

            identifierHelper
            .ParseIdentifier("GetSomething")
            .Returns(
                new List <string> {
                "get", "something"
            });
            identifierHelper
            .ParseIdentifier("Main")
            .Returns(
                new List <string> {
                "main"
            });
            identifierHelper
            .ParseIdentifier("id")
            .Returns(new List <string> {
                "id"
            });
            identifierHelper
            .ParseIdentifier("name")
            .Returns(new List <string> {
                "name"
            });
            identifierHelper
            .ParseIdentifier("args")
            .Returns(new List <string> {
                "args"
            });
            identifierHelper
            .ParseIdentifier("TStuff")
            .Returns(new List <string> {
                "t", "stuff"
            });
            identifierHelper
            .ParseIdentifier("parameter")
            .Returns(new List <string> {
                "parameter"
            });
            identifierHelper
            .ParseIdentifier("ThrowsException")
            .Returns(new List <string> {
                "throws", "exception"
            });
            identifierHelper
            .ParseIdentifier("Test")
            .Returns(new List <string> {
                "test"
            });

            var documentationGenerator = new DocumentionGenerator(identifierHelper);

            var pluralMethodDef = TestHelpers.GetSyntaxSymbol <MethodDeclarationSyntax>(
                @"public class TestClass
{
    public void GetSomething<TStuff>(int id, string name)
    {
    }
}", 2);

            var singularMethodDef = TestHelpers.GetSyntaxSymbol <MethodDeclarationSyntax>(
                @"public class TestClass
{
    public void Main(string[] args)
    {
    }
}", 2);


            var disposeMethodDef = TestHelpers.GetSyntaxSymbol <MethodDeclarationSyntax>(
                @"public class TestClass : IDisposable
{
    public void Dispose(string parameter)
    {
    }
}", 2);
            var exceptionThrowingMethodDef = TestHelpers.GetSyntaxSymbol <MethodDeclarationSyntax>(
                @"public class TestClass
{
    public void ThrowsException()
    {
        if (1 == 1)
        {
            throw new Exception(""test"");
        }
        else
        {
            throw new HttpException(""http test"");
        }
    }
}", 2);
            var interfaceMethodDef = TestHelpers.GetSyntaxSymbol <MethodDeclarationSyntax>(
                @"public class ITestInterface
{
    public void Test();
}", 2);

            _pluralResult            = documentationGenerator.GenerateMethodDocs(pluralMethodDef);
            _singularResult          = documentationGenerator.GenerateMethodDocs(singularMethodDef);
            _disposeResult           = documentationGenerator.GenerateMethodDocs(disposeMethodDef);
            _exceptionThrowingResult = documentationGenerator.GenerateMethodDocs(exceptionThrowingMethodDef);
            _interfaceDefResult      = documentationGenerator.GenerateMethodDocs(interfaceMethodDef);
        }