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);
        }
示例#2
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);
        }
示例#3
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);
        }