public void TryGetContextObject_ThrowsArgumentNullExceptionIfBlockProcessorIsNull() { // Arrange ContextObjectsService testSubject = CreateContextObjectsService(); // Act and assert ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => testSubject.TryGetContextObject(new object(), null, out object value)); }
public void TryGetContextObject_ThrowsArgumentNullExceptionIfKeyIsNull() { // Arrange ContextObjectsService testSubject = CreateContextObjectsService(); // Act and assert ArgumentNullException result = Assert. Throws <ArgumentNullException>(() => testSubject.TryGetContextObject(null, MarkdigTypesFactory.CreateBlockProcessor(), out object value)); }
public void TryGetContextObjectsStore_ReturnsNullIfNoGlobalParserIsAContextObjectsStore() { // Arrange BlockProcessor dummyBlockProcessor = MarkdigTypesFactory.CreateBlockProcessor(); // Several global parsers registered by default ContextObjectsService testSubject = CreateContextObjectsService(); // Act ContextObjectsStore result = testSubject.TryGetContextObjectsStore(dummyBlockProcessor); // Assert Assert.Null(result); }
public void TryGetContextObjectsStore_ReturnsNullIfThereAreNoGlobalParsers() { // Arrange BlockProcessor dummyBlockProcessor = MarkdigTypesFactory.CreateBlockProcessor(blockParsers: new BlockParserList(new BlockParser[0])); ContextObjectsService testSubject = CreateContextObjectsService(); // Act ContextObjectsStore result = testSubject.TryGetContextObjectsStore(dummyBlockProcessor); // Assert Assert.Null(result); }
public void TryGetContextObjectsStore_ReturnsContextObjectsStoreIfItExists() { // Arrange var dummyContextObjectsStore = new ContextObjectsStore(); BlockProcessor dummyBlockProcessor = MarkdigTypesFactory.CreateBlockProcessor(blockParsers: new BlockParserList(new BlockParser[] { dummyContextObjectsStore })); ContextObjectsService testSubject = CreateContextObjectsService(); // Act ContextObjectsStore result = testSubject.TryGetContextObjectsStore(dummyBlockProcessor); // Assert _mockRepository.VerifyAll(); Assert.Same(dummyContextObjectsStore, result); }
public void TryAddContextObject_ReturnsTrueAndAddsContextObjectToMarkdownParserContextIfItsNotNull() { // Arrange var dummyKey = new object(); var dummyValue = new object(); var dummyMarkdownParserContext = new MarkdownParserContext(); BlockProcessor dummyBlockProcessor = MarkdigTypesFactory.CreateBlockProcessor(markdownParserContext: dummyMarkdownParserContext); ContextObjectsService testSubject = CreateContextObjectsService(); // Act bool result = testSubject.TryAddContextObject(dummyKey, dummyValue, dummyBlockProcessor); // Assert Assert.True(result); Assert.Single(dummyMarkdownParserContext.Properties); Assert.Same(dummyValue, dummyMarkdownParserContext.Properties[dummyKey]); }
public void TryGetContextObject_ReturnsTrueAndContextObjectIfItExistsInBlockProcessorContext() { // Arrange var dummyKey = new object(); var dummyValue = new object(); var dummyMarkdownParserContext = new MarkdownParserContext(); dummyMarkdownParserContext.Properties.Add(dummyKey, dummyValue); BlockProcessor dummyBlockProcessor = MarkdigTypesFactory.CreateBlockProcessor(markdownParserContext: dummyMarkdownParserContext); ContextObjectsService testSubject = CreateContextObjectsService(); // Act bool result = testSubject.TryGetContextObject(dummyKey, dummyBlockProcessor, out object resultValue); // Assert Assert.True(result); Assert.Same(dummyValue, resultValue); }