示例#1
0
        public void WhenNamespaceTypeWithMultipleSections_Parse_SetsNamespace()
        {
            CRefPath path = CRefPath.Parse("N:System.Net.Http");

            Assert.AreEqual(CRefTypes.Namespace, path.PathType);
            Assert.AreEqual("System.Net.Http", path.Namespace);
        }
示例#2
0
        public void WhenPassedAnInvalidPath_Parse_TypeIsError()
        {
            CRefPath path = CRefPath.Parse("invalid string");

            Assert.AreEqual(CRefTypes.Error, path.PathType);
            Assert.AreEqual(string.Empty, path.ToString());
        }
示例#3
0
        private void TestSearch()
        {
            CRefPath path   = CRefPath.Parse("M:theboxsoftware.api.livedocumenter.tableofcontents.getdocumentationfor(system.string)");
            Entry    member = this.document.Find(path);

            System.Console.Write(string.Format("[pass] found member {0} from path {1}\n", member.Name, path.ToString()));
        }
示例#4
0
        public void WhenMethodTypeWithNamespaceSection_Parse_SetsNamespace()
        {
            CRefPath path = CRefPath.Parse("M:System.Namespace.TypeName.MethodName()");

            Assert.AreEqual(CRefTypes.Method, path.PathType);
            Assert.AreEqual("MethodName", path.ElementName);
            Assert.AreEqual("System.Namespace", path.Namespace);
            Assert.AreEqual("TypeName", path.TypeName);
        }
示例#5
0
        public void WhenMethodTypeWithParameters_Parse_SetsParameters()
        {
            CRefPath path = CRefPath.Parse("M:System.String.Format(string)");

            Assert.AreEqual(CRefTypes.Method, path.PathType);
            Assert.AreEqual("System", path.Namespace);
            Assert.AreEqual("String", path.TypeName);
            Assert.AreEqual("Format", path.ElementName);
            Assert.AreEqual("(string)", path.Parameters);
        }
示例#6
0
        public void WhenCRefValid_GetSummary_ReturnsSummary()
        {
            XmlCommentFile commentFile = CreateXmlCommentFile("Myfile.xml");
            CRefPath       crefPath    = CRefPath.Parse("T:Namespace.MyType");

            SetFileExistsAndLoadXml(commentFile);

            XmlCodeComment result = commentFile.GetSummary(crefPath);

            Assert.AreEqual("Summary text", result.Elements[0].Text);
        }
示例#7
0
        public void WhenCRefInvalid_GetSummary_ReturnsEmpty()
        {
            XmlCommentFile commentFile = CreateXmlCommentFile("myfile.xml");

            SetFileExistsAndLoadXml(commentFile);
            CRefPath crefPath = CRefPath.Parse("T:Nothing");

            XmlCodeComment result = commentFile.GetSummary(crefPath);

            Assert.AreSame(XmlCodeComment.Empty, result);
        }
示例#8
0
        public void WhenCRefValidButNoData_GetComment_ReturnsEmpty()
        {
            XmlCommentFile commentFile = CreateXmlCommentFile("myfile.xml");

            SetFileExistsAndLoadXml(commentFile);
            CRefPath crefPath = CRefPath.Parse("T:Nowhere.DoesntExist");

            XmlCodeComment result = commentFile.GetComment(crefPath);

            Assert.AreSame(XmlCodeComment.Empty, result);
        }
示例#9
0
        public void WhenNotLoaded_GetComment_ReturnsEmpty()
        {
            XmlCommentFile commentFile = CreateXmlCommentFile("myfile.xml");

            _fileSystem.Setup(p => p.FileExists(It.IsAny <string>())).Returns(true);
            CRefPath crefPath = CRefPath.Parse("T:Namespace.TypeName");

            XmlCodeComment result = commentFile.GetComment(crefPath);

            Assert.AreSame(XmlCodeComment.Empty, result);
        }
示例#10
0
        public DisplayNameSignatureBenchmark()
        {
            _assembly = AssemblyDef.Create(TestFile);

            CRefPath path = CRefPath.Parse(TestMethod1);

            _method1 = _assembly.FindType(path.Namespace, path.TypeName).Methods.Find(m => m.Name == path.ElementName);

            path     = CRefPath.Parse(TestMethod2);
            _method2 = _assembly.FindType(path.Namespace, path.TypeName).Methods.Find(m => m.Name == path.ElementName);
        }
示例#11
0
        public void WhenCRefIsValid_GetComment_GetsCorrectComment()
        {
            XmlCommentFile commentFile = CreateXmlCommentFile("myfile.xml");

            SetFileExistsAndLoadXml(commentFile);
            CRefPath crefPath = CRefPath.Parse("T:Namespace.MyType");

            XmlCodeComment result = commentFile.GetComment(crefPath);

            Assert.AreNotSame(XmlCodeComment.Empty, result);
            Assert.AreEqual(1, result.Elements.Count);
        }
