예제 #1
0
        public async Task WriteAndRead_WrittenDataReturnedCorrectly()
        {
            var dt = new DataTable
            {
                Columns =
                {
                    new DataColumn("FirstName"),
                    new DataColumn("LastName"),
                    new DataColumn("Age"),
                }
            };

            dt.Rows.Add("Jason", "Derulo", 35);
            dt.Rows.Add("Calvin", "Harris", 42);

            await _sut.WriteToCsv("TestFile.csv", dt);

            var result = await _sut.ReadFromCsv("TestFile.csv");

            Assert.AreEqual(2, result.Rows.Count);
            Assert.AreEqual("Jason", result.Rows[0]["FirstName"]);
            Assert.AreEqual("Derulo", result.Rows[0]["LastName"]);
            Assert.AreEqual("35", result.Rows[0]["Age"]);
            Assert.AreEqual("Calvin", result.Rows[1]["FirstName"]);
            Assert.AreEqual("Harris", result.Rows[1]["LastName"]);
            Assert.AreEqual("42", result.Rows[1]["Age"]);
        }