Skip to content

Commit b6a4bd7

Browse files
Code cleanup.
1 parent 98d01e4 commit b6a4bd7

File tree

4 files changed

+63
-72
lines changed

4 files changed

+63
-72
lines changed

src/Standard/dotNetTips.Utility.Standard.Tester/Models/Coordinate.cs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,7 @@ public struct Coordinate : ICoordinate, IEquatable<Coordinate>
6060
/// <exception cref="NotImplementedException"></exception>
6161
public override bool Equals(object obj)
6262
{
63-
if (ReferenceEquals(this, obj))
64-
{
65-
return true;
66-
}
67-
68-
if (obj is null)
69-
{
70-
return false;
71-
}
72-
73-
throw new NotImplementedException();
63+
return ReferenceEquals(this, obj);
7464
}
7565

7666
/// <summary>
@@ -87,8 +77,8 @@ public override bool Equals(object obj)
8777
public override int GetHashCode()
8878
{
8979
var hashCode = 1861411795;
90-
hashCode = hashCode * -1521134295 + this.X.GetHashCode();
91-
hashCode = hashCode * -1521134295 + this.Y.GetHashCode();
80+
hashCode = (hashCode * -1521134295) + this.X.GetHashCode();
81+
hashCode = (hashCode * -1521134295) + this.Y.GetHashCode();
9282
return hashCode;
9383
}
9484

src/Standard/dotNetTips.Utility.Standard.Tester/RandomData.cs

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44
// Created : 01-19-2019
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 05-27-2020
7+
// Last Modified On : 06-03-2020
88
// ***********************************************************************
99
// <copyright file="RandomData.cs" company="dotNetTips.Utility.Standard.Tester">
1010
// Copyright (c) dotNetTips.com - McCarter Consulting. All rights reserved.
1111
// </copyright>
1212
// <summary></summary>
1313
// ***********************************************************************
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;
1914
using System;
2015
using System.Collections.Generic;
2116
using System.Collections.Immutable;
2217
using System.IO;
2318
using System.Linq;
2419
using System.Text;
2520
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;
2626

