コード例 #1
0
        public void CsvOutputFromCsvAscendingCityThenAscendingCity()
        {
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DataConverter.Test.Data.sample_data.csv"))
                using (var ms = new MemoryStream())
                {
                    stream.CopyTo(ms);
                    var csv = Encoding.UTF8.GetString(ms.ToArray());

                    var obj = MainCityData.FromCsv(csv);


                    obj.ObjectResult = obj.ObjectResult.OrderBy(o => o.CityName).ThenBy(t => t.DistrictName).ToList();

                    var desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                    var fileName    = $"TestCase2_{DateTime.Now.ToString("yyyyMMddThhmmss")}.csv";

                    File.WriteAllText(Path.Combine(desktopPath, fileName), obj.AsCsv());

                    Assert.True(true);
                }
        }
コード例 #2
0
        public void XmlOutputFromCsvTest()
        {
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DataConverter.Test.Data.sample_data.csv"))
                using (var ms = new MemoryStream())
                {
                    stream.CopyTo(ms);
                    var csv = Encoding.UTF8.GetString(ms.ToArray());
                    // Arrange
                    var unitUnderTest = this.CreateMainCityData();

                    var obj = MainCityData.FromCsv(csv);

                    obj.Filter(x => x.CityName == "Antalya");

                    var desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                    var fileName    = $"TestCase1_{DateTime.Now.ToString("yyyyMMddThhmmss")}.xml";

                    File.WriteAllText(Path.Combine(desktopPath, fileName), obj.AsXml());

                    // Assert
                    Assert.True(true);
                }
        }