Exemple #1
0
        public void WithAllowedCharactersDoesNotReplaceProvidedCharacters()
        {
            // Given
            string input  = "this-is-a-.net-tag";
            string output = "this-is-a-.net-tag";

            Engine engine = new Engine();

            engine.Trace.AddListener(new TestTraceListener());
            Pipeline          pipeline = new Pipeline("Pipeline", engine, null);
            IExecutionContext context  = new ExecutionContext(engine, pipeline);

            IDocument[] inputs = { new Document(engine, pipeline).Clone(new []
                {
                    new MetadataItem(Keys.SourceFileName, input)
                }) };
            FileName    fileName = new FileName();

            // When
            fileName = fileName.WithAllowedCharacters(new string[] { "-", "." });
            IEnumerable <IDocument> documents = fileName.Execute(inputs, context);

            // Then
            Assert.AreEqual(output, documents.First()[Keys.WriteFileName]);
        }
Exemple #2
0
            public void TrimWhitespace()
            {
                // Given
                string input  = "   myfile.html   ";
                string output = "myfile.html";

                Engine            engine   = new Engine();
                Pipeline          pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context  = new ExecutionContext(engine, pipeline);

                IDocument[] inputs =
                {
                    context.GetDocument(new MetadataItems
                    {
                        new MetadataItem("MyKey", input)
                    })
                };
                FileName fileName = new FileName("MyKey");

                // When
                IEnumerable <IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual(output, documents.First().FilePath(Keys.WriteFileName).FullPath);
            }
            public void WithAllowedCharactersDoesNotReplaceProvidedCharacters()
            {
                // Given
                const string input  = "this-is-a-.net-tag";
                const string output = "this-is-a-.net-tag";

                Engine            engine   = new Engine();
                ExecutionPipeline pipeline = new ExecutionPipeline("Pipeline", (IModuleList)null);
                IExecutionContext context  = new ExecutionContext(engine, Guid.Empty, pipeline);

                IDocument[] inputs =
                {
                    context.GetDocument(new MetadataItems
                    {
                        new MetadataItem(Keys.SourceFileName, new FilePath(input))
                    })
                };
                FileName fileName = new FileName();

                // When
                fileName = fileName.WithAllowedCharacters(new string[] { "-" });
                IEnumerable <IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual(output, documents.First().FilePath(Keys.WriteFileName).FullPath);
            }
            public void FileNameShouldBeLowercase()
            {
                // Given
                const string input  = "FileName With MiXeD CapS";
                const string output = "filename-with-mixed-caps";

                Engine            engine   = new Engine();
                ExecutionPipeline pipeline = new ExecutionPipeline("Pipeline", (IModuleList)null);
                IExecutionContext context  = new ExecutionContext(engine, Guid.Empty, pipeline);

                IDocument[] inputs =
                {
                    context.GetDocument(new MetadataItems
                    {
                        new MetadataItem(Keys.SourceFileName, new FilePath(input))
                    })
                };
                FileName fileName = new FileName();

                // When
                IEnumerable <IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual(output, documents.First().FilePath(Keys.WriteFileName).FullPath);
            }
            public void PreservesExtension()
            {
                // Given
                const string input  = "myfile.html";
                const string output = "myfile.html";

                Engine            engine   = new Engine();
                ExecutionPipeline pipeline = new ExecutionPipeline("Pipeline", (IModuleList)null);
                IExecutionContext context  = new ExecutionContext(engine, Guid.Empty, pipeline);

                IDocument[] inputs =
                {
                    context.GetDocument(new MetadataItems
                    {
                        new MetadataItem("MyKey", input)
                    })
                };
                FileName fileName = new FileName("MyKey");

                // When
                IEnumerable <IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual(output, documents.First().FilePath(Keys.WriteFileName).FullPath);
            }
            public void FileNameIsConvertedCorrectlyWithReservedChar(string character)
            {
                // Given
                Engine            engine            = new Engine();
                ExecutionPipeline pipeline          = new ExecutionPipeline("Pipeline", (IModuleList)null);
                IExecutionContext context           = new ExecutionContext(engine, Guid.Empty, pipeline);
                string            manyCharactersWow = new string(character[0], 10);

                IDocument[] inputs =
                {
                    context.GetDocument(new MetadataItems
                    {
                        new MetadataItem(
                            Keys.SourceFileName,
                            string.Format("testing {0} some of {0} these {0}", manyCharactersWow))
                    })
                };
                FileName fileName = new FileName();

                // When
                IEnumerable <IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual("testing-some-of-these-", documents.First().FilePath(Keys.WriteFileName).FullPath);
            }
