Пример #1
0
        public void CanToggleForSetIterations()
        {
            //arrange
            var fs = Substitute.For <IFileSystem>();

            fs.Read("/sys/class/gpio/gpio123/direction").Returns("out");
            fs.Read("/sys/class/gpio/gpio123/value").Returns("0");
            var pinInterface = new LinuxPinInterface(123, fs);

            //act
            pinInterface.Toggle(TimeSpan.TicksPerMillisecond, 10);

            //assert
            fs.Received(20).Write("/sys/class/gpio/gpio123/value", Arg.Any <string>());
        }
Пример #2
0
        public void ToggleTurnsOffIfOn()
        {
            //arrange
            var fs = Substitute.For <IFileSystem>();

            fs.Read("/sys/class/gpio/gpio123/direction").Returns("out");
            var pinInterface = new LinuxPinInterface(123, fs)
            {
                Power = PowerValue.On
            };

            //act
            pinInterface.Toggle();

            //assert
            Assert.Equal(PowerValue.Off, pinInterface.Power);
        }