Example #1
0
        public async Task FullOnePOTest()
        {
            Assert.IsNotNull(DataAnnotationsFactory.TableAttributeType); // les annotations doivent avoir été chargées
            var connector = Nglib.DATA.CONNECTOR.ConnectorTests.GetDefaultConenctor();
            DataPoSampleProvider dataPoSampleProvider = new DataPoSampleProvider(connector);

            // Insert
            DataPoSample dataPoSample = new DataPoSample();

            dataPoSample.Pseudo = "test";
            dataPoSample.FluxXml.SetObject("/param/sut1", "valeur1", DATA.ACCESSORS.DataAccessorOptionEnum.None);
            dataPoSample.FluxXml["/param/sut2"] = "valeur2";
            await dataPoSampleProvider.InsertPOAsync(dataPoSample);

            Assert.IsTrue(dataPoSample.TestId > 0);

            // Select
            dataPoSample = dataPoSampleProvider.GetFirstPO(dataPoSample.TestId);

            // save
            dataPoSample.FluxXml["/param/sut2"] = "valeurX2";
            dataPoSample.FluxXml["/param/sut3"] = "valeur2";
            dataPoSample.Pseudo = "test2";
            await dataPoSampleProvider.SavePOAsync(dataPoSample);

            // update

            // Delete
            dataPoSample = dataPoSampleProvider.GetFirstPO(dataPoSample.TestId);
            await dataPoSampleProvider.DeletePOAsync(dataPoSample);

            Assert.IsTrue(dataPoSample.TestId > 0);
        }
Example #2
0
        public async Task PertTest1_pre()
        {
            System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
            int nb = 0;

            Nglib.DATA.CONNECTOR.IDataConnector connector = new Nglib.DATA.CONNECTOR.ConnectorGeneric();
            connector.SetConnectionString(Nglib.DATA.CONNECTOR.ConnectorTests.TestConnectionString, "Npgsql");
            connector.QueryCompleted += Connector_QueryCompleted;

            try
            {
                connector.Open(true);
                System.Data.Common.DbConnection connect = (System.Data.Common.DbConnection)connector.GetDbConnection();

                watch.Start();

                DataPoSampleProvider provider = new DataPoSampleProvider(connector);

                Console.WriteLine(string.Format("elapsed:{0}ms - nb:{1}  executes={2}ms -{3}ms", watch.ElapsedMilliseconds, nb, totalelapsedExecute, totalelapsedConnector));
                CollectionPO <DataPoSample> listtest = provider.GetListPO("SELECT * FROM tests");
                Console.WriteLine(string.Format("elapsed:{0}ms - nb:{1}  executes={2}ms -{3}ms", watch.ElapsedMilliseconds, nb, totalelapsedExecute, totalelapsedConnector));
                nb = listtest.Count;

                for (int i = 0; i < 100; i++)
                {
                    DataPoSample item = provider.GetFirstPO(6);
                    item.Pseudo = "tesperf_po_" + i.ToString();
                    provider.SavePO(item);
                    i++;
                }
                Console.WriteLine(string.Format("elapsed:{0}ms - nb:{1}  executes={2}ms -{3}ms", watch.ElapsedMilliseconds, nb, totalelapsedExecute, totalelapsedConnector));

                await provider.InsertPOAsync(new DataPoSample()
                {
                    Pseudo = "totu"
                });

                watch.Stop();
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                connector.Close();
            }
            Console.WriteLine(string.Format("elapsed:{0}ms - nb:{1}  executes={2}ms -{3}ms", watch.ElapsedMilliseconds, nb, totalelapsedExecute, totalelapsedConnector));
        }
Example #3
0
        public async Task DevPOTest()
        {
            var connector = Nglib.DATA.CONNECTOR.ConnectorTests.GetDefaultConenctor();
            DataPoSampleProvider dataPoSampleProvider = new DataPoSampleProvider(connector);
            DataPoSample         dataPoSample         = dataPoSampleProvider.GetFirstPO(6);
            var test0 = dataPoSample.GetObject("jsonb", DataAccessorOptionEnum.None);
            var test  = dataPoSample.GetObject("multicols1", DataAccessorOptionEnum.None);

            Console.WriteLine(test);
            string DnForTalosAdmins = dataPoSample.FluxXml.GetString("/param/DnForTalosAdmins");

            string flux = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<param>\r\n\t<empty true=\"False\" />\r\n\t<maval>e20a0115320b41679c8500e4e651690e</maval>\r\n</param>";
            await dataPoSampleProvider.UpdatePOAsync(new DataPoSample[] { dataPoSample }, "fluxxml", flux);

            Console.WriteLine("test");
        }
Example #4
0
        public void TestwithPOSimple() // note : les PO sont 20% plus long que les POCO en serial et deserial
        {
            DataPoSample po = new DataPoSample();

            po.TestId = 5;
            po.Pseudo = "totoLtoto";
            po.FluxXml["/param/maval5"] = "totop";

            for (int i = 0; i < 1000; i++)
            {
                po.TestId++;
                string       jsonpo = Newtonsoft.Json.JsonConvert.SerializeObject(po);
                DataPoSample po2    = Newtonsoft.Json.JsonConvert.DeserializeObject <DataPoSample>(jsonpo);
                Assert.AreEqual(po2.Pseudo, po.Pseudo);
            }
        }
Example #5
0
        public void TestwithPOSerial() // note : les PO sont 20% plus long que les POCO en serial et deserial
        {
            DataPoSample po = new DataPoSample();

            po.TestId = 5;
            po.Pseudo = "totoLtoto";
            po.FluxXml["/param/maval5"]   = "totop";
            po.FluxJson["/param/mavalj8"] = "totopttttt";

            for (int i = 0; i < 1000; i++)
            {
                po.TestId++;

                Dictionary <string, object> valspo = po.GetValues();
                string jsonpo = Newtonsoft.Json.JsonConvert.SerializeObject(valspo);
                Dictionary <string, object> valspo2 = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, object> >(jsonpo);
                DataPoSample po2 = new DataPoSample();
                po2.SetValues(valspo2);
                Assert.AreEqual(po2.Pseudo, po.Pseudo);
            }
        }