Пример #1
0
        public void ShouldForceTypeIfOnlyMethodDefined()
        {
            var model = new DocumentModel(StubParser, StubEventAggregator);
            var members = new[] { Method<Second>(@"<member name=""M:Example.Second.SecondMethod"" />", x => x.SecondMethod()) };
            var namespaces = model.Create(members);

            namespaces[0].Name.ShouldEqual("Example");
            namespaces[0].Types.ShouldContain(x => x.IsIdentifiedBy(Identifier.FromType(typeof(Second))));
        }
Пример #2
0
 public void should_have_summary_for_documented_types()
 {
     var model = new DocumentModel(RealParser, StubEventAggregator);
     var members = new List<IDocumentationMember>(DocMembers(typeof(First)));
     var indexOfType = members.FindIndex(m => m is UndocumentedType);
     members[indexOfType] = Type<First>(@"<member name=""T:Example.First""><summary>The type description</summary></member>");
     var namespaces = model.Create(members);
     var onlyTypeInModel = namespaces.Single().Types.Single();
     onlyTypeInModel.Summary.Children.Count().ShouldNotEqual(0);
 }
Пример #3
0
        public void ShouldHaveParentForTypes_WithDocumentedParent()
        {
            var model = new DocumentModel(StubParser, StubEventAggregator);
            var members = new[]
            {
                Type<FirstChild>(@"<member name=""T:Example.FirstChild"" />"),  
            };
            var namespaces = model.Create(members);

            namespaces[0].Types[0].ParentType.ShouldNotBeNull();
            namespaces[0].Types[0].ParentType.PrettyName.ShouldEqual("First");
        }
Пример #4
0
        public void ShouldHaveValueForProperty()
        {
            var model = new DocumentModel(new CommentParser(), StubEventAggregator);
            var properties = new[]
            {
                Property<Second>(@"<member name=""P:Example.Second.SecondProperty""><value>The string representation.</value></member>", x => x.SecondProperty)
            };
            var namespaces = model.Create(properties);

            namespaces[0].Types[0].Properties[0].Value.Children.Count().ShouldEqual(1);
            ((InlineText)namespaces[0].Types[0].Properties[0].Value.Children.First()).Text.ShouldEqual("The string representation.");
        }
Пример #5
0
        public void ShouldHaveReturnsForMethods()
        {
            var model = new DocumentModel(new CommentParser(), StubEventAggregator);
            var members = new[]
            {
                Method<Second>(@"<member name=""M:Example.Second.ReturnType""><returns>Method with return</returns></member>", x => x.ReturnType()),
            };
            var namespaces = model.Create(members);

            namespaces[0].Types[0].Methods[0].Returns.Children.Count().ShouldEqual(1);
            ((InlineText)namespaces[0].Types[0].Methods[0].Returns.Children.First()).Text.ShouldEqual("Method with return");
        }
Пример #6
0
        public void ShouldHaveValueForMethod()
        {
            var model = new DocumentModel(new CommentParser(), StubEventAggregator);
            var methods = new[]
            {
                Method<ReturnMethodClass>(@"<member name=""Example.ReturnMethodClass""><value>A string.</value></member>", x => x.Method())
            };
            var namespaces = model.Create(methods);

            namespaces[0].Types[0].Methods[0].Value.Children.Count().ShouldEqual(1);
            ((InlineText)namespaces[0].Types[0].Methods[0].Value.Children.First()).Text.ShouldEqual("A string.");
        }
        public void ShouldRaiseWarningOnUnexpectedKindInReferenceInType()
        {
            var ev = MockRepository.GenerateMock<WarningEvent>();
            var model = new DocumentModel(new CommentParser(), StubEventAggregator);
            var members = new IDocumentationMember[] { Type<Second>(@"<member name=""T:Example.Second""><summary><see cref=""G:Whats-a-g"" /></summary></member>") };

            StubEventAggregator.Stub(x => x.GetEvent<WarningEvent>())
                .Return(ev);

            model.Create(members);

            ev.AssertWasCalled(x => x.Publish("Unsupported documentation member found: 'G:Whats-a-g'"));
        }
