4
4
// Created : 01-19-2019
5
5
//
6
6
// Last Modified By : David McCarter
7
- // Last Modified On : 05-27 -2020
7
+ // Last Modified On : 06-03 -2020
8
8
// ***********************************************************************
9
9
// <copyright file="RandomData.cs" company="dotNetTips.Utility.Standard.Tester">
10
10
// Copyright (c) dotNetTips.com - McCarter Consulting. All rights reserved.
11
11
// </copyright>
12
12
// <summary></summary>
13
13
// ***********************************************************************
14
- using dotNetTips . Utility . Standard . Extensions ;
15
- using dotNetTips . Utility . Standard . OOP ;
16
- using dotNetTips . Utility . Standard . Tester . Collections ;
17
- using dotNetTips . Utility . Standard . Tester . Models ;
18
- using dotNetTips . Utility . Standard . Tester . Properties ;
19
14
using System ;
20
15
using System . Collections . Generic ;
21
16
using System . Collections . Immutable ;
22
17
using System . IO ;
23
18
using System . Linq ;
24
19
using System . Text ;
25
20
using System . Threading . Tasks ;
21
+ using dotNetTips . Utility . Standard . Extensions ;
22
+ using dotNetTips . Utility . Standard . OOP ;
23
+ using dotNetTips . Utility . Standard . Tester . Collections ;
24
+ using dotNetTips . Utility . Standard . Tester . Models ;
25
+ using dotNetTips . Utility . Standard . Tester . Properties ;
26
26
27
27
namespace dotNetTips . Utility . Standard . Tester
28
28
{
@@ -74,6 +74,21 @@ public static class RandomData
74
74
/// <value>The long test string.</value>
75
75
public static string LongTestString => Properties . Resources . LongTestString ;
76
76
77
+ /// <summary>
78
+ /// Generates the byte array.
79
+ /// </summary>
80
+ /// <param name="sizeInKb">The size in kb.</param>
81
+ /// <returns>System.Byte[].</returns>
82
+ public static byte [ ] GenerateByteArray ( double sizeInKb )
83
+ {
84
+ var size = Convert . ToInt32 ( sizeInKb * 1024 ) ;
85
+
86
+ var bytes = new Byte [ size ] ;
87
+ _random . NextBytes ( bytes ) ;
88
+
89
+ return bytes ;
90
+ }
91
+
77
92
/// <summary>
78
93
/// Creates a random character.
79
94
/// </summary>
@@ -196,7 +211,7 @@ public static (string Path, IEnumerable<string> Files) GenerateFiles(int count =
196
211
197
212
var files = new List < string > ( count ) ;
198
213
199
- for ( int fileCount = 0 ; fileCount < count ; fileCount ++ )
214
+ for ( var fileCount = 0 ; fileCount < count ; fileCount ++ )
200
215
{
201
216
files . Add ( GenerateTempFile ( fileLength ) ) ;
202
217
}
@@ -221,7 +236,7 @@ public static (string Path, IEnumerable<string> Files) GenerateFiles(int count =
221
236
222
237
var files = new List < string > ( count ) ;
223
238
224
- for ( int fileCount = 0 ; fileCount < count ; fileCount ++ )
239
+ for ( var fileCount = 0 ; fileCount < count ; fileCount ++ )
225
240
{
226
241
var fileName = GenerateRandomFileName ( 25 , fileExtension ) ;
227
242
files . Add ( GenerateFile ( fileName , fileLength ) ) ;
@@ -249,7 +264,7 @@ public static IEnumerable<string> GenerateFiles(string path, int count = 100, in
249
264
250
265
Directory . CreateDirectory ( path ) ;
251
266
252
- for ( int fileCount = 0 ; fileCount < count ; fileCount ++ )
267
+ for ( var fileCount = 0 ; fileCount < count ; fileCount ++ )
253
268
{
254
269
var fileName = GenerateRandomFileName ( path ) ;
255
270
files . Add ( GenerateFile ( fileName , fileLength ) ) ;
@@ -290,7 +305,7 @@ public static string GenerateKey()
290
305
/// <example>"446085072052112"</example>
291
306
public static string GenerateNumber ( int length )
292
307
{
293
- Encapsulation . TryValidateParam ( length , 1 , int . MaxValue , nameof ( length ) ) ;
308
+ Encapsulation . TryValidateParam ( value : length , minimumValue : 1 , maximumValue : int . MaxValue , paramName : nameof ( length ) ) ;
294
309
295
310
var sb = new StringBuilder ( length ) ;
296
311
@@ -542,42 +557,6 @@ public static string GenerateWord(int minLength, int maxLength)
542
557
return GenerateWord ( minLength , maxLength , DefaultMinCharacter , DefaultMaxCharacter ) ;
543
558
}
544
559
545
- /// <summary>
546
- /// Generates a list of words.
547
- /// </summary>
548
- /// <param name="count">The word count.</param>
549
- /// <param name="minLength">The minimum length.</param>
550
- /// <param name="maxLength">The maximum length.</param>
551
- /// <returns>ImmutableList<System.String>.</returns>
552
- public static ImmutableList < string > GenerateWords ( int count , int minLength , int maxLength )
553
- {
554
- Encapsulation . TryValidateParam ( count , minimumValue : 1 , paramName : nameof ( count ) ) ;
555
-
556
- var strings = new List < string > ( ) ;
557
-
558
- for ( int wordCount = 0 ; wordCount < count ; wordCount ++ )
559
- {
560
- strings . Add ( GenerateWord ( minLength , maxLength ) ) ;
561
- }
562
-
563
- return strings . ToImmutableList ( ) ;
564
- }
565
-
566
- /// <summary>
567
- /// Generates the byte array.
568
- /// </summary>
569
- /// <param name="sizeInKb">The size in kb.</param>
570
- /// <returns>System.Byte[].</returns>
571
- public static byte [ ] GenerateByteArray ( double sizeInKb )
572
- {
573
- int size = Convert . ToInt32 ( sizeInKb * 1024 ) ;
574
-
575
- Byte [ ] bytes = new Byte [ size ] ;
576
- _random . NextBytes ( bytes ) ;
577
-
578
- return bytes ;
579
- }
580
-
581
560
/// <summary>
582
561
/// Creates a random word.
583
562
/// </summary>
@@ -594,7 +573,7 @@ public static string GenerateWord(int length, char minCharacter, char maxCharact
594
573
595
574
for ( var wordCount = 0 ; wordCount < length ; wordCount ++ )
596
575
{
597
- word . Append ( GenerateCharacter ( minCharacter , maxCharacter ) ) ;
576
+ _ = word . Append ( GenerateCharacter ( minCharacter , maxCharacter ) ) ;
598
577
}
599
578
600
579
return word . ToString ( ) ;
@@ -611,6 +590,27 @@ public static string GenerateWord(int length, char minCharacter, char maxCharact
611
590
/// <example>ACRNFTPAE</example>
612
591
public static string GenerateWord ( int minLength , int maxLength , char minCharacter , char maxCharacter ) => GenerateWord ( GenerateInteger ( minLength , maxLength ) , minCharacter , maxCharacter ) ;
613
592
593
+ /// <summary>
594
+ /// Generates a list of words.
595
+ /// </summary>
596
+ /// <param name="count">The word count.</param>
597
+ /// <param name="minLength">The minimum length.</param>
598
+ /// <param name="maxLength">The maximum length.</param>
599
+ /// <returns>ImmutableList<System.String>.</returns>
600
+ public static ImmutableList < string > GenerateWords ( int count , int minLength , int maxLength )
601
+ {
602
+ Encapsulation . TryValidateParam ( count , minimumValue : 1 , paramName : nameof ( count ) ) ;
603
+
604
+ var strings = new List < string > ( ) ;
605
+
606
+ for ( var wordCount = 0 ; wordCount < count ; wordCount ++ )
607
+ {
608
+ strings . Add ( GenerateWord ( minLength , maxLength ) ) ;
609
+ }
610
+
611
+ return strings . ToImmutableList ( ) ;
612
+ }
613
+
614
614
/// <summary>
615
615
/// Picks a random string from an array.
616
616
/// </summary>
0 commit comments