Пример #1
0
        public void CopyTransform1()
        {
            const string xml = @"
<add name='TestProcess'>
    <entities>
        <add name='TestData'>
            <rows>
                <add Field1='1' Field2='2' />
            </rows>
            <fields>
                <add name='Field1' type='int'/>
                <add name='Field2' type='int'/>
            </fields>
            <calculated-fields>
                <add name='Field3' type='int' t='copy(Field2)' />
            </calculated-fields>
        </add>
    </entities>
</add>";


            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);

            var output = controller.Read().ToArray();

            Assert.AreEqual(2, output[0][composer.Process.Entities.First().CalculatedFields.First()]);
        }
Пример #2
0
        public void RazorTransformAdd()
        {
            const string xml = @"
<add name='TestProcess'>
    <entities>
        <add name='TestData'>
            <rows>
                <add Field1='1' Field2='2' Field3='3' />
            </rows>
            <fields>
                <add name='Field1' />
                <add name='Field2' />
                <add name='Field3' />
            </fields>
            <calculated-fields>
                <add name='Add' t='copy(Field1,Field2,Field3).razor(@{var x = Model.Field1 + Model.Field2 + Model.Field3;}@x)' />
                <add name='Format' t='copy(Field1,Field2,Field3).razor(@{var x = string.Format(&quot;{0}-{1}-{2}&quot;\,Model.Field1\,Model.Field2\,Model.Field3);}@x)' />
            </calculated-fields>
        </add>
    </entities>
</add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);

            var output = controller.Read().ToArray();

            Assert.AreEqual("123", output[0][composer.Process.Entities.First().CalculatedFields.First()]);
            Assert.AreEqual("1-2-3", output[0][composer.Process.Entities.First().CalculatedFields.Last()]);
        }
Пример #3
0
        public void FormatTransformer()
        {
            const string xml = @"
    <add name='TestProcess'>
      <entities>
        <add name='TestData'>
          <rows>
            <add Field1='1' Field2='2' Field3='3' />
          </rows>
          <fields>
            <add name='Field1' />
            <add name='Field2' />
            <add name='Field3' />
          </fields>
          <calculated-fields>
            <add name='Format' t='copy(Field1,Field2,Field3).format({0}-{1}+{2} ).trim()' />
          </calculated-fields>
        </add>
      </entities>
    </add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);
            var output     = controller.Read().ToArray();

            Assert.AreEqual("1-2+3", output[0][composer.Process.Entities.First().CalculatedFields.First()]);
        }
        public void DatePart1()
        {
            const string xml = @"
    <add name='TestProcess'>
      <entities>
        <add name='TestData' >
          <rows>
            <add StartDate='2016-06-01' EndDate='2016-08-01' />
          </rows>
          <fields>
            <add name='StartDate' type='datetime' />
            <add name='EndDate' type='datetime' />
          </fields>
          <calculated-fields>
            <add name='StartYear' type='int' t='copy(StartDate).datepart(year)' />
            <add name='EndYear' type='int' t='copy(EndDate).datepart(year)' />
            <add name='StartWeek' type='int' t='copy(StartDate).datepart(weekofyear)' />
            <add name='EndWeek' type='int' t='copy(EndDate).datepart(weekofyear)' />
          </calculated-fields>
        </add>
      </entities>
    </add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);
            var output     = controller.Read().ToArray();

            var cf = composer.Process.Entities.First().CalculatedFields.ToArray();

            Assert.AreEqual(2016, output[0][cf[0]]);
            Assert.AreEqual(2016, output[0][cf[1]]);
            Assert.AreEqual(23, output[0][cf[2]]);
            Assert.AreEqual(32, output[0][cf[3]]);
        }
Пример #5
0
        public void Read1()
        {
            const string xml = @"
<add name='Directory' mode='default'>
    <connections>
        <add name='input' provider='directory' folder='c:\temp' />
        <add name='output' provider='console' />
    </connections>
    <entities>
        <add name='Files'>
            <fields>
                <add name='DirectoryName' length='256' />
                <add name='FullName' length='256' />
                <add name='LastWriteTimeUtc' type='datetime' />
            </fields>
        </add>
    </entities>
</add>";


            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml, LogLevel.Debug);
            var process    = composer.Process;

            controller.Execute();
            controller.Dispose();

            var entity = process.Entities.First();

            Assert.AreEqual(115, entity.Rows.Count, "Most people keep about 115 files in there.");
        }
