コード例 #1
0
        public void TryGetContextObject_ThrowsArgumentNullExceptionIfBlockProcessorIsNull()
        {
            // Arrange
            ContextObjectsService testSubject = CreateContextObjectsService();

            // Act and assert
            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => testSubject.TryGetContextObject(new object(), null, out object value));
        }
コード例 #2
0
        public void TryGetContextObject_ThrowsArgumentNullExceptionIfKeyIsNull()
        {
            // Arrange
            ContextObjectsService testSubject = CreateContextObjectsService();

            // Act and assert
            ArgumentNullException result = Assert.
                                           Throws <ArgumentNullException>(() => testSubject.TryGetContextObject(null, MarkdigTypesFactory.CreateBlockProcessor(), out object value));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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]);
        }
コード例 #7
0
        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);
        }