示例#1
0
        public void TestWithParallelReader()
        {
            IImportEngine engine = new ExcelImportEngine();

            engine.AsExcel().SetFormat(ExcelVersion.XLSX);
            engine.SetDocument(PathConfig.BASE_PATH + MULTIPLE_DATA);
            var resetEvents        = new List <ManualResetEvent>();
            var countItemsInSheets = new List <int>();

            foreach (var index in new string[] { "1", "2" })
            {
                var evt = new ManualResetEvent(false);
                resetEvents.Add(evt);
                ThreadPool.QueueUserWorkItem(i =>
                {
                    var key  = engine.AsExcel().AddContainer <DummyPerson>("Hoja" + index, 1);
                    var data = engine.GetList <DummyPersonWithAttributesAndDefaultValues>(key);
                    countItemsInSheets.Add(data.Count);
                    evt.Set();
                }, index);
            }

            foreach (var evt in resetEvents)
            {
                evt.WaitOne();
            }

            if (!countItemsInSheets.Any() || countItemsInSheets.Sum() != 60)
            {
                throw new Exception("No se pudieron leer los registros en paralelo del documento " + MULTIPLE_DATA);
            }
        }
        public void TestWithoutAttribute()
        {
            IImportEngine engine = new ExcelImportEngine();
            engine.AsExcel().AddContainer<DummyPerson>("1", "Dummy People", 1);
            engine.SetDocument(DIRECTORY_PATH + DUMMY_PERSON);
            var data = engine.GetList<DummyPerson>("1");

            if (!data.Any() || data.Count != 30)
                throw new Exception("No se pudieron leer los registros del documento DummySimplePerson.xlsx");
        }
示例#3
0
        public void TestWithDefaults()
        {
            IImportEngine engine = new ExcelImportEngine();
            var           key    = engine.AsExcel().AddContainer <DummyPerson>("Dummy People", 1);

            engine.SetDocument(PathConfig.BASE_PATH + DUMMY_PERSON_DEFAULTS);
            var data = engine.GetList <DummyPersonWithAttributesAndDefaultValues>(key);

            if (!data.Any() || data.Count != 30)
            {
                throw new Exception("No se pudieron leer los registros del documento " + DUMMY_PERSON_DEFAULTS);
            }
        }
示例#4
0
        public void TestWithoutAttribute()
        {
            IImportEngine engine = new ExcelImportEngine();
            var           key    = engine.AsExcel().AddContainer <DummyPerson>("Dummy People", 1);

            engine.SetDocument(PathConfig.BASE_PATH + DUMMY_PERSON);
            var data = engine.GetList <DummyPerson>(key);

            if (!data.Any() || data.Count != 30)
            {
                throw new Exception("No se pudieron leer los registros del documento DummySimplePerson.xlsx");
            }
        }
示例#5
0
        public void TestWithEmptyRows()
        {
            IImportEngine engine = new ExcelImportEngine();
            var           key    = engine.AsExcel().AddContainer <DummyPerson>("Hoja1", 1);

            engine.SetDocument(PathConfig.BASE_PATH + EMPTY_ROWS);
            var data = engine.GetList <DummyPersonWithAttributesAndDefaultValues>(key);

            if (!data.Any() || data.Count != 33)
            {
                throw new Exception("No se pudieron leer los registros del documento " + EMPTY_ROWS);
            }
        }
        public void TestWithAttribute()
        {
            try
            {
                IImportEngine engine = new ExcelImportEngine();
                engine.AsExcel().SetFormat(ExcelVersion.XLS);
                engine.AddContainer<DummyPersonWithAttributes>("1");
                engine.SetDocument(DIRECTORY_PATH + DUMMY_PERSON);
                var data = engine.GetList<DummyPersonWithAttributes>("1");

                if (!data.Any() || data.Count != 30)
                    throw new Exception("No se pudieron leer los registros del documento DummySimplePerson.xlsx");
            }
            catch (Exception ex)
            {
                throw new Exception("No se pudo completar la prueba. Revise el error interno", ex);
            }
        }
示例#7
0
        public void TestWithAttribute()
        {
            try
            {
                IImportEngine engine = new ExcelImportEngine();
                engine.AsExcel().SetFormat(ExcelVersion.XLS);
                var key = engine.AddContainer <DummyPersonWithAttributes>();
                engine.SetDocument(PathConfig.BASE_PATH + DUMMY_PERSON);
                var data = engine.GetList <DummyPersonWithAttributes>(key);

                if (!data.Any() || data.Count != 30)
                {
                    throw new Exception("No se pudieron leer los registros del documento DummySimplePerson.xlsx");
                }
            }
            catch (Exception ex)
            {
                throw new Exception("No se pudo completar la prueba. Revise el error interno", ex);
            }
        }