Пример #6
0
        public void Match()
        {
            const string xml = @"
    <add name='TestProcess'>
      <entities>
        <add name='TestData' pipeline='linq'>
          <rows>
            <add Field1='Local/3114@tolocalext-fc5d,1' />
            <add Field1='SIP/Generic-Vitel_Outbound-0002b45a' />
          </rows>
          <fields>
            <add name='Field1' />
          </fields>
          <calculated-fields>
            <add name='MatchField1' t='copy(Field1).match(3[0-9]{3}(?=@))' default='None' />
            <add name='MatchAnyField' t='copy(Field1,Field2).match(3[0-9]{3}(?=@))' default='None' />
          </calculated-fields>
        </add>
      </entities>
    </add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);
            var output     = controller.Read().ToArray();

            var cf = composer.Process.Entities.First().CalculatedFields.ToArray();

            Assert.AreEqual("3114", output[0][cf[0]]);
            Assert.AreEqual("3114", output[0][cf[1]]);
            Assert.AreEqual("None", output[1][cf[0]]);
            Assert.AreEqual("None", output[1][cf[1]]);
        }
Пример #7
0
        public void Tag()
        {
            const string xml = @"
    <add name='TestProcess'>
      <entities>
        <add name='TestData' pipeline='linq'>
          <rows>
            <add Field1='1' />
            <add Field1='5' />
          </rows>
          <fields>
            <add name='Field1' />
          </fields>
          <calculated-fields>
            <add name='span' t='copy(Field1).tag(span)' />
            <add name='div' t='copy(Field1).tag(div,class:fun)' />
          </calculated-fields>
        </add>
      </entities>
    </add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);
            var output     = controller.Read().ToArray();

            var cf = composer.Process.Entities.First().CalculatedFields.ToArray();

            Assert.AreEqual("<span>1</span>", output[0][cf[0]]);
            Assert.AreEqual("<div class=\"fun\">1</div>", output[0][cf[1]]);
            Assert.AreEqual("<span>5</span>", output[1][cf[0]]);
            Assert.AreEqual("<div class=\"fun\">5</div>", output[1][cf[1]]);
        }
        public void FormatXmlTransform1()
        {
            const string xml = @"
<add name='TestProcess'>
    <entities>
        <add name='TestData'>
            <rows>
                <add xml='<stuff value=""1""><things><add item=""1""/><add item=""2""/></things></stuff>' />
            </rows>
            <fields>
                <add name='xml' length='128' />
            </fields>
            <calculated-fields>
                <add name='formatted' length='128' t='copy(xml).formatXml()' />
            </calculated-fields>
        </add>
    </entities>
</add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);

            var output = controller.Read().ToArray();

            Assert.AreEqual(@"<stuff value=""1"">
  <things>
    <add item=""1"" />
    <add item=""2"" />
  </things>
</stuff>", output[0][composer.Process.Entities.First().CalculatedFields.First()]);
        }
Пример #9
0
        public void VelocityTransformAdd()
        {
            const string xml = @"
<add name='TestProcess'>
    <entities>
        <add name='TestData'>
            <rows>
                <add Field1='1' Field2='2' Field3='3' />
            </rows>
            <fields>
                <add name='Field1' />
                <add name='Field2' />
                <add name='Field3' />
            </fields>
            <calculated-fields>
                <add name='Add' t='copy(Field1,Field2,Field3).velocity(#set($x = $Field1)$x$Field2$Field3)' />
            </calculated-fields>
        </add>
    </entities>
</add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);

            var output = controller.Read().ToArray();

            Assert.AreEqual("123", output[0][composer.Process.Entities.First().CalculatedFields.First()]);
        }
Пример #10
0
        public void ExcludeTransform()
        {
            const string xml = @"
<add name='TestProcess'>
    <entities>
        <add name='TestData'>
            <rows>
                <add Field1='1' />
                <add Field1='2' />
            </rows>
            <fields>
                <add name='Field1' type='int' t='exclude(1)'/>
            </fields>
        </add>
    </entities>
</add>";


            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);

            var output = controller.Read().ToArray();

            Assert.AreEqual(1, output.Length);
            Assert.AreEqual(2, output[0][composer.Process.Entities.First().Fields.First(f => !f.System)]);
        }
Пример #11
0
        public void RunDelta()
        {
            var composer   = new CompositionRoot();
            var controller = composer.Compose(Cfg, LogLevel.Info);

            controller.Execute();
        }
Пример #12
0
        public void DoMath()
        {
            const string xml = @"
    <add name='TestProcess'>
      <entities>
        <add name='TestData' pipeline='linq'>
          <rows>
            <add Field1='10.6954' Field2='129.992' />
          </rows>
          <fields>
            <add name='Field1' type='double' />
            <add name='Field2' type='decimal' />
          </fields>
          <calculated-fields>
            <add name='Ceiling' type='double' t='copy(Field1).ceiling()' />
            <add name='Floor' type='double' t='copy(Field1).floor()' />
            <add name='Round' type='decimal' t='copy(Field2).round(1)' />
            <add name='Abs' type='decimal' t='copy(Field2).abs()' />
          </calculated-fields>
        </add>
      </entities>
    </add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);
            var output     = controller.Read().ToArray();

            var cf  = composer.Process.Entities.First().CalculatedFields.ToArray();
            var row = output.First();

            Assert.AreEqual(11, row[cf[0]]);
            Assert.AreEqual(10, row[cf[1]]);
            Assert.AreEqual(130.00d, row[cf[2]]);
            Assert.AreEqual(129.992, row[cf[3]]);
        }
