NStub.CSharp.NamespaceDetector.InsertAfterShortestNamespace C# (CSharp) Method

InsertAfterShortestNamespace() public method

Insert the specified extra string into the namespace of a specified type, relative to the ShortestNamespace.
If the full qualified name of the input type is "NStub.CSharp.BuildContext.SetupAndTearDownContext" and the shortest (the root namespace of the library to test) namespace is "NStub.CSharp", then the output of this method is "NStub.CSharp.Tests.BuildContext.SetupAndTearDownContext", inserting the testNamespacePart between the ShortestNamespace and the rest of the full qualified name of inputType. Simply add "Test" at the end to it an you have the full qualified name to your test class.
public InsertAfterShortestNamespace ( CodeTypeDeclaration inputType, string testNamespacePart ) : string
inputType System.CodeDom.CodeTypeDeclaration The type with the input namespace.
testNamespacePart string The additional namespace part of the test project, e.g. ".Test".
return string
        public string InsertAfterShortestNamespace(CodeTypeDeclaration inputType, string testNamespacePart)
        {
            var combined = inputType.Name;
            var splitter = inputType.Name.Split(new[] { this.ShortestNamespace }, StringSplitOptions.RemoveEmptyEntries);
            if (splitter.Length == 1)
            {
                combined = this.ShortestNamespace + testNamespacePart + splitter[0];
            }

            return combined;
        }