예제 #1
0
        public void FirstTest()
        {
            var dto = new PizzaRequestDto
            {
                //Filled = DateTime.Now,
                FullName      = "Batman",
                Address       = "Batcave",
                Price         = 700,
                PaymentMethod = PaymentMethod.CreditCardOnline,
                DeliveryTime  = new DateTime(2018, 4, 22, 23, 15, 0),
                Pizza         = new List <PizzaMaker>()
                {
                    new PizzaMaker
                    {
                        pizza        = Pizza.Margherita,
                        size         = PizzaSize.large,
                        Dough        = DoughType.TraditionalDough,
                        AddMushrooms = false
                    }
                }
            };
            var tempFileName = Path.GetTempFileName();

            try
            {
                PizzaDtoHelper.WriteToFile(tempFileName, dto);
                var readDto = PizzaDtoHelper.LoadFromFile(tempFileName);
                // Assert.AreEqual(dto.Filled, readDto.Filled);
                Assert.AreEqual(dto.Address, readDto.Address);
            }
            finally
            {
                File.Delete(tempFileName);
            }
        }
예제 #2
0
        private void SaveB_Click(object sender, EventArgs e)
        {
            var sfd = new SaveFileDialog()
            {
                Filter = "Файлы заказов|*.pz"
            };
            var result = sfd.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                var dto = GetModelFromUI();
                PizzaDtoHelper.WriteToFile(sfd.FileName, dto);
            }
        }