Пример #13
0
        public void EqualsValidator()
        {
            var xml = @"
    <add name='TestProcess'>
      <entities>
        <add name='TestData'>
          <rows>
            <add Field1='11' Field2='12' Field3='13' />
            <add Field1='11' Field2='11' Field3='11' />
          </rows>
          <fields>
            <add name='Field1' />
            <add name='Field2' />
            <add name='Field3' />
          </fields>
          <calculated-fields>
            <add name='AreEqual' type='bool' t='copy(Field1,Field2,Field2).equal()' />
          </calculated-fields>
        </add>
      </entities>
    </add>
            ".Replace('\'', '"');

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);

            var output  = controller.Read().ToArray();
            var process = composer.Process;

            Assert.AreEqual(false, output[0][process.Entities.First().CalculatedFields.First(cf => cf.Name == "AreEqual")]);
            Assert.AreEqual(true, output[1][process.Entities.First().CalculatedFields.First(cf => cf.Name == "AreEqual")]);
        }
Пример #14
0
        public void In()
        {
            const string xml = @"
    <add name='TestProcess'>
      <entities>
        <add name='TestData' pipeline='linq'>
          <rows>
            <add Field1='1' />
            <add Field1='5' />
          </rows>
          <fields>
            <add name='Field1' />
          </fields>
          <calculated-fields>
            <add name='In123' type='bool' t='copy(Field1).in(1,2,3)' />
            <add name='In456' type='bool' t='copy(Field1).in(4,5,6)' />
          </calculated-fields>
        </add>
      </entities>
    </add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);
            var output     = controller.Read().ToArray();

            var cf = composer.Process.Entities.First().CalculatedFields.ToArray();

            Assert.AreEqual(true, output[0][cf[0]]);
            Assert.AreEqual(false, output[0][cf[1]]);
            Assert.AreEqual(false, output[1][cf[0]]);
            Assert.AreEqual(true, output[1][cf[1]]);
        }
Пример #15
0
        public void ConfurationIsGood()
        {
            var composer   = new CompositionRoot();
            var controller = composer.Compose(@"Files\PersonAndPet.xml");

            Assert.AreEqual(0, composer.Process.Errors().Count());
            Assert.AreEqual(1, composer.Process.Warnings().Count());
        }
Пример #16
0
        public void FromLengths()
        {
            const string xml = @"
    <add name='TestProcess'>
      <entities>
        <add name='TestData'>
          <rows>
            <add line='122333444455555666666' />
            <add line='111111222223333444556' />
          </rows>
          <fields>
            <add name='line'>
                <transforms>
                    <add method='fromlengths'>
                        <fields>
                            <add name='f1' length='1' />
                            <add name='f2' length='2' />
                            <add name='f3' length='3' type='int' />
                            <add name='f4' length='4' />
                            <add name='f5' length='5' />
                            <add name='f6' length='6' />
                        </fields>
                    </add>
                </transforms>
            </add>
          </fields>
        </add>
      </entities>
    </add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);
            var output     = controller.Read().ToArray();

            var cf = composer.Process.Entities.First().CalculatedFields.ToArray();

            var first = output[0];

            Assert.AreEqual("1", first[cf[0]]);
            Assert.AreEqual("22", first[cf[1]]);
            Assert.AreEqual(333, first[cf[2]]);
            Assert.AreEqual("4444", first[cf[3]]);
            Assert.AreEqual("55555", first[cf[4]]);
            Assert.AreEqual("666666", first[cf[5]]);

            var second = output[1];

            Assert.AreEqual("1", second[cf[0]]);
            Assert.AreEqual("11", second[cf[1]]);
            Assert.AreEqual(111, second[cf[2]]);
            Assert.AreEqual("2222", second[cf[3]]);
            Assert.AreEqual("23333", second[cf[4]]);
            Assert.AreEqual("444556", second[cf[5]]);
        }
