public void NOR()
        {
            PowerSupplier  power1  = new PowerSupplier();
            PowerSupplier  power2  = new PowerSupplier();
            NORGate        norGate = new NORGate();
            IndicatorLight light   = new IndicatorLight();

            norGate.Output.ConnectTo(light.Input);
            Assert.IsTrue(light.Lighting);

            norGate.Input1.ConnectTo(power1.Output);
            norGate.Input2.ConnectTo(power2.Output);
            Assert.IsTrue(light.Lighting);

            power1.On();
            power2.Off();
            Assert.IsFalse(light.Lighting);
            power1.Off();
            power2.On();
            Assert.IsFalse(light.Lighting);
            power1.On();
            power2.On();
            Assert.IsFalse(light.Lighting);
            power1.Off();
            power2.Off();
            Assert.IsTrue(light.Lighting);
        }
Exemple #2
0
        public void InvertRelayWithContactInput()
        {
            PowerSupplier  power1 = new PowerSupplier();
            PowerSupplier  power2 = new PowerSupplier();
            IndicatorLight light  = new IndicatorLight();
            Relay          relay  = new Relay(invert: true);

            relay.Input.ConnectTo(power1.Output);
            relay.InputOfContact.ConnectTo(power2.Output);
            relay.Output.ConnectTo(light.Input);

            Assert.IsFalse(light.Lighting);
            power1.On();
            power2.Off();
            Assert.IsFalse(light.Lighting);
            power1.On();
            power2.On();
            Assert.IsFalse(light.Lighting);
            power1.Off();
            power2.On();
            Assert.IsTrue(light.Lighting);
            power1.Off();
            power2.Off();
            Assert.IsFalse(light.Lighting);
        }
        public void PowerWireLight()
        {
            PowerSupplier  power = new PowerSupplier();
            Wire           wire  = new Wire();
            IndicatorLight light = new IndicatorLight();

            wire.Connect(power.Output, light.Input);

            Assert.IsFalse(light.Lighting);

            power.On();
            Assert.IsTrue(light.Lighting);
            power.On();
            Assert.IsTrue(light.Lighting);
            power.Off();
            Assert.IsFalse(light.Lighting);
            power.Off();
            Assert.IsFalse(light.Lighting);
            power.Toggle();
            Assert.IsTrue(light.Lighting);
            power.Toggle();
            Assert.IsFalse(light.Lighting);
            power.Toggle();
            Assert.IsTrue(light.Lighting);
            power.Toggle();
            Assert.IsFalse(light.Lighting);

            power.On();
            Assert.IsTrue(light.Lighting);
            light.Input.DisconnectEndpoint();
            Assert.IsFalse(light.Lighting);
            power.On();
            Assert.IsFalse(light.Lighting);
        }
        public void Add1To0()
        {
            _power1.On();
            _power2.Off();

            Assert.IsTrue(_lightSum.Lighting);
            Assert.IsFalse(_lightCarry.Lighting);
        }
        public void Input10()
        {
            _power1.On();
            _power2.Off();

            Assert.IsFalse(_light00.Lighting);
            Assert.IsFalse(_light01.Lighting);
            Assert.IsTrue(_light10.Lighting);
            Assert.IsFalse(_light11.Lighting);
        }
Exemple #6
0
 public void Add0To0WithCarryIn()
 {
     _8BitsNumber1Switches.Set();
     _8BitsNumber2Switches.Set();
     _carryInPowerFor8Bits.On();
     Assert8BitsResultEquals("1");
 }
