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>())); }
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)); }
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)); }