コード例 #1
0
        public void SourceWithDifferentNames()
        {
            //Arrange
            TwoColumnsTableFixture            dest2Columns = new TwoColumnsTableFixture("XmlSource2ColsDynamic");
            RowTransformation <ExpandoObject> trans        = new RowTransformation <ExpandoObject>(
                row =>
            {
                dynamic r = row as ExpandoObject;
                r.Col1    = r.Column1;
                r.Col2    = r.Column2;
                return(r);
            });
            DbDestination <ExpandoObject> dest = new DbDestination <ExpandoObject>("XmlSource2ColsDynamic", Connection);

            //Act
            XmlSource <ExpandoObject> source = new XmlSource <ExpandoObject>("res/XmlSource/TwoColumnsElementDifferentNames.xml", ResourceType.File)
            {
                ElementName = "MySimpleRow"
            };
            var link1 = source.LinkTo(trans);
            var link2 = link1.source.LinkTo(dest);

            using (link1.link)
                using (link2.link)
                {
                    source.Execute();
                    dest.Wait();

                    //Assert
                    dest2Columns.AssertTestData();
                }
        }
コード例 #2
0
        public void WithoutErrorLinking()
        {
            //Arrange
            MemoryDestination <MySimpleRow> dest = new MemoryDestination <MySimpleRow>();

            //Act
            XmlSource <MySimpleRow> source = new XmlSource <MySimpleRow>("res/XmlSource/TwoColumnsErrorLinking.xml", ResourceType.File);

            //Assert
            Assert.Throws <System.InvalidOperationException>(() =>
            {
                source.LinkTo(dest);
                source.Execute();
                dest.Wait();
            });
        }
コード例 #3
0
        public void XmlOnlyAttributes()
        {
            //Arrange
            TwoColumnsTableFixture         dest2Columns = new TwoColumnsTableFixture("XmlSource2ColsAttribute");
            DbDestination <MyAttributeRow> dest         = new DbDestination <MyAttributeRow>(Connection, "XmlSource2ColsAttribute");

            //Actt
            XmlSource <MyAttributeRow> source = new XmlSource <MyAttributeRow>("res/XmlSource/TwoColumnsOnlyAttributes.xml", ResourceType.File);

            source.LinkTo(dest);
            source.Execute();
            dest.Wait();

            //Assert
            dest2Columns.AssertTestData();
        }
コード例 #4
0
        public void WithObjectErrorLinking()
        {
            //Arrange
            TwoColumnsTableFixture          dest2Columns = new TwoColumnsTableFixture("XmlSourceErrorLinking");
            DbDestination <MySimpleRow>     dest         = new DbDestination <MySimpleRow>(SqlConnection, "XmlSourceErrorLinking");
            MemoryDestination <ETLBoxError> errorDest    = new MemoryDestination <ETLBoxError>();

            //Act
            XmlSource <MySimpleRow> source = new XmlSource <MySimpleRow>("res/XmlSource/TwoColumnsErrorLinking.xml",
                                                                         ResourceType.File);

            source.LinkTo(dest);
            source.LinkErrorTo(errorDest);
            source.Execute();
            dest.Wait();
            errorDest.Wait();

            //Assert
            dest2Columns.AssertTestData();
            Assert.Collection <ETLBoxError>(errorDest.Data,
                                            d => Assert.True(!string.IsNullOrEmpty(d.RecordAsJson) && !string.IsNullOrEmpty(d.ErrorText))
                                            );
        }