34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
// <copyright file="CommentaireFactory.cs" company="PlaceholderCompany">
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
// </copyright>
|
|
|
|
using Bogus;
|
|
|
|
namespace Webzine.Entity.Fixtures
|
|
{
|
|
public class CommentaireFactory
|
|
{
|
|
/// <summary>
|
|
/// Seeder pour la base de données.
|
|
/// </summary>
|
|
/// <param name="titre">Titre.</param>
|
|
/// <param name="min">Min.</param>
|
|
/// <param name="max">Max.</param>
|
|
/// <returns>Liste de commentaire.</returns>
|
|
public static List<Commentaire> CreerListeCommentaire(Titre titre, int min = 0, int max = 5)
|
|
{
|
|
Random random = new Random();
|
|
int count = random.Next(min, max + 1);
|
|
|
|
Faker<Commentaire> faker = new Faker<Commentaire>("fr")
|
|
.RuleFor(c => c.Auteur, f => f.Internet.UserName())
|
|
.RuleFor(c => c.Contenu, f => f.Lorem.Sentences(2))
|
|
.RuleFor(c => c.DateCreation, f => f.Date.Recent(60))
|
|
.RuleFor(c => c.Titre, _ => titre)
|
|
.RuleFor(c => c.IdTitre, _ => titre.IdTitre);
|
|
|
|
return faker.Generate(count);
|
|
}
|
|
}
|
|
}
|