Пример #17
0
        public void FileStuff()
        {
            const string xml = @"
    <add name='TestProcess'>
      <connections>
        <add name='input' provider='internal' file='c:\temp.txt' port='6' />
        <add name='other' provider='internal' file='\\server\projects\ETL\2016-04-24.txt' />
      </connections>
      <entities>
        <add name='TestData'>
          <rows>
            <add Field1='1' Field2='2' Field3='3' />
          </rows>
          <fields>
            <add name='Field1' />
            <add name='Field2' />
            <add name='Field3' />
          </fields>
          <calculated-fields>
            <add name='File' type='string' t='connection(input,File)' />
            <add name='Port' type='int' t='connection(input,Port)' />            
            <add name='FileName' length='128' t='connection(other,File).filename()' />
            <add name='FileNameNoExt' length='128' t='connection(other,File).filename(false)' />
            <add name='FileExt' length='128' t='connection(other,File).fileext()' />
            <add name='FilePath' length='128' t='connection(other,File).filepath()' />
          </calculated-fields>
        </add>
      </entities>
    </add>
            ";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);
            var output     = controller.Read().ToArray();

            var f             = composer.Process.Entities.First().CalculatedFields;
            var file          = f.First(cf => cf.Name == "File");
            var port          = f.First(cf => cf.Name == "Port");
            var fileName      = f.First(cf => cf.Name == "FileName");
            var fileNameNoExt = f.First(cf => cf.Name == "FileNameNoExt");
            var fileExt       = f.First(cf => cf.Name == "FileExt");
            var filePath      = f.First(cf => cf.Name == "FilePath");

            Assert.AreEqual(@"c:\temp.txt", output[0][file]);
            Assert.AreEqual(6, output[0][port]);
            Assert.AreEqual(@"2016-04-24.txt", output[0][fileName]);
            Assert.AreEqual(@"2016-04-24", output[0][fileNameNoExt]);
            Assert.AreEqual(@".txt", output[0][fileExt]);
            Assert.AreEqual(@"\\server\projects\ETL\2016-04-24.txt", output[0][filePath]);
        }
Пример #18
0
        public void ConditionalFormat()
        {
            const string xml = @"
<add name='Test Conditional Format'>
    <entities>
        <add name='People'>
            <rows>
                <add First='Dale' Last='Newman' Gender='Male' />
                <add First='Owen' Last='Watson' Gender='Male' />
                <add First='Jeremy' Last='Christ' Gender='Male' />
                <add First='Kelly' Last='Jones' Gender='Female' />
            </rows>
            <fields>
                <add name='First' />
                <add name='Last' />
                <add name='Gender' />
            </fields>
            <calculated-fields>
                <add name='FullName' default='None'>
                    <transforms>
                        <add method='format' 
                            run-field='Gender'
                            run-operator='Equal'
                            run-value='Male'
                            format='{0} {1}'>
                            <parameters>
                                <add field='First' />
                                <add field='Last' />
                            </parameters>
                        </add>
                    </transforms>
                </add>
            </calculated-fields>
        </add>
    </entities>
</add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);

            var output = controller.Read().ToArray();
            var full   = composer.Process.Entities.First().CalculatedFields[0];

            Assert.AreEqual(4, output.Count());
            Assert.AreEqual("Dale Newman", output[0][full]);
            Assert.AreEqual("Owen Watson", output[1][full]);
            Assert.AreEqual("Jeremy Christ", output[2][full]);
            Assert.AreEqual("None", output[3][full]);
        }
Пример #19
0
        public void MapTransformAdd()
        {
            const string xml = @"
<add name='TestProcess'>

    <maps>
        <add name='Map'>
            <items>
                <add from='1' to='One' />
                <add from='2' to='Two' />
                <add from='3' parameter='Field3' />
            </items>
        </add>
    </maps>

    <entities>
        <add name='TestData'>
            <rows>
                <add Field1='1' Field3='^' />
                <add Field1='2' Field3='#' />
                <add Field1='3' Field3='$THREE$' />
                <add Field1='4' Field3='@' />
            </rows>
            <fields>
                <add name='Field1' />
                <add name='Field2' />
                <add name='Field3' />
            </fields>
            <calculated-fields>
                <add name='Map' t='copy(Field1).map(map)' default='None' />
            </calculated-fields>
        </add>
    </entities>

</add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);
            var field      = composer.Process.Entities.First().CalculatedFields.First();
            var output     = controller.Read().ToArray();

            Assert.AreEqual("One", output[0][field]);
            Assert.AreEqual("Two", output[1][field]);
            Assert.AreEqual("$THREE$", output[2][field]);
            Assert.AreEqual("None", output[3][field]);
        }
