Пример #1
0
        private void SaveB_Click(object sender, EventArgs e)
        {
            var sfd = new SaveFileDialog()
            {
                Filter = "Бланки заказов|*.blk"
            };
            var result = sfd.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                var dto = GetModelfromUI();
                BooksDtoHelper.WriteToFile(sfd.FileName, dto);
            }
        }
Пример #2
0
        public void TestMethod()
        {
            var dto = new BookRequestDto
            {
                Filled     = DateTime.Now,
                FullName   = "Тот чье имя нельзя называть",
                BookTitles = new List <BookTitle>()
                {
                    new BookTitle
                    {
                        Book = new List <BookDetails>()
                        {
                            new BookDetails
                            {
                                Title       = "Гарри Поттер. Все части",
                                Genre       = Genre.HumorousLiterature,
                                PagesNumber = 322,
                                Price       = 40000,
                                AgeLimit    = AgeLimit.sixAndOlder,
                                Presence    = true
                            }
                        }
                    }
                },
                Addres   = "Косой переулок",
                Price    = 40000,
                Currency = Currency.Bitcoins
            };
            var tempFileName = Path.GetTempFileName();

            try
            {
                BooksDtoHelper.WriteToFile(tempFileName, dto);
                var readDto = BooksDtoHelper.LoadFromFile(tempFileName);
                Assert.AreEqual(dto.FullName, readDto.FullName);
                Assert.AreEqual(dto.Currency, readDto.Currency);
            }
            finally
            {
                File.Delete(tempFileName);
            }
        }