| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="PatternFakerExtensions.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System.Collections.Generic; |
| | | 8 | | using MyNet.Generator; |
| | | 9 | | using MyNet.Text.Randomize; |
| | | 10 | | |
| | | 11 | | #pragma warning disable IDE0130 // Namespace does not match folder structure |
| | | 12 | | namespace MyNet.Fakers; |
| | | 13 | | #pragma warning restore IDE0130 // Namespace does not match folder structure |
| | | 14 | | |
| | | 15 | | public static class PatternFakerExtensions |
| | | 16 | | { |
| | | 17 | | extension(ITextRandomGenerator random) |
| | | 18 | | { |
| | | 19 | | /// <summary> |
| | | 20 | | /// Generates a random string based on a randomly selected pattern from the provided list, using the specified t |
| | | 21 | | /// </summary> |
| | | 22 | | /// <param name="generator">The random generator used to select a pattern from the list.</param> |
| | | 23 | | /// <param name="patterns">The list of patterns to choose from.</param> |
| | | 24 | | /// <returns>A randomly generated string based on the selected pattern.</returns> |
| | | 25 | | public string RandomizeWithRandomPattern(IRandomGenerator generator, IReadOnlyList<string> patterns) |
| | | 26 | | { |
| | 18 | 27 | | var pattern = generator.Item(patterns); |
| | | 28 | | |
| | 18 | 29 | | return random.Randomize(pattern); |
| | | 30 | | } |
| | | 31 | | } |
| | | 32 | | } |
| | | 33 | | |