Пример #20
0
        public void CSharpTransformAdd()
        {
            // Problem is I am compiling code in advance,
            // but not remembering that there are actually two processes that run,
            // the entity processes,  and the calculated field process

            const string xml = @"
<add name='TestProcess' mode='default'>
    <entities>
        <add name='TestData'>
            <rows>
                <add Field1='1' Field2='2' Field3='3' />
                <add Field1='4' Field2='5' Field3='6' />
            </rows>
            <fields>
                <add name='Field1' />
                <add name='Field2' />
                <add name='Field3' />
            </fields>
            <calculated-fields>
                <add name='Add' t='copy(Field1,Field2,Field3).cs(Field1+Field2+Field3;)' />
                <add name='Format' t='copy(Field1,Field2,Field3).cs(string.Format(&quot;{0}-{1}-{2}&quot;,Field1,Field2,Field3);)' />
            </calculated-fields>
        </add>
    </entities>
</add>";


            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml, LogLevel.Debug);
            var process    = composer.Process;

            controller.Execute();
            controller.Dispose();

            var entity = process.Entities.First();

            var row1 = entity.Rows[0];
            var row2 = entity.Rows[1];

            Assert.AreEqual("123", row1["Add"]);
            Assert.AreEqual("1-2-3", row1["Format"]);

            Assert.AreEqual("456", row2["Add"]);
            Assert.AreEqual("4-5-6", row2["Format"]);
        }
Пример #21
0
        public void Validator()
        {
            const string xml = @"
    <add name='TestSignature'>
      <entities>
        <add name='TestData'>
          <rows>
            <add args='10,0' />
          </rows>
          <fields>
            <add name='args' length='128'>
                <transforms>
                    <add method='fromsplit' separator=','>
                        <fields>
                            <add name='TotalWidth' />
                            <add name='PaddingChar' />
                        </fields>
                    </add>
                </transforms>
            </add>
          </fields>
          <calculated-fields>
            <add name='length' type='int' t='copy(args).splitlength(\,)' />
            <add name='TotalWidthCheck' type='bool' t='copy(TotalWidth).is(int)' />
          </calculated-fields>
        </add>
      </entities>
    </add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);
            var process    = composer.Process;
            var output     = controller.Read().ToArray();

            var field = process.Entities.First().CalculatedFields.First(cf => cf.Name == "length");

            Assert.AreEqual(2, output[0][field]);

            foreach (var row in output)
            {
                Console.WriteLine(row);
            }
        }
Пример #22
0
        public void FieldsAreIndexed()
        {
            var composer = new CompositionRoot();

            composer.Compose(@"Files\PersonAndPet.xml");

            var pet    = composer.Process.Entities.First();
            var person = composer.Process.Entities.Last();

            // system fields
            Assert.AreEqual(0, pet.Fields[0].Index);
            Assert.AreEqual(1, pet.Fields[1].Index);
            Assert.AreEqual(2, pet.Fields[2].Index);
            Assert.AreEqual(3, pet.Fields[3].Index);

            // fields
            Assert.AreEqual(4, pet.Fields[4].Index);
            Assert.AreEqual(5, pet.Fields[5].Index);
            Assert.AreEqual(6, pet.Fields[6].Index);
            Assert.AreEqual(7, pet.Fields[7].Index);
            Assert.AreEqual(8, pet.Fields[8].Index);

            // calc fields produced from xml
            Assert.AreEqual(9, pet.CalculatedFields[0].Index);
            Assert.AreEqual(10, pet.CalculatedFields[1].Index);


            Assert.AreEqual("Id", person.Fields[4].Name);

            // system fields
            Assert.AreEqual(0, person.Fields[0].Index);
            Assert.AreEqual(1, person.Fields[1].Index);
            Assert.AreEqual(2, person.Fields[2].Index);
            Assert.AreEqual(3, person.Fields[3].Index);

            // fields
            Assert.AreEqual(4, person.Fields[4].Index);
            Assert.AreEqual(5, person.Fields[5].Index);
            Assert.AreEqual(6, person.Fields[6].Index);
            Assert.AreEqual(7, person.Fields[7].Index);

            Assert.AreEqual(8, person.CalculatedFields[0].Index);
        }
Пример #23
0
        public void Try1()
        {
            const string xml = @"
    <add name='name'>
      <entities>
        <add name='Employee'>
          <rows>
            <add EmpId='1' FirstName='John' LastName='Doe' JobId='1' />
            <add EmpId='2' FirstName='Jane' LastName='Doe' JobId='2' />
          </rows>
          <fields>
            <add name='EmpId' type='int' primary-key='true' />
            <add name='FirstName' />
            <add name='LastName' />
            <add name='JobId' type='int' />
          </fields>
          <calculated-fields>
            <add name='FullName' t='copy(FirstName,LastName).format({0} {1})' />
          </calculated-fields>
        </add>
        <add name='Job'>
            <rows>
                <add JobId='1' Title='Carpenter' />
                <add JobId='2' Title='Seamstress' />
            </rows>
            <fields>
                <add name='JobId' type='int' primary-key='true' />
                <add name='Title' />
            </fields>
        </add>
      </entities>
      <relationships>
        <add left-entity='Employee' left-field='JobId' right-entity='Job' right-field='JobId' />
      </relationships>
    </add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);
            var output     = controller.Read().ToArray();

            Assert.AreEqual(2, output.Length);
        }
