public void End2EndSerializationTest() { var dto = new OrderRequestDto { Filled = new TimeOfRepair() { Filled = DateTime.Today, }, FullName = "Grigoriy Zalyatskiy", DescriptionOfBreakageDevice = new Device() { BrokenDevice = Apparat.Kettle, Breakage = new List <Breakage>() { new Breakage() { BreakageType = DamageType.Burned, Description = "Cгорел датчик температуры" }, new Breakage() { BreakageType = DamageType.Physical, Description = "Оторвалась крышка" }, } }, Price = new Payment() { Currency = Currency.Bitcoins, Price = 0.002, }, Repair = new AdditionalRequirements() { TimeOfRepair = new TimeOfRepair() { Days = 7, }, BuySomeDetailsYourself = false, AdditionalRequests = "Почините, пожалуйста чайник, приходится кипятить воду в кастрюльке без него :(" } }; var tempFileName = Path.GetTempFileName(); try { RideDtoHelper.WriteToFile(tempFileName, dto); var readDto = RideDtoHelper.LoadFromFile(tempFileName); Assert.AreEqual(dto.FullName, readDto.FullName); Assert.AreEqual(dto.Price.Price, readDto.Price.Price); } finally { File.Delete(tempFileName); } }
private void button2_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog() { Filter = "Файл заказа|*.pizza" }; var result = ofd.ShowDialog(this); if (result == DialogResult.OK) { var dto = RideDtoHelper.LoadFromFile(ofd.FileName); SetModelToUI(dto); } }
public void End2EndSerializationTest() { var dto = new RideApplicationDto { Filled = DateTime.Now, FullName = "Alexandr Malykh", Citizenship = "Russian", Age = 19, Height = 178, Weight = 60, AgeStartCareer = 15, ExperienceInFootball = 3, Position = Position.Goalkeeper, WorkingLeg = WorkingLeg.Right, WeakSides = WeakSides.Endurance, Strengths = Strengths.Reaction, Traums = new List <Trauma>() { new Trauma { CountTraums = 0, TimeTraums = 0, TraumаNow = false, Type = TraumaTypes.None } } }; var tempFileName = Path.GetTempFileName(); try { RideDtoHelper.WriteToFile(tempFileName, dto); var readDto = RideDtoHelper.LoadFromFile(tempFileName); Assert.AreEqual(dto.Filled, readDto.Filled); } finally { File.Delete(tempFileName); } }