2727
namespace dotNetTips.Utility.Standard.Tester
2828
{
@@ -74,6 +74,21 @@ public static class RandomData
7474
/// <value>The long test string.</value>
7575
public static string LongTestString => Properties.Resources.LongTestString;
7676

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+
7792
/// <summary>
7893
/// Creates a random character.
7994
/// </summary>
@@ -196,7 +211,7 @@ public static (string Path, IEnumerable<string> Files) GenerateFiles(int count =
196211

197212
var files = new List<string>(count);
198213

199-
for (int fileCount = 0; fileCount < count; fileCount++)
214+
for (var fileCount = 0; fileCount < count; fileCount++)
200215
{
201216
files.Add(GenerateTempFile(fileLength));
202217
}
@@ -221,7 +236,7 @@ public static (string Path, IEnumerable<string> Files) GenerateFiles(int count =
221236

222237
var files = new List<string>(count);
223238

224-
for (int fileCount = 0; fileCount < count; fileCount++)
239+
for (var fileCount = 0; fileCount < count; fileCount++)
225240
{
226241
var fileName = GenerateRandomFileName(25, fileExtension);
227242
files.Add(GenerateFile(fileName, fileLength));
@@ -249,7 +264,7 @@ public static IEnumerable<string> GenerateFiles(string path, int count = 100, in
249264

250265
Directory.CreateDirectory(path);
251266

252-
for (int fileCount = 0; fileCount < count; fileCount++)
267+
for (var fileCount = 0; fileCount < count; fileCount++)
253268
{
254269
var fileName = GenerateRandomFileName(path);
255270
files.Add(GenerateFile(fileName, fileLength));
@@ -290,7 +305,7 @@ public static string GenerateKey()
290305
/// <example>"446085072052112"</example>
291306
public static string GenerateNumber(int length)
292307
{
293-
Encapsulation.TryValidateParam(length, 1, int.MaxValue, nameof(length));
308+
Encapsulation.TryValidateParam(value: length, minimumValue: 1, maximumValue: int.MaxValue, paramName: nameof(length));
294309

295310
var sb = new StringBuilder(length);
296311

@@ -542,42 +557,6 @@ public static string GenerateWord(int minLength, int maxLength)
542557
return GenerateWord(minLength, maxLength, DefaultMinCharacter, DefaultMaxCharacter);
543558
}
544559

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&lt;System.String&gt;.</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-
581560
/// <summary>
582561
/// Creates a random word.
583562
/// </summary>
@@ -594,7 +573,7 @@ public static string GenerateWord(int length, char minCharacter, char maxCharact
594573

595574
for (var wordCount = 0; wordCount < length; wordCount++)
596575
{
597-
word.Append(GenerateCharacter(minCharacter, maxCharacter));
576+
_ = word.Append(GenerateCharacter(minCharacter, maxCharacter));
598577
}
599578

600579
return word.ToString();
@@ -611,6 +590,27 @@ public static string GenerateWord(int length, char minCharacter, char maxCharact
611590
/// <example>ACRNFTPAE</example>
612591
public static string GenerateWord(int minLength, int maxLength, char minCharacter, char maxCharacter) => GenerateWord(GenerateInteger(minLength, maxLength), minCharacter, maxCharacter);
613592

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&lt;System.String&gt;.</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+
614614
/// <summary>
615615
/// Picks a random string from an array.
616616
/// </summary>

src/Standard/dotNetTips.Utility.Standard.Tester/dotNetTips.Utility.Standard.Tester.csproj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<Version>2020.5.27.2</Version>
5+
<Version>2020.8.9.0</Version>
66
<Authors>David McCarter</Authors>
77
<Company>dotNetTips.com - David McCarter</Company>
88
<Product>dotNetTips.Utility.Standard</Product>
@@ -17,10 +17,11 @@
1717
-- AUG 31 2019: Cleanup of models including fixes.
1818
-- DEC 02 2019: Added new methods for creating ramdom files. Code cleanup.
1919
-- MAR 2020: Quartertly release.
20-
-- MAY 2020: Added more functionality to RandomData.</PackageReleaseNotes>
20+
-- MAY 2020: Added more functionality to RandomData.
21+
-- AUG 2020: Code cleanup.</PackageReleaseNotes>
2122
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
22-
<AssemblyVersion>2020.7.30.39713</AssemblyVersion>
23-
<FileVersion>2020.7.30.39713</FileVersion>
23+
<AssemblyVersion>2020.8.7.37337</AssemblyVersion>
24+
<FileVersion>2020.8.7.37337</FileVersion>
2425
<DebugType>pdbonly</DebugType>
2526
<DebugSymbols>true</DebugSymbols>
2627
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
@@ -51,8 +52,8 @@
5152
</ItemGroup>
5253

5354
<ItemGroup>
54-
<PackageReference Include="dotNetTips.Utility.Standard" Version="2020.5.26.2" />
55-
<PackageReference Include="dotNetTips.Utility.Standard.Extensions" Version="2020.5.26.2" />
55+
<PackageReference Include="dotNetTips.Utility.Standard" Version="2020.8.9" />
56+
<PackageReference Include="dotNetTips.Utility.Standard.Extensions" Version="2020.8.9" />
5657
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
5758
<PrivateAssets>all</PrivateAssets>
5859
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

src/Unit Tests/dotNetTips.Utility.Standard.Tester.Tests/dotNetTips.Utility.Standard.Tester.Tests.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55

66
<IsPackable>false</IsPackable>
77

8-
<AssemblyVersion>2020.7.30.39713</AssemblyVersion>
8+
<AssemblyVersion>2020.8.7.37337</AssemblyVersion>
99

10-
<FileVersion>2020.7.30.39713</FileVersion>
10+
<FileVersion>2020.8.7.37337</FileVersion>
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
15-
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
16-
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
17-
<PackageReference Include="coverlet.collector" Version="1.2.1">
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.0" />
15+
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
16+
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
17+
<PackageReference Include="coverlet.collector" Version="1.3.0">
1818
<PrivateAssets>all</PrivateAssets>
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2020
</PackageReference>

0 commit comments

Comments
 (0)