Example #1
0
        public void TestAnd()
        {
            And    and       = new And();
            Input  InputOne  = (Input)and.FindName("InputOne");
            Input  InputTwo  = (Input)and.FindName("InputTwo");
            Output andOutput = (Output)and.FindName("Output");

            Output testOutputOne = new Output();

            testOutputOne.State = false;
            Output testOutputTwo = new Output();

            testOutputTwo.State = false;

            InputOne.LinkInputs(testOutputOne);
            InputTwo.LinkInputs(testOutputTwo);

            InputOne._state_StateChange();
            InputTwo._state_StateChange();

            //Input 0 0
            Assert.IsTrue(InputOne.State == false);
            Assert.IsTrue(InputTwo.State == false);
            Assert.IsTrue(andOutput.State == false);

            testOutputOne.State = true;
            InputOne._state_StateChange();

            //Input 1 0
            Assert.IsTrue(InputOne.State == true);
            Assert.IsTrue(InputTwo.State == false);
            Assert.IsTrue(andOutput.State == false);

            testOutputTwo.State = true;
            InputTwo._state_StateChange();

            //Input 1 1
            Assert.IsTrue(InputOne.State == true);
            Assert.IsTrue(InputTwo.State == true);
            Assert.IsTrue(andOutput.State == true);

            testOutputOne.State = false;
            InputOne._state_StateChange();

            //Input 0 1
            Assert.IsTrue(InputOne.State == false);
            Assert.IsTrue(InputTwo.State == true);
            Assert.IsTrue(andOutput.State == false);
        }