You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vartestValue=String.Join(", ",new[]{"test1"});varerror=newError("Missing columns from extraction");IEnumerable<(string,string)>groups=new(string,string)[]{("Category",testValue)};foreach(var(key,value)ingroups){error=error.WithMetadata(key,value);}vartestResult=Result.Fail<JObject>(error);// Actvarresult=sut.VerifyMapping(JsonConvert.SerializeObject(mapping),extraction);// AsserttestResult.Should().BeFailure().And.HaveReason("Missing",MessageComparisonLogics.ActualContainsExpected).That.HaveMetadata("Category","test1");// Assertresult.Should().BeFailure().And.HaveReason("Missing",MessageComparisonLogics.ActualContainsExpected).That.HaveMetadata("Category","test1");
Where result is the real value I'm trying to check and testResult is a variable I've created to try and duplicate. As you can see bellow they have the same structure.
However, the result assertions fail, but testResult don't. I've then tried to step through the actual actions of the assertion, where I've found the following issue (result assertion).
The equality comparison here returns false for "obj == metatdataValue, but when I tried obj.Equals(metatdataValue)` it returned true.
Do you have any idea why would this be happening, or what would be a way to fix it? Sorry if it's obvious, I'm quite new to dotnet
The text was updated successfully, but these errors were encountered:
Causes the testResult to fail as well. Is this intended behaviour?
WhoAteDaCake
changed the title
[FluentResults.Extensions.FluentAssertions.Test] HaveMetadata behaves differently for same result types
[FluentResults.Extensions.FluentAssertions.Test] HaveMetadata breaks when new string is used
Dec 8, 2022
I've got the same problem, but when using the Guid instead of the string.
This error happens due to Guid boxing as the Guid equality operator compares objects rather than values.
As you can see here I have obj and metadataValue with the same value, but as Guid were boxed earlier they represent different objects. Using obj.Equals(metatdataValue) will resolve this issue, due to value comparison.
The following fails in my XUnit test suite:
Where
result
is the real value I'm trying to check andtestResult
is a variable I've created to try and duplicate. As you can see bellow they have the same structure.However, the
result
assertions fail, buttestResult
don't. I've then tried to step through the actual actions of the assertion, where I've found the following issue (result
assertion).The equality comparison here returns false for "obj == metatdataValue
, but when I tried
obj.Equals(metatdataValue)` it returned true.Do you have any idea why would this be happening, or what would be a way to fix it? Sorry if it's obvious, I'm quite new to dotnet
The text was updated successfully, but these errors were encountered: