Esempio n. 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);
        }
Esempio n. 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());
        }
Esempio n. 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()));
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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
        }
Esempio n. 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);
        }
Esempio n. 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;
            }
        }
Esempio n. 16
0
        public void WhenEmptyNamespace_Parse_NamespaceIsEmptyString()
        {
            CRefPath path = CRefPath.Parse("N:");

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

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

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

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