public void End2EndSerializationTest() { var electro = new Choice { NewTime = DateTime.Now, FullName = "Savva Baranovsky", Price = 50000, Currency = Currency.Rubles, Additions = new List <Addition>() { new Addition() { Name = "MSI", Memory = '8', VideoCard = "Nvidia", Processor = "Intel Core I7" } } }; var tempFileName = Path.GetTempFileName(); try { ElectronicHelper.WriteToFile(tempFileName, electro); var readElectro = ElectronicHelper.LoadFromFile(tempFileName); Assert.AreEqual(electro.Additions.Count, readElectro.Additions.Count); Assert.AreEqual(electro.NewTime, readElectro.NewTime); } finally { File.Delete(tempFileName); } }
private void button1_Click(object sender, EventArgs e) { var o = new OpenFileDialog() { Filter = "Файл заказа|*.txt" }; var result = o.ShowDialog(this); if (result == DialogResult.OK) { var dto = ElectronicHelper.LoadFromFile(o.FileName); SetModelToUI(dto); } }