Ejemplo n.º 1
0
        public void ensureToStringWorks()
        {
            Restriction instance = new Restriction("oh hi mark", new SameMaterialAndFinishAlgorithm());
            Restriction other    = new Restriction("oh hi mark", new SameMaterialAndFinishAlgorithm());

            Assert.Equal(instance.ToString(), other.ToString());
        }
        private void SeedBooks(BookSystemDbContext context)
        {
            int authorsCount = context.Authors.Local.Count;

            string[] books = File.ReadAllLines($@"{AppDomain.CurrentDomain.BaseDirectory}\Import\books.csv");

            for (int i = 1; i < books.Length; i++)
            {
                string[] data = books[i]
                                .Split(',')
                                .Select(arg => arg.Replace("\"", string.Empty))
                                .ToArray();

                int         authorIndex    = i % authorsCount;
                Author      author         = context.Authors.Local[authorIndex];
                EditionType edition        = (EditionType)int.Parse(data[0]);
                DateTime    releaseDate    = DateTime.ParseExact(data[1], "d/M/yyyy", CultureInfo.InvariantCulture);
                int         copies         = int.Parse(data[2]);
                decimal     price          = decimal.Parse(data[3]);
                Restriction ageRestriction = (Restriction)int.Parse(data[4]);
                string      title          = data[5];
                Book        book           = new Book
                {
                    Author         = author,
                    AuthorId       = author.Id,
                    Edition        = edition.ToString(),
                    ReleaseDate    = releaseDate,
                    Copies         = copies,
                    Price          = price,
                    AgeRestriction = ageRestriction.ToString(),
                    Title          = title
                };

                context.Books.AddOrUpdate(b => new { b.Title, b.AuthorId }, book);
            }
        }