Exemple #7
0
        public void EnableSetData()
        {
            _powerDataLevelTriggered.On();
            _powerClockLevelTriggered.On();

            Assert.IsTrue(_lightQLevelTriggered.Lighting);
            Assert.IsFalse(_lightQBarLevelTriggered.Lighting);

            _powerDataLevelTriggered.Off();
            _powerClockLevelTriggered.On();

            Assert.IsFalse(_lightQLevelTriggered.Lighting);
            Assert.IsTrue(_lightQBarLevelTriggered.Lighting);
        }
 public void Sub0By0_16Bits()
 {
     _16BitsNumber1Switches.Set();
     _16BitsNumber2Switches.Set();
     _turnSub16Bits.On();
     Assert16BitsResultEquals("0");
     Assert.IsFalse(_overflowUnderflowLight16Bits.Lighting);
 }
        public void AbleToOscillate()
        {
            IInputEndpoint input = new InputEndpoint();

            input.ConnectTo(_oscillator10Hz.Output);
            input.Receive += (sd, sgn) =>
            {
                Thread.Sleep(1);
                _count = (Int32)_count + 1;
            };

            ThreadHelper.ExecuteThenSleepShortly(() => _startPower.On(), 500);
            _startPower.Off();
            Assert.IsTrue((Int32)_count > 0);
        }
        public void Oscillate25HzOnTime()
        {
            IOscillator   oscillator = new Oscillator(20);
            PowerSupplier power      = new PowerSupplier();

            power.Output.ConnectTo(oscillator.Start);

            _count = 0;
            Boolean        oscillating = false;
            IInputEndpoint input       = new InputEndpoint();

            input.ConnectTo(oscillator.Output);
            input.Receive += (sd, sgn) =>
            {
                Thread.Sleep(1);
                if ((Int32)_count >= 5)
                {
                    _startPower.Off();
                }
                else
                {
                    _count = (Int32)_count + 1;
                }
            };

            ThreadHelper.ExecuteThenSleepShortly(() => power.On(), 200);
            Assert.AreEqual(_count, 5);

            _count = 0;
            ThreadHelper.ExecuteThenSleepShortly(() => power.On(), 100);
            Assert.AreEqual(_count, 5);

            _count = 0;
            ThreadHelper.ExecuteThenSleepShortly(() => power.On(), 40);
            Assert.IsTrue((Int32)_count < 5);
        }
Exemple #11
0
        public void InvertRelay()
        {
            PowerSupplier  power = new PowerSupplier();
            IndicatorLight light = new IndicatorLight();
            Relay          relay = new Relay(invert: true);

            relay.Input.ConnectTo(power.Output);
            relay.Output.ConnectTo(light.Input);

            power.On();
            Assert.IsFalse(light.Lighting);
            power.Off();
            Assert.IsTrue(light.Lighting);
            power.Toggle();
            Assert.IsFalse(light.Lighting);
            power.Toggle();
            Assert.IsTrue(light.Lighting);
        }
Exemple #12
0
        public void DefaultInvertor()
        {
            PowerSupplier  power    = new PowerSupplier();
            IndicatorLight light    = new IndicatorLight();
            Invertor       invertor = new Invertor();

            invertor.Input.ConnectTo(power.Output);
            invertor.Output.ConnectTo(light.Input);

            power.On();
            Assert.IsFalse(light.Lighting);
            power.Off();
            Assert.IsTrue(light.Lighting);
            power.Toggle();
            Assert.IsFalse(light.Lighting);
            power.Toggle();
            Assert.IsTrue(light.Lighting);
        }
Exemple #13
0
        public void DelayRelay()
        {
            Int32         delayMilliseconds = 50;
            PowerSupplier power             = new PowerSupplier();
            Relay         relay             = new Relay(delayMilliseconds: delayMilliseconds);
            InputEndpoint input             = new InputEndpoint();
            Stopwatch     timer             = new Stopwatch();

            input.Receive += (s, sg) => { if (sg == 1)
                                          {
                                              timer.Stop();
                                          }
            };

            relay.Input.ConnectTo(power.Output);
            relay.Output.ConnectTo(input);

            timer.Start();
            power.On();

            var deltaMilliseconds = Math.Abs(timer.ElapsedMilliseconds - delayMilliseconds);

            Assert.IsTrue(deltaMilliseconds <= 1);
        }
