Skip to content

Commit

Permalink
Made the tests more reliable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Richards committed Oct 28, 2020
1 parent 20348eb commit 865a68f
Show file tree
Hide file tree
Showing 8 changed files with 990 additions and 7 deletions.
2 changes: 2 additions & 0 deletions zxcvbn-core-test/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// a specific target and scoped to a namespace, type, member, etc.

using System.Diagnostics.CodeAnalysis;
using Xunit;

[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "To match this project's coding style.")]
[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1200:Using directives should be placed correctly", Justification = "To match this project's coding style.")]
Expand All @@ -12,3 +13,4 @@
[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1208:System using directives should be placed before other using directives", Justification = "Using CodeMaid for this task.")]
[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "This isn't actually publicly released.")]
[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:File should have header", Justification = "No header required.")]
[assembly: CollectionBehavior(DisableTestParallelization = true)]
4 changes: 1 addition & 3 deletions zxcvbn-core-test/Matcher/SpatialMatcherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ public void MatchesGeneralPattern(string pattern, string keyboard, int turns, in
public void MatchesSpatialPatternSurroundedByNonSpatialPatterns()
{
var matcher = new SpatialMatcher();
SpatialMatcher.SpatialGraphs = SpatialMatcher.SpatialGraphs.Where(g => g.Name == "qwerty").ToList().AsReadOnly();

var pattern = "6tfGHJ";
var password = $"rz!{pattern}%z";
var result = matcher.MatchPassword(password).OfType<SpatialMatch>().ToList();
var result = matcher.MatchPassword(password).OfType<SpatialMatch>().Where(m => m.Graph == "qwerty").ToList();

var expected = new[]
{
Expand Down
2 changes: 1 addition & 1 deletion zxcvbn-core/FeedbackItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class FeedbackItem
public IList<string> Suggestions { get; internal set; }

/// <summary>
/// Gets or sets the warning that should be the headline for the user.
/// Gets the warning that should be the headline for the user.
/// </summary>
public string Warning { get; internal set; }
}
Expand Down
1 change: 0 additions & 1 deletion zxcvbn-core/Matcher/DateMatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace Zxcvbn.Matcher
///
/// This isn't true date parsing. Invalid dates like 31 February will be allowed.
/// </remarks>
/// </summary>
internal class DateMatcher : IMatcher
{
private const int MaxYear = 2050;
Expand Down
3 changes: 3 additions & 0 deletions zxcvbn-core/Matcher/Matches/DateMatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class DateMatch : Match
/// </summary>
public int Month { get; internal set; }

/// <summary>
/// Gets the name of the pattern matcher used to generate this match.
/// </summary>
public override string Pattern => "date";

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions zxcvbn-core/Matcher/SpatialMatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ internal class SpatialMatcher : IMatcher
private const string ShiftedRegex = "[~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:\"ZXCVBNM<>?]";

/// <summary>
/// Gets or sets the spatial graphs to match against.
/// Gets the spatial graphs to match against.
/// </summary>
internal static ReadOnlyCollection<SpatialGraph> SpatialGraphs { get; set; } = GenerateSpatialGraphs();
internal static ReadOnlyCollection<SpatialGraph> SpatialGraphs { get; } = GenerateSpatialGraphs();

/// <summary>
/// Find spatial matches in <paramref name="password"/>.
Expand Down
4 changes: 4 additions & 0 deletions zxcvbn-core/zxcvbn-core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<RootNamespace>Zxcvbn</RootNamespace>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|AnyCPU'">
<DocumentationFile>C:\Users\trich\Source\Repos\trichards57\zxcvbn-cs\zxcvbn-core\zxcvbn-core.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="Dictionaries\*.lst" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
</ItemGroup>
Expand Down
Loading

0 comments on commit 865a68f

Please sign in to comment.