Beispiel #1
0
 public GarageNewRepo(GarageConfig config, ILogger <GarageRepo> logger)
 {
     _config = config;
     _logger = logger;
     Pi.Init <BootstrapWiringPi>();
     InitPins();
 }
Beispiel #2
0
        public void InitTests()
        {
            _PinMappings     = new Dictionary <int, bool>();
            _PinOpenMappings = new Dictionary <int, bool>();
            _PinModeMappings = new Dictionary <int, bool>();

            _GarageConfig = new GarageConfig()
            {
                TogglePin = 4, ClosedPin = 27
            };

            _MockGpioController = new Mock <GpioController>();
            _MockLogger         = new Mock <AbstractLogger <GarageRepo> >();

            _MockLogger.Setup(f => f.Log(LogLevel.Information, It.IsAny <Exception>(), It.IsAny <string>()));

            _MockGpioController.Setup(f => f.IsPinOpen(It.IsAny <int>())).Returns((int x) => GetPinOpenValue(x));
            _MockGpioController.Setup(f => f.OpenPin(It.IsAny <int>())).Callback((int x) => ModifyPinOpen(x, true));
            _MockGpioController.Setup(f => f.ClosePin(It.IsAny <int>())).Callback((int x) => ModifyPinOpen(x, false));
            _MockGpioController.Setup(f => f.SetPinMode(It.IsAny <int>(), It.IsAny <PinMode>())).Callback((int pin, PinMode mode) => ModifyPinMode(pin, mode));
            _MockGpioController.Setup(f => f.Write(It.IsAny <int>(), It.IsAny <PinValue>())).Callback((int pin, PinValue value) => ModifyPin(pin, value));
        }
Beispiel #3
0
 public GarageRepo(GpioController gpioController, GarageConfig config, ILogger <GarageRepo> logger) : base(gpioController)
 {
     _config = config;
     _logger = logger;
 }