Example #1
0
        public async Task ReadJSon1TypedAsync()
        {
            var setting =
                new CsvFile(UnitTestInitializeCsv.GetTestPath("Larger.json"))
            {
                JsonFormat = true
            };

            using (var processDisplay = new CustomProcessDisplay(UnitTestInitializeCsv.Token))
            {
                using (var jfr = new JsonFileReader(setting, processDisplay))
                {
                    await jfr.OpenAsync(processDisplay.CancellationToken);

                    await jfr.ReadAsync(processDisplay.CancellationToken);

                    Assert.AreEqual(new Guid("ef21069c-3d93-4e07-878d-00e820727f65"), jfr.GetGuid(0));
                    Assert.IsTrue((new DateTime(2020, 04, 03, 18, 45, 29, 573, DateTimeKind.Utc) -
                                   jfr.GetDateTime(1).ToUniversalTime()).TotalSeconds < 2);
                    Assert.AreEqual((short)0, jfr.GetInt16(5));
                    Assert.AreEqual((int)0, jfr.GetInt32(5));
                    Assert.AreEqual((long)0, jfr.GetInt64(5));
                    var val = new object[jfr.FieldCount];
                    jfr.GetValues(val);
                    Assert.IsNull(val[2]);
                }
            }
        }