Main Site Documentation

Lack of interfaces makes mocks time intensive


#1

Hello,

I am just starting to put together my first project and immediately noticed that the GHIElectronics.NETMF.Hardware.AnalogIn lacks an interface.

I can work around this by extracting an interface and implementing my own class, but it is time intensive.

Could you please put it on your todo list to create interfaces around these classes (input and output) so that we can create mocks off of them?


#2

Just as an example - in order to be able to create unit tests using the analog input, I must create the following:


using System;
using GHIElectronics.NETMF.Hardware;

namespace GHIElectronics.NETMF.Hardware.UnitTestable
{
    public interface IAnalogIn : IDisposable
    {
        int Read();
        void SetLinearScale(int minValue, int maxValue);
    }

    public class AnalogInTestable : AnalogIn
    {
        public AnalogInT(AnalogIn.Pin ain) : base(ain)
        {
        }

        public static IAnalogIn CreateInstance(AnalogIn.Pin ain)
        {
            return (IAnalogIn) new AnalogInT(ain);
        }
    }
}


#3

ok, we will look into it,.