-
Notifications
You must be signed in to change notification settings - Fork 397
Replace ToUnit(UnitSystem) from the IQuantity<TUnit> interface with an extension method #1606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…tensions - removed the As(UnitSystem) method from the IQuantity interface
Split tests into ToUnit vs ToUnitTyped Update calls to ToUnitTyped where output is IQuantity.
…interface with an extension method ([Obsolete]) - renamed the ToUnitUntyped extension back to ToUnit and made it [Obsolete] - replaced the generated UnitSystem tests for the IQuantity / IQuantity<TUnit> with a single set of tests in the IQauntityTests
@angularsen This corresponds to option 2) from this comment: #1600 (comment) |
public void ToUnit_UnitSystem_ReturnsValueInDimensionlessUnit() | ||
{{ | ||
Assert.Multiple(() => | ||
{{ | ||
var quantity = new {_quantity.Name}(value: 1, unit: {_baseUnitFullName}); | ||
|
||
{_quantity.Name} convertedQuantity = quantity.ToUnit(UnitSystem.SI); | ||
|
||
Assert.Equal({_baseUnitFullName}, convertedQuantity.Unit); | ||
Assert.Equal(quantity.Value, convertedQuantity.Value); | ||
}}, () => | ||
{{ | ||
IQuantity<{_unitEnumName}> quantity = new {_quantity.Name}(value: 1, unit: {_baseUnitFullName}); | ||
|
||
IQuantity<{_unitEnumName}> convertedQuantity = quantity.ToUnit(UnitSystem.SI); | ||
|
||
Assert.Equal({_baseUnitFullName}, convertedQuantity.Unit); | ||
Assert.Equal(quantity.Value, convertedQuantity.Value); | ||
}}); | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've only kept the concrete part of this test, but on second thought there shouldn't really be any need for it to exist here either- as we already have tests for the UnitSystem
constructor.
In case we decide to move forward with the removal of the interface methods from the interface in v6
, then these tests should probably go to another test file- something like QuantityExtensionsTests
.
One point I forgot to mention in the other thread was the requirement for So, there you have it, another thing for you to consider (I can't say I have any preferences- one way or the other). |
ToUnit(UnitSystem)
overload from theIQuantity<TUnit>
interface with an extension method ([Obsolete]
)ToUnitUntyped
extension back toToUnit
and made it[Obsolete]
UnitSystem
tests for theIQuantity
/IQuantity<TUnit>
with a single set of tests in theIQauntityTests