Skip to content

IsEqualTo does not check whether an implicit cast is possible from string to value object #351

@edouard-mangel

Description

@edouard-mangel

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
I use classes or records as ValueObjects to wrap my domain primitives. For example, I have my UserId record, which wraps a GUID or a string.

When I test, I don't want to use my constructor, so I want to compare my UserId to a string.
Currently, this assertion fails because String and UserId are of different type.

Check.That(MyValueObject).IsEquivalentTo("Value inside my ValueObject");

Describe the solution you'd like
I would like this assertion to pass, if the value is correct

Describe alternatives you've considered
Currently, I use this, which is functional, but it would be nice to have some syntaxic sugar to this assertion to keep the assertions as fluent as possible.

Check.That(MyValueObject).IsEquivalentTo((MyValueObjectType)"Value inside my ValueObject");

Additional context
I have some implicit operators which convert my ValueObjects to String and vice versa, but they are not called implicitly.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions