Exemplo n.º 1
0
        public static void SetUp(TestContext testContext)
        {
            // get the path of test files
            var directory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            loadPath = System.IO.Path.Combine(directory, testCSVFilename);
            savePath = System.IO.Path.Combine(directory, "athlete.json");

            // get athletes data
            athleles = Integration.Program.LoadCsvFile(loadPath);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Loading data....");
            Integration.AthletesDTO athleles = LoadCsvFile(CSV_FILENAME);
            Console.WriteLine("Data loaded....\n");

            Console.WriteLine("Saving Data....");
            SaveJsonFile(JSON_FILENAME, athleles);
            Console.WriteLine("Data Saved....\n");

            Console.WriteLine("Go to bin/Debug/netcoreapp2.1/athlete.json to look at result...");
            Console.WriteLine("Press ENTER to exit...");
            Console.ReadLine();
        }
Exemplo n.º 3
0
        public void TestSaveJsonFile()
        {
            string json = Integration.Program.SaveJsonFile(savePath, athleles);

            Integration.AthletesDTO athletesDto = JsonConvert.DeserializeObject <Integration.AthletesDTO>(json);

            Assert.AreEqual(2, athletesDto.rows.Count);

            var firstRow = athletesDto.rows[0];

            // test the key/value pairs
            Assert.AreEqual(0, firstRow.row);
            Assert.AreEqual(7, firstRow.pairs.Count);

            Assert.AreEqual("firstName", firstRow.pairs[0].key);
            Assert.AreEqual("Bob", firstRow.pairs[0].value);

            Assert.AreEqual("lastName", firstRow.pairs[1].key);
            Assert.AreEqual("Smith", firstRow.pairs[1].value);

            Assert.AreEqual("middleName", firstRow.pairs[2].key);
            Assert.AreEqual("John", firstRow.pairs[2].value);

            Assert.AreEqual("dateOfBirth", firstRow.pairs[3].key);
            Assert.AreEqual("30/08/1990", firstRow.pairs[3].value);

            Assert.AreEqual("sex", firstRow.pairs[4].key);
            Assert.AreEqual("M", firstRow.pairs[4].value);


            Assert.AreEqual("height", firstRow.pairs[5].key);
            Assert.AreEqual("1.83", firstRow.pairs[5].value);

            Assert.AreEqual("sport", firstRow.pairs[6].key);
            Assert.AreEqual("basketball", firstRow.pairs[6].value);
        }