Exemplo n.º 1
0
        public void WriteSteps_WhenSmallerValuesSize_ClearSteps()
        {
            var  gpio   = new TestGpio();
            uint millis = 0;

            ISsdWriter <ImmutableList <byte> > writer = new DirectSsdWriter(
                ImmutableList <int> .Empty.Add(0).Add(1),
                ImmutableList <int> .Empty.Add(2).Add(3),
                gpio.Write, () => new Ticker(1, millis));

            writer = writer.Write(ImmutableList <byte> .Empty.Add(0b01000000));

            gpio.Clear();

            writer = writer.Tick(++millis);
            gpio.TestWritten(2, false);
            gpio.TestWritten(3, false);
            gpio.TestWritten(0, false);
            gpio.TestWritten(1, false);
            gpio.TestEmpty();

            /*
             * writer = writer.Tick(++millis);
             * gpio.TestWritten(3, false);
             * gpio.TestWritten(0, false);
             * gpio.TestWritten(1, true);
             * gpio.TestWritten(2, true);
             * gpio.TestEmpty();*/
        }
Exemplo n.º 2
0
        public void Creation_Expects_WriteZerosToAllPins()
        {
            var gpio   = new TestGpio();
            var writer = new DirectSsdWriter(
                ImmutableList <int> .Empty.Add(0),
                ImmutableList <int> .Empty.Add(2).Add(3),
                gpio.Write, () => null);

            gpio.TestWritten(2, false);
            gpio.TestWritten(3, false);
            gpio.TestWritten(0, false);
            gpio.TestEmpty();
        }
Exemplo n.º 3
0
        public void WriteSteps_WenInvalidPin_ClearSteps()
        {
            var gpio   = new TestGpio();
            var writer = new DirectSsdWriter(
                ImmutableList <Pin> .Empty.Add(new Pin(0, true)),
                ImmutableList <Pin> .Empty.Add(new Pin(2, true)).Add(new Pin(3, true)),
                gpio.Write, 1);

            writer.Write(0b10000000, 2);
            gpio.TestWritten(2, false);
            gpio.TestWritten(3, false);
            gpio.TestWritten(0, false);
            gpio.TestEmpty();
        }
Exemplo n.º 4
0
        public void CycleSteps_Expects_ToCycle()
        {
            var values = new List <byte>
            {
                0b01000000,
                0b10000000
            };
            var  gpio   = new TestGpio();
            uint millis = 0;

            ISsdWriter <ImmutableList <byte> > writer = new DirectSsdWriter(
                ImmutableList <int> .Empty.Add(0).Add(1),
                ImmutableList <int> .Empty.Add(2).Add(3),
                gpio.Write, () => new Ticker(1, millis));

            writer = writer.Write(ImmutableList <byte> .Empty.Add(0b01000000).Add(0b10000000));

            gpio.Clear();

            writer = writer.Tick(++millis);
            gpio.TestWritten(2, false);
            gpio.TestWritten(0, true);
            gpio.TestWritten(1, false);
            gpio.TestWritten(3, true);
            gpio.TestEmpty();

            Assert.AreEqual(1, writer.NextTick(1));

            writer = writer.Tick(++millis);
            gpio.TestWritten(3, false);
            gpio.TestWritten(0, false);
            gpio.TestWritten(1, true);
            gpio.TestWritten(2, true);
            gpio.TestEmpty();
        }
Exemplo n.º 5
0
        public void ClearSteps_Expects_WriteZerosToAllPins()
        {
            var gpio   = new TestGpio();
            var writer = new DirectSsdWriter(
                ImmutableList <Pin> .Empty.Add(new Pin(0, true)),
                ImmutableList <Pin> .Empty.Add(new Pin(2, true)).Add(new Pin(3, true)),
                gpio.Write, 1);

            writer.Clear();

            gpio.TestWritten(2, false);
            gpio.TestWritten(3, false);
            gpio.TestWritten(0, false);
            gpio.TestEmpty();
        }
Exemplo n.º 6
0
        public void WriteSteps_Expects_ProperSteps()
        {
            var gpio   = new TestGpio();
            var writer = new DirectSsdWriter(
                ImmutableList <Pin> .Empty.Add(new Pin(0, true)).Add(new Pin(1, true)),
                ImmutableList <Pin> .Empty.Add(new Pin(2, true)).Add(new Pin(3, true)),
                gpio.Write, 1);

            writer.Write(0b10000000, 0);

            gpio.TestWritten(3, false);
            gpio.TestWritten(0, true);
            gpio.TestWritten(1, false);
            gpio.TestWritten(2, true);
            gpio.TestEmpty();
        }
Exemplo n.º 7
0
        public void Write_Expects_Written()
        {
            var gpio = new TestGpio();

            ISsdWriter <ImmutableList <byte> > writer = new DirectSsdWriter(
                ImmutableList <int> .Empty.Add(0).Add(1),
                ImmutableList <int> .Empty.Add(2).Add(3),
                gpio.Write, () => null);

            gpio.Clear();

            writer = writer.Write(ImmutableList <byte> .Empty.Add(0b10000000));

            gpio.TestWritten(3, false);
            gpio.TestWritten(0, true);
            gpio.TestWritten(1, false);
            gpio.TestWritten(2, true);
            gpio.TestEmpty();
        }
Exemplo n.º 8
0
        public void CycleSteps_Expects_ToCycle()
        {
            var values = new List <byte>
            {
                0b01000000,
                0b10000000
            };
            var gpio   = new TestGpio();
            var writer = new DirectSsdWriter(
                ImmutableList <Pin> .Empty.Add(new Pin(0, true)).Add(new Pin(1, true)),
                ImmutableList <Pin> .Empty.Add(new Pin(2, true)).Add(new Pin(3, true)),
                gpio.Write, 5);

            var tickable = writer.Write(
                (i) =>
            {
                if (i >= values.Count)
                {
                    return(0);
                }
                return(values[i]);
            }).Tick(0);

            gpio.TestWritten(3, false);
            gpio.TestWritten(0, false);
            gpio.TestWritten(1, true);
            gpio.TestWritten(2, true);
            gpio.TestEmpty();

            tickable = tickable.Tick(5);
            gpio.TestWritten(2, false);
            gpio.TestWritten(0, true);
            gpio.TestWritten(1, false);
            gpio.TestWritten(3, true);
            gpio.TestEmpty();

            tickable = tickable.Tick(10);
            gpio.TestWritten(3, false);
            gpio.TestWritten(0, false);
            gpio.TestWritten(1, true);
            gpio.TestWritten(2, true);
            gpio.TestEmpty();
        }