Пример #24
0
        public void Try1()
        {
            const string xml = @"
    <add name='TestProcess'>
      <entities>
        <add name='TestData'>
          <rows>
            <add id='1' xml=""&lt;things&gt;&lt;add name='deez'/&gt;&lt;add name='nutz'/&gt;&lt;/things&gt;"" />
            <add id='2' xml=""&lt;things&gt;&lt;add name='got'/&gt;&lt;add name='eeee'/&gt;&lt;/things&gt;"" />
          </rows>
          <fields>
                <add name='id' type='int' />
                <add name='xml' length='max'>
                    <transforms>
                        <add method='fromxml' root='things' xml-mode='all'>
                            <fields>
                                <add name='name' node-type='attribute' />
                            </fields>
                        </add>
                    </transforms>
                </add>
            </fields>
        </add>
      </entities>
    </add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);
            var output     = controller.Read().ToArray();

            Assert.AreEqual(4, output.Length);

            var name = composer.Process.Entities.First().CalculatedFields.First();

            var first = output[0];

            Assert.AreEqual("deez", first[name]);

            var second = output[1];

            Assert.AreEqual("nutz", second[name]);
        }
Пример #25
0
        public void Test1()
        {
            const string xml        = @"<cfg>
    <processes>
        <add name='one' mode='init'>
            <connections>
                <add name='input' provider='solr' server='***change-me***' port='8080' path='solr' core='TimeCard' />
            </connections>
            <entities>
                <add name='TimeCard'>
                    <filter>
                        <add expression='fullnamesearch:christ' />
                    </filter>
                    <fields>
                        <add name='tflkey' alias='key' type='int' />
                        <add name='tflbatchid' alias='batchid' type='int' />
                        <add name='tfldeleted' alias='deleted' type='bool' />
                        <add name='tflhashcode' alias='hashcode' type='int' />
                        <add name='exportcode' />
                        <add name='weekending' />
                        <add name='costcode' />
                        <add name='jobcode' />
                        <add name='acct' />
                        <add name='sub' />
                        <add name='regularhours' type='decimal' />
                        <add name='overtimehours' type='decimal' />
                        <add name='worklocation' />
                        <add name='firstname' />
                        <add name='lastname' />
                    </fields>
                </add>
            </entities>
        </add>
    </processes>
</cfg>";
            var          composer   = new CompositionRoot();
            var          controller = composer.Compose(xml);
            var          rows       = controller.Read().ToArray();

            Assert.AreEqual(2, rows.Length);
        }
Пример #26
0
        public void DateDiff1()
        {
            var xml = @"
    <add name='TestProcess'>
      <entities>
        <add name='TestData' >
          <rows>
            <add StartDate='2016-06-01' EndDate='2016-08-01' />
          </rows>
          <fields>
            <add name='StartDate' type='datetime' />
            <add name='EndDate' type='datetime' />
          </fields>
          <calculated-fields>
            <add name='Years' type='int' t='copy(StartDate,EndDate).datediff(year)' />
            <add name='Days' type='int' t='copy(StartDate,EndDate).datediff(day)' />
            <add name='Minutes' type='int' t='copy(StartDate,EndDate).datediff(minute)' />
            <add name='Hours' type='double' t='copy(StartDate,EndDate).datediff(hour)' />
            <add name='MovingUtc' type='int' t='copy(EndDate).datediff(hour,UTC)' />
            <add name='MovingEst' type='int' t='copy(EndDate).datediff(hour,Eastern Standard Time)' />
          </calculated-fields>
        </add>
      </entities>
    </add>
            ".Replace('\'', '"');

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);
            var output     = controller.Read().ToArray();

            var cf = composer.Process.Entities.First().CalculatedFields.ToArray();

            Assert.AreEqual(0, output[0][cf[0]]);
            Assert.AreEqual(61, output[0][cf[1]]);
            Assert.AreEqual(87840, output[0][cf[2]]);
            Assert.AreEqual(1464, output[0][cf[3]]);
            //Assert.AreEqual(1640, output[0][cf[4]]);
            //Assert.AreEqual(1644, output[0][cf[5]]);
        }
