Daeer-Projects / Converter.Temperature

The temperature convertions methods created as extension methods.
MIT License
3 stars 0 forks source link

Add base test classes to help with adding new temp scales #66

Open Daeer-Projects opened 1 year ago

Daeer-Projects commented 1 year ago

Is your feature request related to a problem? Please describe. The tests for the From() and To() classes are very long and will only get bigger. When I add a new temp scale, adding more tests is very hard and time consuming.

Describe the solution you'd like I would like some base classes that have a set of properties and tests already available. So, all I have to do is add a class that inherits from the base tests and add any additional tests I think are relevant to the temp scale I am adding.

Describe alternatives you've considered I've already been adding tests as I went when I added the previous temp scales. They take a lot of time.

Additional context The base class for the From() extensions would start like this:

public abstract class BaseFromExtensionTests<TInputType, TOutputType>
    where TInputType : struct
    where TOutputType : TypeBase<TInputType>

It would contain a few properties that could be expanded on for the To() tests.

    protected virtual TInputType HighValue { get; }
    protected virtual TInputType MidHighValue { get; }
    protected virtual TInputType MidValue { get; }
    protected virtual TInputType MidLowValue { get; }
    protected virtual TInputType LowValue { get; }

The classes that would inherit from the base class would have to override the ConvertFrom() method.

Base Class: protected abstract TOutputType ConvertFrom(TInputType value);

Overridden version:

    protected override CelsiusDouble ConvertFrom(
        double value)
    {
        return value.FromCelsius();
    }
Daeer-Projects commented 1 year ago

I have done this work - well started it and done a few test classes. It looks like it is working well.

Daeer-Projects commented 1 year ago

The To() extension tests are not going well.

Daeer-Projects commented 1 year ago

I have made some headway with the To() base test methods. These are for same value tests and simple checks.

The next stage is to add a way to have a collection of inputs and the respective "expected" converted values.

My thoughts at the moment are having abstract methods in the base class for an input (using a generic type) and a DTO that contains all of the expected values when converted. The method could have a collection of these input/output items that might be used in a Theory test.