Skip to content

Conversation

tmilnthorp
Copy link
Collaborator

No description provided.

tmilnthorp and others added 5 commits March 1, 2019 15:32
Adding As/ToUnit conversions to UnitSystem
@tmilnthorp
Copy link
Collaborator Author

Fat fingers + copy paste. A recipe for disaster in test naming 😆

Match the old descriptions and use singular unit instead of plural units.
Copy link
Owner

@angularsen angularsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a nice addition 👍

}

[Fact]
public void ToUnit_ImperialGivenSIUnitSystem_ReturnsSIValue()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand it right, this test would pass regardless if we pass it SI unit system or some other system. The quantity doesn't change when changing the unit.
Maybe the test should instead assert this:

Assert.Equal(LengthUnit.SquareMeter, imperialArea.ToUnit(UnitSystem.SI).Unit)

If so, maybe also rename the test to something like this ToUnit_ImperialQuantityGivenSIUnitSystem_ConvertsToSIUnit.

Same for other files below.

Copy link
Collaborator Author

@tmilnthorp tmilnthorp Mar 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will pass only for a unit system that has a base unit in meters. You could define one in feet and it would have a different quantity value and unit (whatever value in square feet). That conversion is handled by other tests, but I added it here regardless. I can change it for sure.

Copy link
Owner

@angularsen angularsen Mar 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, I forgot this one before merging.

Are you saying that this test will only pass because ToUnit(UnitSystem.SI) converts to the Meter unit?
I think that is false, because the Area equality check converts to the default/base unit before comparing values.

As an example, I just tested this: Length.FromCentimeters(100).Equals(Length.FromMeters(1)) is true.

This is why I think this test does not actually test the ToUnit behavior at all - because it could have incorrectly converted to nautical mile unit and it would still equal the left hand side.

}
/// <summary>
/// Converts the quantity into a quantity which has units compatible with the given <see cref="UnitSystem"/>.
Copy link
Owner

@angularsen angularsen Mar 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar nazi 🎈 , but which should be preceded with a comma.
I also changed the descriptions a bit in IQuantity, so after you review those then match this xmldoc up with those and regen the files.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinging this one, please review my xmldoc revisions in IQuantity, and make this consistent with that, then regen.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I just did an inheritdoc to keep things cleaner.

tmilnthorp and others added 3 commits March 2, 2019 20:57
Adding AreAllBaseUnitsDefined method
Doc update
Copy link
Owner

@angularsen angularsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I edited the xmldoc too, please review

@tmilnthorp
Copy link
Collaborator Author

Yup! Sorry, I got busy with my daughter and didn't get to finish. Let me take a look now.

Inherit doc
@angularsen
Copy link
Owner

Ok nice!

@angularsen angularsen merged commit 3ecea2a into angularsen:master Mar 4, 2019
@angularsen angularsen changed the title Adding As/ToUnit conversions to UnitSystem Add As/ToUnit conversions to UnitSystem Mar 4, 2019
Copy link
Owner

@angularsen angularsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already merged the PR, but forgot to follow up on this test. I think we maybe need to fix this.

}

[Fact]
public void ToUnit_ImperialGivenSIUnitSystem_ReturnsSIValue()
Copy link
Owner

@angularsen angularsen Mar 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, I forgot this one before merging.

Are you saying that this test will only pass because ToUnit(UnitSystem.SI) converts to the Meter unit?
I think that is false, because the Area equality check converts to the default/base unit before comparing values.

As an example, I just tested this: Length.FromCentimeters(100).Equals(Length.FromMeters(1)) is true.

This is why I think this test does not actually test the ToUnit behavior at all - because it could have incorrectly converted to nautical mile unit and it would still equal the left hand side.

@tmilnthorp
Copy link
Collaborator Author

Oh yea. #629 to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants