public void CompositeXORTest()
        {
            ObservableCollection <LogicalBase> xorInternalCollectionFrame =
                CreateCollectionFrame.CreateXorShemaFrame();

            LogicalShema xor = new LogicalShema(xorInternalCollectionFrame);

            Assert.AreEqual(2, xor.Inputs.Count);
            Assert.AreEqual(1, xor.Outputs.Count);
            Assert.AreEqual(false, xor.Outputs[0].SignalValue);

            Switch switchOne = new Switch();
            Switch switchTwo = new Switch();

            switchOne.Output.AttachObserver(xor.Inputs[0]);
            switchTwo.Output.AttachObserver(xor.Inputs[1]);

            switchOne.Switching();
            Assert.AreEqual(true, xor.Outputs[0].SignalValue);

            switchTwo.Switching();
            Assert.AreEqual(false, xor.Outputs[0].SignalValue);
        }
Beispiel #2
0
        public void LogicalXorShemaCommandTest()
        {
            ObservableCollection <LogicalBase> xorInternalCollectionFrame =
                CreateCollectionFrame.CreateXorShemaFrame();

            LogicalBaseVM xor = LogicalBaseVM.CreateLogicalShema(xorInternalCollectionFrame);

            SwitchVM switchOne = new SwitchVM();
            SwitchVM switchTwo = new SwitchVM();

            ICommand switchingSwitchOne = switchOne.SwitchingCommand;

            switchingSwitchOne.Execute(null);

            ICommand switchingSwitchTwo = switchOne.SwitchingCommand;

            switchingSwitchOne.Execute(null);

            ICommand selectSignalCommand = switchOne.SelectSignalCommand;

            selectSignalCommand.Execute(null);

            selectSignalCommand = xor.SelectSignalCommand;
            selectSignalCommand.Execute(xor.InputSignals[0]);

            selectSignalCommand = xor.SelectSignalCommand;
            selectSignalCommand.Execute(xor.InputSignals[1]);

            selectSignalCommand = switchTwo.SelectSignalCommand;
            selectSignalCommand.Execute(null);

            Assert.AreEqual(false, xor.OutputSignals[0].SignalValue);

            switchingSwitchOne.Execute(null);
            Assert.AreEqual(true, xor.OutputSignals[0].SignalValue);
        }