예제 #1
0
파일: UnitTest1.cs 프로젝트: yanancai/usql
        public void TestMyProcessor()
        {
            // Define the schema for processor input rowset
            // Schema: "a:int, b:int"
            //
            USqlColumn <int> col1    = new USqlColumn <int>("col1");
            USqlColumn <int> col2    = new USqlColumn <int>("col2");
            List <IColumn>   columns = new List <IColumn> {
                col1, col2
            };
            USqlSchema schema = new USqlSchema(columns);

            // Generate one row with specified column values as input rowset
            //
            object[] values = new object[2] {
                0, 0
            };
            IRow          input  = new USqlRow(schema, values);
            IUpdatableRow output = input.AsUpdatable();

            // Create processor instance for testing and run the processor with fake input
            //
            MyProcessor processor = new MyProcessor();
            IRow        newOutput = processor.Process(input, output);

            //Verify results for processor output
            //
            Assert.IsTrue(newOutput.Schema.Count == 2);
            Assert.IsTrue(newOutput.Get <int>(0) == 1);
            Assert.IsTrue(newOutput.Get <int>(1) == 5);
        }
        public void TestMyProcessor()
        {
            //Schema: "a:int, b:int"
            USqlColumn <int> col1    = new USqlColumn <int>("a");
            USqlColumn <int> col2    = new USqlColumn <int>("b");
            List <IColumn>   columns = new List <IColumn> {
                col1, col2
            };
            USqlSchema schema = new USqlSchema(columns);

            //Generate one row with specified column values
            object[] values = new object[2] {
                2, 3
            };
            IRow          input  = new USqlRow(schema, values);
            IUpdatableRow output = input.AsUpdatable();

            //Create UDO instance
            MyProcessor processor = new MyProcessor(floor: 4);
            IRow        newOutput = processor.Process(input, output);

            //Verify results
            Assert.IsTrue(newOutput.Schema.Count == 2);
            Assert.IsTrue(newOutput.Get <int>(0) == 2);
            Assert.IsTrue(newOutput.Get <int>(1) == 4);
        }
예제 #3
0
        public void EmptyFile()
        {
            IExtractor extractor = new EventhubCaptureExtractor();

            FileStream stream = File.Open(@"sampleData/empty.avro", FileMode.Open);

            IUnstructuredReader input = new UnstructuredReaderTest(stream);

            var body = new USqlColumn <byte>("Body");

            var columns = new List <IColumn> {
                body
            };
            var schema  = new USqlSchema(columns);
            var usqlrow = new USqlRow(schema, null);
            var result  = extractor.Extract(input, usqlrow.AsUpdatable());

            Assert.AreEqual(0, result.Count());
        }