Exemple #14
0
        public void Delayer999Milliseconds()
        {
            Int32          delayMilliseconds = 999;
            PowerSupplier  power             = new PowerSupplier();
            Delayer        delayer           = new Delayer(delayMilliseconds);
            IInputEndpoint input             = new InputEndpoint();
            Stopwatch      timer             = new Stopwatch();

            input.Receive += (s, sg) => { if (sg == 1)
                                          {
                                              timer.Stop();
                                          }
            };

            delayer.Input.ConnectTo(power.Output);
            delayer.Output.ConnectTo(input);

            timer.Start();
            power.On();

            var deltaMilliseconds = Math.Abs(timer.ElapsedMilliseconds - delayMilliseconds);

            Assert.IsTrue(deltaMilliseconds <= 2);
        }
        public void MultiOR()
        {
            PowerSupplier power1   = new PowerSupplier();
            PowerSupplier power2   = new PowerSupplier();
            PowerSupplier power3   = new PowerSupplier();
            PowerSupplier power4   = new PowerSupplier();
            PowerSupplier power5   = new PowerSupplier();
            MultiORGate   mtORGate = new MultiORGate(5);

            mtORGate.ConnectInputsWith(power1.Output, power2.Output, power3.Output, power4.Output, power5.Output);
            IndicatorLight light = new IndicatorLight();

            mtORGate.Output.ConnectTo(light.Input);
            Assert.IsFalse(light.Lighting);

            power1.On();
            power2.Off();
            power3.Off();
            power4.Off();
            power5.Off();
            Assert.IsTrue(light.Lighting);
            power1.On();
            power2.On();
            power3.Off();
            power4.Off();
            power5.Off();
            Assert.IsTrue(light.Lighting);
            power1.On();
            power2.On();
            power3.On();
            power4.Off();
            power5.Off();
            Assert.IsTrue(light.Lighting);
            power1.On();
            power2.On();
            power3.On();
            power4.On();
            power5.Off();
            Assert.IsTrue(light.Lighting);
            power1.On();
            power2.On();
            power3.On();
            power4.On();
            power5.On();
            Assert.IsTrue(light.Lighting);
            power1.Off();
            power2.On();
            power3.Off();
            power4.Off();
            power5.Off();
            Assert.IsTrue(light.Lighting);
            power1.Off();
            power2.On();
            power3.On();
            power4.Off();
            power5.Off();
            Assert.IsTrue(light.Lighting);
            power1.Off();
            power2.On();
            power3.On();
            power4.On();
            power5.Off();
            Assert.IsTrue(light.Lighting);
            power1.Off();
            power2.On();
            power3.On();
            power4.On();
            power5.On();
            Assert.IsTrue(light.Lighting);
            power1.Off();
            power2.Off();
            power3.On();
            power4.Off();
            power5.Off();
            Assert.IsTrue(light.Lighting);
            power1.Off();
            power2.Off();
            power3.On();
            power4.On();
            power5.Off();
            Assert.IsTrue(light.Lighting);
            power1.Off();
            power2.Off();
            power3.On();
            power4.On();
            power5.On();
            Assert.IsTrue(light.Lighting);
            power1.Off();
            power2.Off();
            power3.Off();
            power4.On();
            power5.Off();
            Assert.IsTrue(light.Lighting);
            power1.Off();
            power2.Off();
            power3.Off();
            power4.On();
            power5.On();
            Assert.IsTrue(light.Lighting);
            power1.Off();
            power2.Off();
            power3.Off();
            power4.Off();
            power5.On();
            Assert.IsTrue(light.Lighting);
            power1.Off();
            power2.Off();
            power3.Off();
            power4.Off();
            power5.Off();
            Assert.IsFalse(light.Lighting);
        }
Exemple #16
0
 public void Complement00000000()
 {
     _switches8.Set();
     _invertPwr.On();
     _resultLights8.AssertEquals("11111111");
 }
Exemple #17
0
 public void Invert0000000000000000_For16Bits()
 {
     _switches16.Set();
     _invertPwr16.On();
     _resultLights16.AssertEquals("1111111111111111");
 }
Exemple #18
0
 public void AbleToSet()
 {
     _powerSet.On();
     Assert.IsTrue(_lightSet.Lighting);
     Assert.IsFalse(_lightReset.Lighting);
 }