Пример #8
0
        public void ShouldHaveSummaryForFields()
        {
            var model = new DocumentModel(new CommentParser(), StubEventAggregator);
            var members = new[]
            {
                Field<Second>(@"<member name=""F:Example.Second.aField""><summary>A field</summary></member>", x => x.aField),
            };
            var namespaces = model.Create(members);
            var comment = new List<IComment>(namespaces[0].Types[0].Fields[0].Summary.Children);

            comment.Count.ShouldEqual(1);
            ((InlineText)comment[0]).Text.ShouldEqual("A field");
        }
Пример #9
0
        public void ShouldHaveRemarksForProperties()
        {
            var model = new DocumentModel(new CommentParser(), StubEventAggregator);
            var members = new[]
            {
                Property<Second>(@"<member name=""P:Example.Second.SecondProperty""><remarks>Second property</remarks></member>", x => x.SecondProperty),
            };
            var namespaces = model.Create(members);
            var comment = new List<IComment>(namespaces[0].Types[0].Properties[0].Remarks.Children);

            comment.Count.ShouldEqual(1);
            ((InlineText)comment[0]).Text.ShouldEqual("Second property");
        }
Пример #10
0
        public void ShouldHaveSummaryForType()
        {
            var model = new DocumentModel(RealParser, StubEventAggregator);
            var members = new[]
            {
                Type<First>(@"<member name=""T:Example.First""><summary>First summary</summary></member>"),
            };
            var namespaces = model.Create(members);
            var comment = new List<IComment>(namespaces[0].Types[0].Summary.Children);

            comment.Count.ShouldEqual(1);
            ((InlineText)comment[0]).Text.ShouldEqual("First summary");
        }
Пример #11
0
        public void ShouldHaveInterfacesForTypes()
        {
            var model = new DocumentModel(StubParser, StubEventAggregator);
            var members = new[]
            {
                Type<ClassWithInterfaces>(@"<member name=""T:Example.ClassWithInterfaces"" />"),
            };
            var namespaces = model.Create(members);

            namespaces[0].Types[0].Interfaces.Count.ShouldEqual(2);
            namespaces[0].Types[0].Interfaces[0].PrettyName.ShouldEqual("EmptyInterface");
            namespaces[0].Types[0].Interfaces[1].PrettyName.ShouldEqual("IDisposable");
        }
Пример #12
0
        public void ShouldHaveSummaryForMethods()
        {
            var model = new DocumentModel(new CommentParser(), StubEventAggregator);
            var members = new[]
            {
                Method<Second>(@"<member name=""M:Example.Second.SecondMethod2(System.String,System.Int32)""><summary>Second method 2</summary></member>", x => x.SecondMethod2(null, 0))
            };
            var namespaces = model.Create(members);
            var comment = new List<IComment>(namespaces[0].Types[0].Methods[0].Summary.Children);

            comment.Count.ShouldEqual(1);
            ((InlineText)comment[0]).Text.ShouldEqual("Second method 2");
        }
Пример #13
0
        public void ShouldHaveSummaryForEvents()
        {
            var model = new DocumentModel(new CommentParser(), StubEventAggregator);
            var members = new[]
            {
                Event<Second>(@"<member name=""E:Example.Second.AnEvent""><summary>An event</summary></member>", "AnEvent"),
            };
            var namespaces = model.Create(members);
            var comment = new List<IComment>(namespaces[0].Types[0].Events[0].Summary.Children);

            comment.Count.ShouldEqual(1);
            ((InlineText)comment[0]).Text.ShouldEqual("An event");
        }
Пример #14
0
        public void ShouldBuildNamespaces()
        {
            var model = new DocumentModel(StubParser, StubEventAggregator);
            var members = new[]
            {
                Type<First>(@"<member name=""T:Example.First"" />"),  
                Type<DeepFirst>(@"<member name=""T:Example.Deep.DeepFirst"" />"),
            };
            var namespaces = model.Create(members);

            namespaces.ShouldContain(x => x.IsIdentifiedBy(Identifier.FromNamespace("Example")));
            namespaces.ShouldContain(x => x.IsIdentifiedBy(Identifier.FromNamespace("Example.Deep")));
        }
