コード例 #1
0
        public static List <BookListNoSql> CreateDummyBooks(int numBooks = 10, bool stepByYears = false)
        {
            var random       = new Random(0);
            var result       = new List <BookListNoSql>();
            var commonAuthor = new Author {
                Name = "CommonAuthor"
            };

            for (int i = 0; i < numBooks; i++)
            {
                var publishedDate = stepByYears
                    ? DddEfTestData.DummyBookStartDate.AddYears(i)
                    : DddEfTestData.DummyBookStartDate.AddDays(i);
                var book = new BookListNoSql
                {
                    BookId              = Guid.NewGuid(),
                    Title               = $"Book{i:D4} Title",
                    AuthorsOrdered      = $"Author{i:D4}, CommonAuthor",
                    OrgPrice            = i + 1,
                    ActualPrice         = i + 1,
                    PublishedOn         = publishedDate,
                    YearPublished       = publishedDate.Year,
                    ReviewsAverageVotes = random.NextDouble() * 5,
                    ReviewsCount        = (i % 5) + 1
                };
                result.Add(book);
            }
            return(result);
        }
コード例 #2
0
        public static BookListNoSql CreateDummyNoSqlBook()
        {
            var book = new BookListNoSql
            {
                BookId              = Guid.NewGuid(),
                Title               = "Test",
                AuthorsOrdered      = "Author1,Author2",
                ActualPrice         = 1,
                OrgPrice            = 1,
                PublishedOn         = new DateTime(2000, 1, 1),
                ReviewsAverageVotes = 5,
                ReviewsCount        = 1
            };

            return(book);
        }