示例#1
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 []
            {
                Common.Documents.Metadata.Create("SourceFileName", input)
            }) };
            FileName fileName = new FileName();

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

            // Then
            Assert.AreEqual(output, documents.First()["WriteFileName"]);
        }
示例#2
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 []
            {
                Common.Documents.Metadata.Create("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()["WriteFileName"]);
        }
示例#3
0
        public void FileNameShouldBeLowercase()
        {
            // Given
            string input = "FileName With MiXeD CapS";
            string output = "filename-with-mixed-caps";

            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 []
            {
                Common.Documents.Metadata.Create("SourceFileName", input)
            }) };
            FileName fileName = new FileName();

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

            // Then
            Assert.AreEqual(output, documents.First()["WriteFileName"]);
        }
示例#4
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 []
            {
                Common.Documents.Metadata.Create("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()["WriteFileName"]);
        }
示例#5
0
        public void IgnoresNullOrWhiteSpaceStrings(string input)
        {
            // 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 []
            {
                Common.Documents.Metadata.Create("SourceFileName", input)
            }) };
            FileName fileName = new FileName();

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

            // Then
            Assert.IsFalse(documents.First().ContainsKey("WriteFileName"));
        }