Пример #15
0
        public void ShouldHaveRemarksForMethods()
        {
            var model = new DocumentModel(RealParser, StubEventAggregator);
            var members = new IDocumentationMember[]
            {
                Type<Second>(@"<member name=""T:Example.Second"" />"),
                Method<Second>(@"<member name=""M:Example.Second.SecondMethod2(System.String,System.Int32)""><remarks>Second method 2</remarks></member>", x => x.SecondMethod2(null, 0))
            };
            var namespaces = model.Create(members);
            var comment = new List<IComment>(namespaces[0].Types[0].Methods[0].Remarks.Children);

            comment.Count.ShouldEqual(1);
            ((InlineText)comment[0]).Text.ShouldEqual("Second method 2");
        }
Пример #16
0
        public void ShouldPassMethodReturnsToContentParser()
        {
            var contentParser = MockRepository.GenerateMock<ICommentParser>();
            var model = new DocumentModel(contentParser, StubEventAggregator);
            var members = new[] { Method<Second>(@"<member name=""M:Example.Second.ReturnType""><returns>Method with return</returns></member>", x => x.ReturnType()), };

            contentParser.Stub(x => x.Parse(null))
                .IgnoreArguments()
                .Return(new List<IComment>());

            model.Create(members);

            contentParser.AssertWasCalled(x => x.Parse(members[0].Xml.ChildNodes[0]));
        }
Пример #17
0
        public void ShouldHaveEventsInTypes()
        {
            var model = new DocumentModel(StubParser, StubEventAggregator);
            var members = new IDocumentationMember[]
            {
                Type<Second>(@"<member name=""T:Example.Second"" />"),  
                Event<Second>(@"<member name=""E:Example.Second.AnEvent"" />", "AnEvent"),
            };
            var namespaces = model.Create(members);
            var ev = typeof(Second).GetEvent("AnEvent");

            namespaces[0].Types[0].Events
                .ShouldContain(x => x.IsIdentifiedBy(Identifier.FromEvent(ev, typeof(Second))));
        }
Пример #18
0
        public void ShouldHaveEventsInTypes()
        {
            var model = new DocumentModel(StubParser, StubEventAggregator);
            var members = new IDocumentationMember[]
            {
                Type<Second>(@"<member name=""T:Example.Second"" />"),  
                Field<Second>(@"<member name=""F:Example.Second.aField"" />", x => x.aField),
            };
            var namespaces = model.Create(members);
            var field = Field<Second>(x => x.aField);

            namespaces[0].Types[0].Fields
                .ShouldContain(x => x.IsIdentifiedBy(Identifier.FromField(field, typeof(Second))));
        }
Пример #19
0
        public void ShouldPassMethodSummaryToContentParser()
        {
            var contentParser = MockRepository.GenerateMock<ICommentParser>();
            var model = new DocumentModel(contentParser, StubEventAggregator);
            var members = new[] { Method<Second>(@"<member name=""M:Example.Second.SecondMethod""><summary>First summary</summary></member>", x => x.SecondMethod()) };

            contentParser.Stub(x => x.ParseNode(null))
                .IgnoreArguments()
                .Return(new List<IComment>());

            model.Create(members);

            contentParser.AssertWasCalled(x => x.ParseNode(members[0].Xml.ChildNodes[0]));
        }
Пример #20
0
        public void ShouldPassRemarksToContentParser()
        {
            var contentParser = MockRepository.GenerateMock<ICommentParser>();
            var model = new DocumentModel(contentParser, StubEventAggregator);
            var members = new[] { Type<First>(@"<member name=""T:Example.First""><remarks>First remark</remarks></member>") };

            contentParser.Stub(x => x.ParseNode(null))
                .IgnoreArguments()
                .Return(new List<IComment>());

            model.Create(members);

            contentParser.AssertWasCalled(x => x.ParseNode(members[0].Xml.ChildNodes[0]));
        }