Пример #27
0
        public void Test()
        {
            const string xml = @"
    <add name='TestProcess'>
        <connections>
            <add name='input' provider='web' url='' user='' password='' />
            <add name='output' provider='log' />
        </connections>
      <entities>
        <add name='TestData' >
          <fields>
            <add name='Content' length='max' output='false'>
                <transforms>
                    <add method='fromXml' xml-mode='all'>
                        <fields>
                            <add name='name' node-type='attribute' />
                            <add name='consumerCount' type='int' node-type='attribute' />
                        </fields>
                    </add>
                </transforms>
            </add>
          </fields>
          <calculated-fields>
            <add name='pass' type='bool' t='copy(pass,consumerCount).js(consumerCount &gt; 0).filter(false)' />
            <add name='message' length='128' t='copy(name,consumerCount).format({0} queue has {1} consumers!)' />
            <add name='level' default='error' />
          </calculated-fields>
        </add>
      </entities>
    </add>";

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);

            controller.Execute();
        }
Пример #28
0
        public void AnyEqual()
        {
            var xml = @"
    <add name='TestProcess'>
      <entities>
        <add name='TestData' pipeline='linq'>
          <rows>
            <add Field1='1' Field2='2' Field3='3' />
          </rows>
          <fields>
            <add name='Field1' />
            <add name='Field2' />
            <add name='Field3' />
          </fields>
          <calculated-fields>
            <add name='Has1' type='bool' t='copy(*).any(1)' />
            <add name='Has2' type='bool' t='copy(Field1,Field2,Field3).any(2)' />
            <add name='Has3' type='bool' t='copy(*).any(3)' />
            <add name='Has4' type='bool' t='copy(Field1,Field2,Field3).any(4)' />
          </calculated-fields>
        </add>
      </entities>
    </add>
            ".Replace('\'', '"');

            var composer   = new CompositionRoot();
            var controller = composer.Compose(xml);
            var output     = controller.Read().ToArray();

            var cf = composer.Process.Entities.First().CalculatedFields.ToArray();

            Assert.AreEqual(true, output[0][cf[0]]);
            Assert.AreEqual(true, output[0][cf[1]]);
            Assert.AreEqual(true, output[0][cf[2]]);
            Assert.AreEqual(false, output[0][cf[3]]);
        }
Пример #29
0
        public void RunInit()
        {
            var composer = new CompositionRoot();

            composer.Compose(Cfg + @"?Mode=init", LogLevel.Info).Execute();
        }
