Skip to content

Commit

Permalink
Fixed some issues introduced by code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tape-Worm committed Jan 4, 2025
1 parent 6c6dd25 commit c003b99
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion Gorgon/Gorgon.Core/IO/GorgonFileExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,12 @@ public string FullExtension
/// <returns>
/// <b>true</b> if the specified <see cref="object" /> is equal to this instance; otherwise, <b>false</b>.
/// </returns>
public override bool Equals(object? obj) => obj is GorgonFileExtension ext ? ext.Equals(this) : base.Equals(obj);
public override bool Equals(object? obj) => obj switch
{
GorgonFileExtension ext => Equals(ext),
string str => Equals(str),
_ => base.Equals(obj),
};

/// <summary>
/// Returns a hash code for this instance.
Expand Down
10 changes: 7 additions & 3 deletions Test/Gorgon.Core.Tests/GorgonFileExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,18 @@ public void OperatorGreaterThanOrEqualShouldReturnTrueWhenLeftIsGreaterThanOrEqu
public void OperatorEqualsShouldReturnTrueWhenExtensionEqualsString()
{
GorgonFileExtension fileExtension = new(".txt", "Text File");
Assert.AreEqual(".txt", fileExtension);
#pragma warning disable MSTEST0037 // Use proper 'Assert' methods
Assert.IsTrue(".txt" == fileExtension);
#pragma warning restore MSTEST0037 // Use proper 'Assert' methods
}

[TestMethod]
public void OperatorNotEqualsShouldReturnFalseWhenExtensionEqualsString()
{
GorgonFileExtension fileExtension = new(".txt", "Text File");
Assert.AreEqual(".txt", fileExtension);
GorgonFileExtension fileExtension = new(".txt1", "Text File");
#pragma warning disable MSTEST0037 // Use proper 'Assert' methods
Assert.IsTrue(".txt" != fileExtension);
#pragma warning restore MSTEST0037 // Use proper 'Assert' methods
}

[TestMethod]
Expand Down

0 comments on commit c003b99

Please sign in to comment.