Пример #21
0
        public void ShouldHaveCustomAttributesOnProperties()
        {
            var model = new DocumentModel(StubParser, StubEventAggregator);
            var members = new IDocumentationMember[]
            {
                Type<Second>(@"<member name=""T:Example.Second"" />"),
                Property<Second>(@"<member name=""P:Example.Second.SecondProperty2"" />", x => x.SecondProperty2)
            };
            var namespaces = model.Create(members);
            var property = namespaces[0].Types[0].Properties[0];

            property.Attributes.ShouldNotBeNull();
            property.Attributes.Count.ShouldEqual(1);
            property.Attributes.FirstOrDefault().ShouldBeOfType<CustomAttribute>();
        }
Пример #22
0
        public void ShouldHaveExampleForEvent()
        {
            var model = new DocumentModel(RealParser, StubEventAggregator);
            var members = new IDocumentationMember[]
            {
                Type<Second>(@"<member name=""T:Example.Second"" />"),
                Event<Second>("<member name=\"E:Example.Second.AnEvent\"><example>\r\n                    void Something()\r\n                    {\r\n                      return;\r\n                    }\r\n                  </example></member>", "AnEvent")
            };
            var namespaces = model.Create(members);
            var @event = namespaces.Single().Classes.Single().Events.Single();

            @event.Example.ShouldNotBeNull();

            @event.Example.ShouldMatchStructure(com =>
                                                com.InlineText("void Something()\r\n{\r\n  return;\r\n}"));
        }
Пример #23
0
        public void ShouldHaveExampleForMethod()
        {
            var model = new DocumentModel(RealParser, StubEventAggregator);
            var members = new IDocumentationMember[]
            {
                Type<Second>(@"<member name=""T:Example.Second"" />"),
                Method<Second>("<member name=\"M:Example.Second.SecondMethod2(System.String,System.Int32)\"><example>\r\n                    void Something()\r\n                    {\r\n                      return;\r\n                    }\r\n                  </example></member>", x => x.SecondMethod2(null, 0))
            };
            var namespaces = model.Create(members);
            var method = namespaces.Single().Classes.Single().Methods.Single();

            method.Example.ShouldNotBeNull();

            method.Example.ShouldMatchStructure(com =>
                                                com.InlineText("void Something()\r\n{\r\n  return;\r\n}"));
        }
Пример #24
0
        public void ShouldHaveExampleForField()
        {
            var model = new DocumentModel(RealParser, StubEventAggregator);
            var members = new IDocumentationMember[]
            {
                Type<Second>(@"<member name=""T:Example.Second"" />"),
                Field<Second>("<member name=\"F:Example.Second.aField\"><example>\r\n                    void Something()\r\n                    {\r\n                      return;\r\n                    }\r\n                  </example></member>", x => x.aField)
            };
            var namespaces = model.Create(members);
            var field = namespaces.Single().Classes.Single().Fields.Single();

            field.Example.ShouldNotBeNull();

            field.Example.ShouldMatchStructure(com =>
                                               com.InlineText("void Something()\r\n{\r\n  return;\r\n}"));
        }
Пример #25
0
        public void ShouldHaveTypesInNamespaces()
        {
            var model = new DocumentModel(StubParser, StubEventAggregator);
            var members = new[]
            {
                Type<First>(@"<member name=""T:Example.First"" />"),  
                Type<Second>(@"<member name=""T:Example.Second"" />"),  
                Type<DeepFirst>(@"<member name=""T:Example.Deep.DeepFirst"" />")
            };
            var namespaces = model.Create(members);

            namespaces[0].Types
                .ShouldContain(x => x.IsIdentifiedBy(Identifier.FromType(typeof(First))))
                .ShouldContain(x => x.IsIdentifiedBy(Identifier.FromType(typeof(Second))));
            namespaces[1].Types
                .ShouldContain(x => x.IsIdentifiedBy(Identifier.FromType(typeof(DeepFirst))));
        }
