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

            if (result == DialogResult.OK)
            {
                var dto = GetModelFromUI();
                RideDtoHelper.WriteToFile(sfd.FileName, 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);
            }
        }