Example #1
0
        public void ShouldGetTagNamesForCorrespondingToMarkupFromStream(string documentPath, int tagsNumber)
        {
            // Arrange
            var escapedBeginMarkup = @"\|\{";
            var escapedEndMarkup   = @"\}\|";
            var expectedTags       = new List <string>()
            {
                "Title",
                "Subtitle"
            };
            IEnumerable <string> actualTagsToReplace;

            // Act
            using (var stream = File.Open(documentPath, FileMode.Open))
            {
                using (var document = new OpenXmlDocument(stream))
                {
                    actualTagsToReplace = document.GetTagNames(escapedBeginMarkup, escapedEndMarkup);
                }
            }

            // Assert
            Assert.NotEmpty(actualTagsToReplace);
            Assert.Equal(tagsNumber, actualTagsToReplace.Count());
            Assert.All(expectedTags, expectedTag => Assert.Contains(expectedTag, actualTagsToReplace));
        }
Example #2
0
        public void ShouldGetTagNamesFromFilePath(string documentPath, int tagsNumber)
        {
            // Arrange
            var expectedTags = new List <string>()
            {
                "Title",
                "Subtitle"
            };
            IEnumerable <string> actualTagsToReplace;

            // Act
            using (var document = new OpenXmlDocument(documentPath))
            {
                actualTagsToReplace = document.GetTagNames();
            }

            // Assert
            Assert.NotEmpty(actualTagsToReplace);
            Assert.Equal(tagsNumber, actualTagsToReplace.Count());
            Assert.All(expectedTags, expectedTag => Assert.Contains(expectedTag, actualTagsToReplace));
        }