Пример #26
0
        public void ShouldHaveMethodsInTypes()
        {
            var model = new DocumentModel(StubParser, StubEventAggregator);
            var members = new IDocumentationMember[]
            {
                Type<Second>(@"<member name=""T:Example.Second"" />"),
                Method<Second>(@"<member name=""M:Example.Second.SecondMethod"" />", x => x.SecondMethod()),
                Method<Second>(@"<member name=""M:Example.Second.SecondMethod2(System.String,System.Int32)"" />", x => x.SecondMethod2(null, 0))
            };
            var namespaces = model.Create(members);
            var method = Method<Second>(x => x.SecondMethod());
            var method2 = Method<Second>(x => x.SecondMethod2(null, 0));

            namespaces[0].Types[0].Methods
                .ShouldContain(x => x.IsIdentifiedBy(Identifier.FromMethod(method, typeof(Second))))
                .ShouldContain(x => x.IsIdentifiedBy(Identifier.FromMethod(method2, typeof(Second))));
        }
Пример #27
0
        public void ShouldHaveParametersInMethods()
        {
            var model = new DocumentModel(StubParser, StubEventAggregator);
            var members = new IDocumentationMember[]
            {
                Type<First>(@"<member name=""T:Example.First"" />"),
                Method<Second>(@"<member name=""M:Example.Second.SecondMethod2(System.String,Example.First)"" />", x => x.SecondMethod3(null, null))
            };
            var namespaces = model.Create(members);

            var method = namespaces[0].Types[1].Methods[0];

            method.Parameters.Count.ShouldEqual(2);
            method.Parameters[0].Name.ShouldEqual("one");
            method.Parameters[0].Reference.IsExternal.ShouldBeTrue();
            method.Parameters[1].Name.ShouldEqual("two");
            method.Parameters[1].Reference.ShouldBeOfType<DeclaredType>();
        }
Пример #28
0
        public void ShouldHaveSummaryForMethodParameter()
        {
            var model = new DocumentModel(new CommentParser(), StubEventAggregator);
            var members = new[]
            {
                Method<Second>(@"
                <member name=""M:Example.Second.SecondMethod2(System.String,System.Int32)"">
                  <param name=""one"">First parameter</param>
                  <param name=""two"">Second parameter</param>
                </member>", x => x.SecondMethod2(null, 0))
            };
            var namespaces = model.Create(members);
            var comment1 = new List<IComment>(namespaces[0].Types[0].Methods[0].Parameters[0].Summary.Children);
            var comment2 = new List<IComment>(namespaces[0].Types[0].Methods[0].Parameters[1].Summary.Children);

            comment1.Count.ShouldEqual(1);
            ((InlineText)comment1[0]).Text.ShouldEqual("First parameter");
            comment2.Count.ShouldEqual(1);
            ((InlineText)comment2[0]).Text.ShouldEqual("Second parameter");
        }
Пример #29
0
        public void ShouldHaveSummaryForProperties()
        {
            var model = new DocumentModel(RealParser, StubEventAggregator);
            var members = new IDocumentationMember[]
            {
                Type<Second>(@"<member name=""T:Example.Second"" />"),
                Property<Second>(@"<member name=""P:Example.Second.SecondProperty""><summary>Second property</summary></member>", x => x.SecondProperty),
            };
            var namespaces = model.Create(members);
            var comment = new List<IComment>(namespaces[0].Types[0].Properties[0].Summary.Children);

            comment.Count.ShouldEqual(1);
            ((InlineText)comment[0]).Text.ShouldEqual("Second property");
        }
Пример #30
0
        public void ShouldPassMethodParameterSummaryToContentParser()
        {
            var contentParser = MockRepository.GenerateMock<ICommentParser>();
            var model = new DocumentModel(contentParser, StubEventAggregator);
            var members = new[]
            {
                Method<Second>(@"
                <member name=""M:Example.Second.SecondMethod2(System.String,System.Int32)"">
                  <param name=""one"">First parameter</param>
                  <param name=""two"">Second parameter</param>
                </member>", x => x.SecondMethod2(null, 0))
            };

            contentParser.Stub(x => x.ParseNode(null))
                .IgnoreArguments()
                .Return(new List<IComment>());

            model.Create(members);

            contentParser.AssertWasCalled(x => x.ParseNode(members[0].Xml.ChildNodes[0]));
            contentParser.AssertWasCalled(x => x.ParseNode(members[0].Xml.ChildNodes[1]));
        }