Exemple #7
0
            public void FileNameIsConvertedCorrectly(string input, string output)
            {
                // Given
                Engine            engine   = new Engine();
                Pipeline          pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context  = new ExecutionContext(engine, pipeline);

                IDocument[] inputs = { context.GetDocument(new MetadataItems
                    {
                        new MetadataItem(Keys.SourceFileName, input)
                    }) };
                FileName    fileName = new FileName();

                // When
                IEnumerable <IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual(output, documents.First().FilePath(Keys.WriteFileName).FullPath);
            }
Exemple #8
0
            public void IgnoresNullOrWhiteSpaceStrings(string input)
            {
                // Given
                Engine            engine   = new Engine();
                Pipeline          pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context  = new ExecutionContext(engine, pipeline);

                IDocument[] inputs = { context.GetDocument(new MetadataItems
                    {
                        new MetadataItem(Keys.SourceFileName, input)
                    }) };
                FileName    fileName = new FileName();

                // When
                IEnumerable <IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.IsFalse(documents.First().ContainsKey(Keys.WriteFileName));
            }
Exemple #9
0
        public void FileNameIsConvertedCorrectly(string input, string output)
        {
            // Given
            Engine engine = new Engine();

            engine.Trace.AddListener(new TestTraceListener());
            Pipeline          pipeline = new Pipeline("Pipeline", engine, null);
            IExecutionContext context  = new ExecutionContext(engine, pipeline);

            IDocument[] inputs = { new Document(engine, pipeline).Clone(new []
                {
                    new MetadataItem(Keys.SourceFileName, input)
                }) };
            FileName    fileName = new FileName();

            // When
            IEnumerable <IDocument> documents = fileName.Execute(inputs, context);

            // Then
            Assert.AreEqual(output, documents.First()[Keys.WriteFileName]);
        }
Exemple #10
0
            public void FileNameShouldBeLowercase()
            {
                // Given
                string input  = "FileName With MiXeD CapS";
                string output = "filename-with-mixed-caps";

                Engine            engine   = new Engine();
                Pipeline          pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context  = new ExecutionContext(engine, pipeline);

                IDocument[] inputs = { context.GetDocument(new MetadataItems
                    {
                        new MetadataItem(Keys.SourceFileName, input)
                    }) };
                FileName    fileName = new FileName();

                // When
                IEnumerable <IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual(output, documents.First()[Keys.WriteFileName]);
            }
Exemple #11
0
            public void WithAllowedCharactersDoesNotReplaceDotAtEnd()
            {
                // Given
                string input  = "this-is-a-.";
                string output = "thisisa.";

                Engine            engine   = new Engine();
                Pipeline          pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context  = new ExecutionContext(engine, pipeline);

                IDocument[] inputs = { context.GetDocument(new MetadataItems
                    {
                        new MetadataItem(Keys.SourceFileName, new FilePath(input))
                    }) };
                FileName    fileName = new FileName();

                // When
                fileName = fileName.WithAllowedCharacters(new string[] { "." });
                IEnumerable <IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual(output, documents.First().FilePath(Keys.WriteFileName).FullPath);
            }
Exemple #12
0
        public void FileNameIsConvertedCorrectlyWithReservedChar(string character)
        {
            // Given
            Engine engine = new Engine();

            engine.Trace.AddListener(new TestTraceListener());
            Pipeline          pipeline          = new Pipeline("Pipeline", engine, null);
            IExecutionContext context           = new ExecutionContext(engine, pipeline);
            string            manyCharactersWow = new String(character[0], 10);

            IDocument[] inputs = { new Document(engine, pipeline).Clone(new []
                {
                    new MetadataItem(Keys.SourceFileName,
                                     string.Format("testing {0} some of {0} these {0}", manyCharactersWow))
                }) };
            FileName    fileName = new FileName();

            // When
            IEnumerable <IDocument> documents = fileName.Execute(inputs, context);

            // Then
            Assert.AreEqual("testing-some-of-these-", documents.First()[Keys.WriteFileName]);
        }