Skip to content

Commit

Permalink
ft: bump lib versions and add in test whitespaces fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Winner-Timothy Bolorunduro committed Jun 29, 2020
1 parent 66cbefa commit 174f7c5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
24 changes: 19 additions & 5 deletions shortid.Test/ShortId.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,30 @@ public void GenerateCreatesIdsWithoutSpecialCharacters()
{
var id = ShortId.Generate(true, false);
var ans = new[] {"-", "_"}.Any(x => id.Contains(x));

ans.Should().BeFalse();
}

[Fact]
public void GenerateCreatesIdsOfASpecifiedLength()
{
var id = ShortId.Generate(false, true, 8);
id.Length.Should().Be(8);

id
.Length
.Should()
.Be(8);
}

[Fact]
public void SetSeedThrowsWhenCharacterSetIsEmptyOrNull()
{
var seed = string.Empty;
Action action = () => { ShortId.SetCharacters(seed); };
action.Should().Throw<ArgumentException>()

action
.Should()
.Throw<ArgumentException>()
.WithMessage("The replacement characters must not be null or empty.");
}

Expand All @@ -52,7 +60,10 @@ public void SetSeedThrowsWhenCharacterSetIsLessThan20Characters()
{
const string seed = "783ujrcuei039kj4";
Action action = () => { ShortId.SetCharacters(seed); };
action.Should().Throw<InvalidOperationException>()

action
.Should()
.Throw<InvalidOperationException>()
.WithMessage(
"The replacement characters must be at least 20 letters in length and without whitespace.");
}
Expand All @@ -61,7 +72,10 @@ public void SetSeedThrowsWhenCharacterSetIsLessThan20Characters()
public void DoesNotAllowLengthsLessThan7()
{
Action action = () => { ShortId.Generate(6); };
action.Should().ThrowExactly<ArgumentException>()

action
.Should()
.ThrowExactly<ArgumentException>()
.WithMessage("The specified length of 6 is less than the lower limit of 7.");
}

Expand All @@ -81,4 +95,4 @@ public void ShouldAllowForACustomSeed()
.NotThrow<Exception>();
}
}
}
}
4 changes: 3 additions & 1 deletion shortid/shortid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
<PackageIconUrl>https://members.orcid.org/sites/default/files/vector_iD_icon.svg</PackageIconUrl>
<RepositoryUrl>https://github.com/bolorundurowb/shortid/</RepositoryUrl>
<PackageTags>shortid short id databse key primarykey mongodb sql</PackageTags>
<PackageReleaseNotes>update net standard support</PackageReleaseNotes>
<PackageReleaseNotes>- add a new configuration option
- add better thread safety features</PackageReleaseNotes>
<Authors>Bolorunduro Winner-Timothy</Authors>
<Description>A library that generates random Id's from 7 to 14 characters. Id's generated can be used as primary keys for databases or unique identifiers</Description>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Title>shortid</Title>
<RepositoryType>git</RepositoryType>
<PackageVersion>2.0.2</PackageVersion>
</PropertyGroup>
</Project>

0 comments on commit 174f7c5

Please sign in to comment.