Пример #30
0
        public void StarSql()
        {
            var composer   = new CompositionRoot();
            var controller = composer.Compose(@"Files\Northwind.xml");

            Assert.AreEqual(0, composer.Process.Errors().Length);

            var pipe   = new PipelineContext(new TraceLogger(), composer.Process);
            var actual = new SqlFormattingManager().Format(pipe.SqlCreateStarView(new SqlServerConnectionFactory(new Connection().WithDefaults())));

            Assert.IsNotNull(controller);
            const string expected = @"CREATE VIEW [NorthWindStar]
AS
SELECT A.[A1] AS [TflKey]
	,A.[A2] AS [TflBatchId]
	,A.[A3] AS [TflHashCode]
	,A.[A4] AS [TflDeleted]
	,A.[A5] AS [OrderDetailsDiscount]
	,A.[A6] AS [OrderDetailsOrderID]
	,A.[A7] AS [OrderDetailsProductID]
	,A.[A8] AS [OrderDetailsQuantity]
	,A.[A9] AS [OrderDetailsRowVersion]
	,A.[A10] AS [OrderDetailsUnitPrice]
	,A.[A11] AS [OrderDetailsExtendedPrice]
	,A.[A20] AS [CountryExchange]
	,A.[A21] AS [Test]
	,A.[B5] AS [OrdersCustomerID]
	,A.[B6] AS [OrdersEmployeeID]
	,A.[E12] AS [ProductsSupplierID]
	,A.[E5] AS [ProductsCategoryID]
	,A.[B19] AS [OrdersShipVia]
	,COALESCE(B.[B7], 0.0) AS [OrdersFreight]
	,COALESCE(B.[B8], '9999-12-31T00:00:00Z') AS [OrdersOrderDate]
	,COALESCE(B.[B10], '9999-12-31T00:00:00Z') AS [OrdersRequiredDate]
	,COALESCE(B.[B12], '') AS [OrdersShipAddress]
	,COALESCE(B.[B13], '') AS [OrdersShipCity]
	,COALESCE(B.[B14], '') AS [OrdersShipCountry]
	,COALESCE(B.[B15], '') AS [OrdersShipName]
	,COALESCE(B.[B16], '9999-12-31T00:00:00Z') AS [OrdersShippedDate]
	,COALESCE(B.[B17], '') AS [OrdersShipPostalCode]
	,COALESCE(B.[B18], '') AS [OrdersShipRegion]
	,COALESCE(B.[B20], '12-DEC') AS [TimeOrderMonth]
	,COALESCE(B.[B21], '9999-12-31') AS [TimeOrderDate]
	,COALESCE(B.[B22], '9999') AS [TimeOrderYear]
	,COALESCE(C.[C5], '') AS [CustomersAddress]
	,COALESCE(C.[C6], '') AS [CustomersCity]
	,COALESCE(C.[C7], '') AS [CustomersCompanyName]
	,COALESCE(C.[C8], '') AS [CustomersContactName]
	,COALESCE(C.[C9], '') AS [CustomersContactTitle]
	,COALESCE(C.[C10], '') AS [CustomersCountry]
	,COALESCE(C.[C12], '') AS [CustomersFax]
	,COALESCE(C.[C13], '') AS [CustomersPhone]
	,COALESCE(C.[C14], '') AS [CustomersPostalCode]
	,COALESCE(C.[C15], '') AS [CustomersRegion]
	,COALESCE(D.[D5], '') AS [EmployeesAddress]
	,COALESCE(D.[D6], '9999-12-31T00:00:00Z') AS [EmployeesBirthDate]
	,COALESCE(D.[D7], '') AS [EmployeesCity]
	,COALESCE(D.[D8], '') AS [EmployeesCountry]
	,COALESCE(D.[D10], '') AS [EmployeesExtension]
	,COALESCE(D.[D11], '') AS [EmployeesFirstName]
	,COALESCE(D.[D12], '9999-12-31T00:00:00Z') AS [EmployeesHireDate]
	,COALESCE(D.[D13], '') AS [EmployeesHomePhone]
	,COALESCE(D.[D14], '') AS [EmployeesLastName]
	,COALESCE(D.[D15], '') AS [EmployeesNotes]
	,COALESCE(D.[D18], '') AS [EmployeesPostalCode]
	,COALESCE(D.[D19], '') AS [EmployeesRegion]
	,COALESCE(D.[D21], '') AS [EmployeesTitle]
	,COALESCE(D.[D22], '') AS [EmployeesTitleOfCourtesy]
	,COALESCE(D.[D23], 0) AS [EmployeesReportsTo]
	,COALESCE(D.[D24], '') AS [EmployeesManager]
	,COALESCE(D.[D25], '') AS [Employee]
	,COALESCE(E.[E6], 0) AS [ProductsDiscontinued]
	,COALESCE(E.[E8], '') AS [ProductsProductName]
	,COALESCE(E.[E9], '') AS [ProductsQuantityPerUnit]
	,COALESCE(E.[E10], 0) AS [ProductsReorderLevel]
	,COALESCE(E.[E13], 0.0) AS [ProductsUnitPrice]
	,COALESCE(E.[E14], 0) AS [ProductsUnitsInStock]
	,COALESCE(E.[E15], 0) AS [ProductsUnitsOnOrder]
	,COALESCE(F.[F5], '') AS [SuppliersAddress]
	,COALESCE(F.[F6], '') AS [SuppliersCity]
	,COALESCE(F.[F7], '') AS [SuppliersCompanyName]
	,COALESCE(F.[F8], '') AS [SuppliersContactName]
	,COALESCE(F.[F9], '') AS [SuppliersContactTitle]
	,COALESCE(F.[F10], '') AS [SuppliersCountry]
	,COALESCE(F.[F11], '') AS [SuppliersFax]
	,COALESCE(F.[F12], '') AS [SuppliersHomePage]
	,COALESCE(F.[F13], '') AS [SuppliersPhone]
	,COALESCE(F.[F14], '') AS [SuppliersPostalCode]
	,COALESCE(F.[F15], '') AS [SuppliersRegion]
	,COALESCE(G.[G6], '') AS [CategoriesCategoryName]
	,COALESCE(G.[G7], '') AS [CategoriesDescription]
	,COALESCE(H.[H5], '') AS [ShippersCompanyName]
	,COALESCE(H.[H6], '') AS [ShippersPhone]
FROM [NorthWindOrder DetailsTable] A
LEFT OUTER JOIN [NorthWindOrdersTable] B ON (A.[A6] = B.[B9])
LEFT OUTER JOIN [NorthWindCustomersTable] C ON (A.[B5] = C.[C11])
LEFT OUTER JOIN [NorthWindEmployeesTable] D ON (A.[B6] = D.[D9])
LEFT OUTER JOIN [NorthWindProductsTable] E ON (A.[A7] = E.[E7])
LEFT OUTER JOIN [NorthWindSuppliersTable] F ON (A.[E12] = F.[F17])
LEFT OUTER JOIN [NorthWindCategoriesTable] G ON (A.[E5] = G.[G5])
LEFT OUTER JOIN [NorthWindShippersTable] H ON (A.[B19] = H.[H8]);
";

            Assert.AreEqual(expected, actual);
        }