예제 #1
0
        public void AddNewParagraph_WithParagraphTitle_ShouldSetHeaderBuilderToNewCreatedObject()
        {
            Mock <IPrintableMarkdownElementFactory> elementFactoryMock = new Mock <IPrintableMarkdownElementFactory>();
            Mock <IMarkdownParagraph> markdownParagraphMock            = new Mock <IMarkdownParagraph>();

            elementFactoryMock.Setup(f => f.CreateMarkdownContainer <IMarkdownParagraph>(It.IsAny <string>()))
            .Returns(markdownParagraphMock.Object);
            Mock <IMarkdownHeaderBuilder> headerBuilderMock = new Mock <IMarkdownHeaderBuilder>();

            MarkdownSite site = new MarkdownSite("Test", elementFactoryMock.Object, headerBuilderMock.Object);

            site.AddNewParagraph("Paragraph");

            markdownParagraphMock.Verify(p => p.SetHeaderBuilder(It.IsAny <IMarkdownHeaderBuilder>()));
        }
예제 #2
0
        public void AddNewParagraph_WithParagraphTitle_ShouldCloneTheHeaderBuilderOfTheCurrentObject()
        {
            Mock <IPrintableMarkdownElementFactory> elementFactoryMock = new Mock <IPrintableMarkdownElementFactory>();
            Mock <IMarkdownParagraph> markdownParagraphMock            = new Mock <IMarkdownParagraph>();

            elementFactoryMock.Setup(f => f.CreateMarkdownContainer <IMarkdownParagraph>(It.IsAny <string>()))
            .Returns(markdownParagraphMock.Object);
            Mock <IMarkdownHeaderBuilder> headerBuilderMock = new Mock <IMarkdownHeaderBuilder>();

            MarkdownSite site = new MarkdownSite("Test", elementFactoryMock.Object, headerBuilderMock.Object);

            site.AddNewParagraph("Paragraph");

            headerBuilderMock.Verify(hb => hb.Clone(), Times.Exactly(1));
        }
예제 #3
0
        public void AddNewParagraph_WithParagraphTitle_ShouldCallFactoryForCreateANewParagraphWithTheGivenTitle()
        {
            Mock <IPrintableMarkdownElementFactory> elementFactoryMock = new Mock <IPrintableMarkdownElementFactory>();
            Mock <IMarkdownParagraph> markdownParagraphMock            = new Mock <IMarkdownParagraph>();

            elementFactoryMock.Setup(f => f.CreateMarkdownContainer <IMarkdownParagraph>(It.IsAny <string>()))
            .Returns(markdownParagraphMock.Object);
            Mock <IMarkdownHeaderBuilder> headerBuilderMock = new Mock <IMarkdownHeaderBuilder>();

            MarkdownSite site = new MarkdownSite("Test", elementFactoryMock.Object, headerBuilderMock.Object);

            site.AddNewParagraph("Paragraph");

            elementFactoryMock.Verify(f => f.CreateMarkdownContainer <IMarkdownParagraph>(
                                          It.Is((string s) => s.Equals("Paragraph"))), Times.Exactly(1));
        }