Humanizer icon indicating copy to clipboard operation
Humanizer copied to clipboard

Add ToString and comparison operators to ByteRate with tests

Open Cirzen opened this issue 5 years ago • 9 comments

Fixes #802

Here is a checklist you should tick through before submitting a pull request:

  • [x] Implementation is clean
  • [x] Code adheres to the existing coding standards; e.g. no curlies for one-line blocks, no redundant empty lines between methods or code blocks, spaces rather than tabs, etc.
  • [x] No ReSharper warnings
  • [x] There is proper unit test coverage
  • [x] If the code is copied from StackOverflow (or a blog or OSS) full disclosure is included. That includes required license files and/or file headers explaining where the code came from with proper attribution
  • [x] There are very few or no comments (because comments shouldn't be needed if you write clean code)
  • [x] Xml documentation is added/updated for the addition/change
  • [x] Your PR is (re)based on top of the latest commits from the dev branch (more info below)
  • [x] Link to the issue(s) you're fixing from your PR description. Use fixes #<the issue number>
  • [x] Readme is updated if you change an existing feature or add a new one
  • [x] Run either build.cmd or build.ps1 and ensure there are no test failures

Cirzen avatar Mar 26 '19 18:03 Cirzen

CLA assistant check
All CLA requirements met.

dnfclas avatar Mar 26 '19 18:03 dnfclas

Looks like my typo correction has caused one of the tests to fail. I'll revert that change.

Cirzen avatar Mar 26 '19 19:03 Cirzen

Failing on the approve_public_api test, since that's what I've changed. Was

    public class ByteRate
    {
        public ByteRate(Humanizer.Bytes.ByteSize size, System.TimeSpan interval) { }
        public System.TimeSpan Interval { get; }
        public Humanizer.Bytes.ByteSize Size { get; }
        public string Humanize(Humanizer.Localisation.TimeUnit timeUnit = 1) { }
        public string Humanize(string format, Humanizer.Localisation.TimeUnit timeUnit = 1) { }
    }

Now

    public class ByteRate : System.IComparable, System.IComparable<Humanizer.Bytes.ByteRate>, System.IEquatable<Humanizer.Bytes.ByteRate>
    {
        public ByteRate(Humanizer.Bytes.ByteSize size, System.TimeSpan interval) { }
        public System.TimeSpan Interval { get; }
        public Humanizer.Bytes.ByteSize Size { get; }
        public int CompareTo(Humanizer.Bytes.ByteRate other) { }
        public int CompareTo(object obj) { }
        public bool Equals(Humanizer.Bytes.ByteRate other) { }
        public string Humanize(Humanizer.Localisation.TimeUnit timeUnit = 1) { }
        public string Humanize(string format, Humanizer.Localisation.TimeUnit timeUnit = 1) { }
        public override string ToString() { }
        public string ToString(string format, Humanizer.Localisation.TimeUnit timeUnit = 1) { }
    }

Could do with some feedback or guidance on best way to proceed here.

Cirzen avatar Mar 28 '19 10:03 Cirzen

If you run either build.cmd or build.ps1 it should come up with a method of updating the PublicApiApprovalTest.approve_public_api.approved.txt file.

Once that matches the public api, the test will then pass

AKTheKnight avatar Mar 28 '19 12:03 AKTheKnight

Hi Claire, would you be willing to have another look at this, I've hopefully resolved any remaining concerns.

Cirzen avatar Oct 03 '20 23:10 Cirzen

Looks like there's a build error that needs to be resolved?

clairernovotny avatar Oct 03 '20 23:10 clairernovotny

You're right, I jumped the gun. Looks like some issues in Master

Cirzen avatar Oct 04 '20 23:10 Cirzen

Now passing tests

Cirzen avatar Nov 05 '20 12:11 Cirzen

@Cirzen sorry for the delay. can you rebase and re-approve the api changes

SimonCropp avatar Feb 14 '24 11:02 SimonCropp