示例#12
0
        public void WhenMethodPathWithOnlyTwoPartNames_Parse_TypeIsError()
        {
            // this fails because there is not enough elements defined, currently we expect
            // that there are more than 2 elements, which will probably cause errors when
            // types are defined without a namespace.
            // TODO: Fix, but need to make sure all the rest of the system doesnt break.

            CRefPath path = CRefPath.Parse("M:string.ToUpper()");

            Assert.AreEqual(CRefTypes.Error, path.PathType); // this is currently an error as there
            // was no namespace defined
        }
示例#13
0
        public void WhenMethodPath_Parse_TypeIsMethod()
        {
            // I think there is a slight problem here, in that there is an expection
            // that all method defenitions will all have atleast 3 parts, namespace,
            // type and then method name. This is an error as some types can be defined
            // without a namespace.

            CRefPath path = CRefPath.Parse("M:System.string.ToUpper()");

            Assert.AreEqual(CRefTypes.Method, path.PathType);
            Assert.AreEqual("string", path.TypeName);
            Assert.AreEqual("ToUpper", path.ElementName);
            Assert.AreEqual("System", path.Namespace);
        }
        public override void Generate()
        {
            this.Blocks.Add(new Header1(this.associatedEntry.Name));

            SummaryTable classTable = new SummaryTable("Namespace", string.Empty, false, false);

            foreach (Entry currentNamespace in this.associatedEntry.Children)
            {
                CRefPath crefPath = CRefPath.Parse(string.Format("N:{0}", currentNamespace.SubKey));

                // Find the description for the type
                // Block description = this.GetSummaryFor(xmlFile, currentType.Assembly, "/doc/members/member[@name='" + crefPath + "']/summary");
                Hyperlink nameLink = new Hyperlink(new Run(currentNamespace.Name));
                nameLink.Tag    = new EntryKey(currentNamespace.Key, currentNamespace.SubKey);
                nameLink.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);
                classTable.AddItem(nameLink, string.Empty);
            }
            this.Blocks.Add(classTable);
        }
示例#15
0
        /// <summary>
        /// Resolves a hyperlink to a treenode in the document map
        /// </summary>
        /// <param name="sender">The source of the event</param>
        /// <param name="e">The event arguments</param>
        public static void Resolve(object sender, System.Windows.RoutedEventArgs e)
        {
            if (e.Source is System.Windows.Documents.Hyperlink)
            {
                System.Windows.Documents.Hyperlink sourceLink = e.Source as System.Windows.Documents.Hyperlink;
                LiveDocument document = LiveDocumentorFile.Singleton.LiveDocument;
                Entry        entry    = null;
                sourceLink.Cursor = Cursors.Wait;

                EntryKey key = null;
                if (sourceLink.Tag is CrefEntryKey)
                {
                    CrefEntryKey crefEntryKey = (CrefEntryKey)sourceLink.Tag;
                    CRefPath     path         = CRefPath.Parse(crefEntryKey.CRef);
                    entry = document.Find(path);
                }
                else if (sourceLink.Tag is EntryKey)
                {
                    key = (EntryKey)sourceLink.Tag;
                    if (key != null)
                    {
                        entry = document.Find(key.Key, key.SubKey);

                        if (entry != null && entry.Parent != null)
                        {
                            entry.IsSelected        = true;
                            entry.Parent.IsExpanded = true;
                        }
                    }
                }

                if (entry != null && entry.Parent != null)
                {
                    entry.IsSelected        = true;
                    entry.Parent.IsExpanded = true;
                }

                sourceLink.Cursor = null;
            }
        }
示例#16
0
        public void WhenEmptyNamespace_Parse_NamespaceIsEmptyString()
        {
            CRefPath path = CRefPath.Parse("N:");

            Assert.AreEqual(string.Empty, path.Namespace);
        }
示例#17
0
        public void WhenNamespaceTypeWithName_Parse_SetsNamespace()
        {
            CRefPath path = CRefPath.Parse("N:System");

            Assert.AreEqual("System", path.Namespace);
        }
示例#18
0
 public void WhenPassedEmptyString_Parse_ThrowsException()
 {
     Assert.Throws <ArgumentNullException>(delegate() {
         CRefPath.Parse(string.Empty);
     });
 }
示例#19
0
        public void WhenCRefIsErrorType_ToString_ShouldReturnEmptyString()
        {
            CRefPath path = CRefPath.Parse("invalid string");

            Assert.AreEqual(string.Empty, path.ToString());
        }
示例#20
0
        public void PathTypesShouldBeSetCorrectly(string path, CRefTypes expectedType)
        {
            CRefPath converted = CRefPath.Parse(path);

            Assert.AreEqual(expectedType, converted.PathType);
        }