Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            var s = new SaveFileDialog()
            {
                Filter = "Файлы заказа|*.txt"
            };
            var result = s.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                var dto = GetModelFromUI();

                ElectronicHelper.WriteToFile(s.FileName, dto);
            }
        }