Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace aweXpect.Core.Constraints;
/// </summary>
public abstract partial class ConstraintResult
{
#pragma warning disable S2166 // Rename this class to remove "Exception" or correct its inheritance
/// <summary>
/// A failed <see cref="ConstraintResult" /> due to an <see cref="Exception" />.
/// </summary>
Expand Down Expand Up @@ -69,4 +70,5 @@ public override bool TryGetValue<TValue>([NotNullWhen(true)] out TValue? value)
public override ConstraintResult Negate()
=> _inner.Negate();
}
#pragma warning restore S2166 // Rename this class to remove "Exception" or correct its inheritance
}
70 changes: 39 additions & 31 deletions Source/aweXpect.Core/Core/ManualExpectationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,6 @@ public class ManualExpectationBuilder<TValue>(
: ExpectationBuilder("", grammars),
IEqualityComparer<ManualExpectationBuilder<TValue>>
{
/// <inheritdoc cref="IEqualityComparer{T}.Equals(T, T)" />
public bool Equals(ManualExpectationBuilder<TValue>? x, ManualExpectationBuilder<TValue>? y)
{
if (x is null && y is null)
{
return true;
}

if (x is null || y is null)
{
return false;
}

return x.Equals(y);
}

/// <inheritdoc cref="IEqualityComparer{T}.GetHashCode(T)" />
public int GetHashCode(ManualExpectationBuilder<TValue> obj)
=> obj.GetHashCode();

/// <inheritdoc cref="object.Equals(object?)" />
public override bool Equals(object? obj) => obj is ManualExpectationBuilder<TValue> other && Equals(other);

/// <summary>
/// Determines whether the <paramref name="other" /> object is equal to the current object.
/// </summary>
protected virtual bool Equals(ManualExpectationBuilder<TValue> other) => GetRootNode().Equals(other.GetRootNode());

/// <inheritdoc cref="object.GetHashCode()" />
public override int GetHashCode() => GetRootNode().GetHashCode();

/// <summary>
/// Appends the expectation of the root node to the <paramref name="stringBuilder" />.
/// </summary>
Expand Down Expand Up @@ -99,4 +68,43 @@ public override string ToString()
AppendExpectation(sb);
return sb.ToString();
}

#region Equals methods

/// <inheritdoc cref="IEqualityComparer{T}.Equals(T, T)" />
public bool Equals(ManualExpectationBuilder<TValue>? x, ManualExpectationBuilder<TValue>? y)
{
if (x is null && y is null)
{
return true;
}

if (x is null || y is null)
{
return false;
}

return x.Equals(y);
}

/// <inheritdoc cref="object.Equals(object?)" />
public override bool Equals(object? obj) => obj is ManualExpectationBuilder<TValue> other && Equals(other);

/// <summary>
/// Determines whether the <paramref name="other" /> object is equal to the current object.
/// </summary>
protected virtual bool Equals(ManualExpectationBuilder<TValue> other) => GetRootNode().Equals(other.GetRootNode());

#endregion

#region GetHashCode methods

/// <inheritdoc cref="IEqualityComparer{T}.GetHashCode(T)" />
public int GetHashCode(ManualExpectationBuilder<TValue> obj)
=> obj.GetHashCode();

/// <inheritdoc cref="object.GetHashCode()" />
public override int GetHashCode() => GetRootNode().GetHashCode();

#endregion
}
2 changes: 1 addition & 1 deletion Source/aweXpect.Core/Core/Nodes/AndNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public override void SetReason(IBecauseReason becauseReason)
{
if (_nodes.Any() && Current is ExpectationNode expectationNode && expectationNode.IsEmpty())
{
_nodes.Last().Item2.SetReason(becauseReason);
_nodes[^1].Item2.SetReason(becauseReason);
Comment thread
vbreuss marked this conversation as resolved.
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Source/aweXpect.Core/Core/Nodes/OrNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public override void SetReason(IBecauseReason becauseReason)
{
if (_nodes.Any() && Current is ExpectationNode expectationNode && expectationNode.IsEmpty())
{
_nodes.Last().Item2.SetReason(becauseReason);
_nodes[^1].Item2.SetReason(becauseReason);
Comment thread
vbreuss marked this conversation as resolved.
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions Source/aweXpect.Core/Equivalency/MemberToIgnore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace aweXpect.Equivalency;

#pragma warning disable S1694 // Convert this abstract class to an interface
/// <summary>
/// Class to specify which members to ignore.
/// </summary>
Expand Down Expand Up @@ -39,3 +40,4 @@ public override bool IgnoreMember(string memberPath, Type memberType, MemberInfo
public override string ToString() => $"\"{memberName}\"";
}
}
#pragma warning restore S1694 // Convert this abstract class to an interface
2 changes: 2 additions & 0 deletions Source/aweXpect.Core/Results/ToleranceEqualityResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace aweXpect.Results;

#pragma warning disable S2436 // Reduce the number of generic parameters
/// <summary>
/// The result of an expectation with an underlying value of type <typeparamref name="TType" />
/// that allows specifying a <typeparamref name="TTolerance" />.
Expand Down Expand Up @@ -52,3 +53,4 @@ public AndOrResult<TType, TThat, TSelf> Within(TTolerance tolerance)
return this;
}
}
#pragma warning restore S2436 // Reduce the number of generic parameters
3 changes: 2 additions & 1 deletion Tests/aweXpect.Internal.Tests/aweXpect.Internal.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\..\Source\aweXpect.Frameworks\aweXpect.Frameworks.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\..\Source\aweXpect.Frameworks\aweXpect.Frameworks.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
<ProjectReference Include="..\..\Source\aweXpect\aweXpect.csproj"/>
</ItemGroup>

<ItemGroup>
<PackageReference Remove="Nullable"/>
<PackageReference Include="aweXpect.Chronology"/>
<PackageReference Include="FluentAssertions"/>
<ProjectReference Include="..\..\Source\aweXpect.Analyzers\aweXpect.Analyzers.csproj"
Expand Down