Example #1
0
        public void When_InvalidVariables_Then_NoSubstitution()
        {
            const string test            = "Once upon <%foobar> a time";
            var          variableContent = new VariableContent(test);
            var          file            = new UploadFile(@"c:\foobar");

            Assert.That(variableContent.ExpandedContent(file), Is.EqualTo(test));
        }
Example #2
0
        public void When_NegativeExpansionIndexNotInRange_Then_EmptyStringIsSubstituted()
        {
            var test = "<%-4>";
            var file = new UploadFile(@"c:\a\b.foo");

            var variableContent = new VariableContent(test);

            Assert.That(variableContent.ExpandedContent(file), Is.Empty);
        }
Example #3
0
        public void When_NegativeExpansionIndexNotValidInteger_Then_SubstitutionNatDone()
        {
            var test = "Once upon<%-999999999999999999999999999999999999999999999999999999999999> a time";
            var file = new UploadFile("foobar");

            var variableContent = new VariableContent(test);

            Assert.That(variableContent.ExpandedContent(file), Is.EqualTo(test));
        }
Example #4
0
        public void When_FilenameExpansion_Then_FilenameWithouExtensionIsSubstituted()
        {
            var test = "<%filename>";
            var file = new UploadFile(@"c:\foo\foobar.png");

            var variableContent = new VariableContent(test);

            Assert.That(variableContent.ExpandedContent(file), Is.EqualTo("foobar"));
        }
Example #5
0
        public void When_ExpansionIndexIsZeroe_Then_FullPathIsSubstituted()
        {
            const string fileName = @"c:\a\b.foo";
            var          test     = "<%0>";
            var          file     = new UploadFile(fileName);

            var variableContent = new VariableContent(test);

            Assert.That(variableContent.ExpandedContent(file), Is.EqualTo(fileName));
        }
Example #6
0
        public void When_NegativeExpansionse_Then_ExpansionsDone()
        {
            var test     = "once <%-1> upon <%-2> a <%-3> z <%-4>";
            var file     = new UploadFile(@"c:\three\two\one.foo");
            var expected = "once one.foo upon two a three z c:";

            var variableContent = new VariableContent(test);

            Assert.That(variableContent.ExpandedContent(file), Is.EqualTo(expected));
        }
Example #7
0
        public void When_Expansionse_Then_ExpansionsDone()
        {
            var test     = "once <%1> upon <%2> a <%3> z <%4>";
            var expected = "once c: upon two a three z four.foo";
            var file     = new UploadFile(@"c:\two\three\four.foo");

            var variableContent = new VariableContent(test);

            Assert.That(variableContent.ExpandedContent(file), Is.EqualTo(expected));
        }
Example #8
0
        private static void GetVariableContents(string groupName, List <IVariableContent> _viariableContent, IEnumerable <LabelObject> objects)
        {
            foreach (var obj in objects)
            {
                foreach (var content in obj.Contents)
                {
                    if (content.ContentType == "Variable")
                    {
                        IVariableContent vdl = new VariableContent();

                        vdl.GroupName     = groupName;
                        vdl.ObjectName    = obj.ObjectName;
                        vdl.ContentName   = content.ContentName;
                        vdl.ContentValue  = content.ContentValue;
                        vdl.OutputControl = -1;
                        vdl.DataField     = -1;

                        _viariableContent.Add(vdl);
                    }
                }
            }
        }
Example #9
0
        public void When_NoVariables_Then_HasVariablesIsFalse()
        {
            var variableContent = new VariableContent("Once upon a time");

            Assert.That(variableContent.HasVariables, Is.False);
        }
Example #10
0
        public void When_NegativeVariables_Then_HasVariablesIsTrue()
        {
            var variableContent = new VariableContent("<%-4>");

            Assert.That(variableContent.HasVariables, Is.True);
        }
 public SplitLiteralContent(VariableContent content) : base(content.RenderContent())
 {
     Content = content;
 }