public void TestDivision3()
 {
     _oper = new Division(_entity);
     _oper.EnterContacts[0] = TestHelper.CreateNewChannel(4);
     _oper.EnterContacts[1] = TestHelper.CreateNewChannel(8);
     _oper.ExitContacts[0] = TestHelper.CreateNewChannel();
     _oper.Action();
     Assert.IsTrue(_oper.ExitContacts[0].Value == 0);
 }
        public void RandomNumber()
        {
            const uint limit = 100;
            var results = new List<ulong>();
            _oper = new RandomNumber(_entity);
            _oper.EnterContacts[0] = TestHelper.CreateNewChannel(limit);
            _oper.ExitContacts[0] = TestHelper.CreateNewChannel();
            for (int i = 0; i < 1000; i++)
            {
                _oper.Action();
                var res = _oper.ExitContacts[0].Value;
                if (res >= limit) {Assert.Fail("Under the limit!");}
                results.Add(res);
            }

            ulong sum = 0;
            foreach (var res in results)
            {
                sum += res;
            }

            double mid = (double)sum/results.Count;
            Assert.IsTrue((mid > limit * 0.4d) && (mid < limit * 0.6d), "Arithmetic mean was:" + mid);
        }
Esempio n. 3
0
 public Contact(Operator oper, ulong contactNumber)
 {
     _oper = oper;
        _contactNumber = contactNumber;
 }
Esempio n. 4
0
 public ChannelTableKey(Operator fromOperator, Operator toOperator)
 {
     FromOperator = fromOperator;
     ToOperator = toOperator;
 }
 public void TestEqual()
 {
     const ushort inputVal = 4;
     _oper = new Equal(_entity);
     _oper.EnterContacts[0] = TestHelper.CreateNewChannel(inputVal);
     _oper.ExitContacts[0] = TestHelper.CreateNewChannel();
     _oper.Action();
     Assert.IsTrue(_oper.ExitContacts[0].Value == inputVal);
 }
 public void TestTime()
 {
     _oper = new Time(_entity);
     _oper.ExitContacts[0] = TestHelper.CreateNewChannel();
     _oper.Action();
     TimeSpan ts = TimeSpan.FromTicks((long)_oper.ExitContacts[0].Value);
     Assert.IsTrue(ts.Seconds == DateTime.Now.Second);
 }
 public void TestPower()
 {
     _oper = new Power(_entity);
     _oper.EnterContacts[0] = TestHelper.CreateNewChannel(2);
     _oper.EnterContacts[1] = TestHelper.CreateNewChannel(3);
     _oper.ExitContacts[0] = TestHelper.CreateNewChannel();
     _oper.Action();
     Assert.IsTrue(_oper.ExitContacts[0].Value == 8);
 }
 public void TestOne()
 {
     _oper = new One(_entity);
     _oper.ExitContacts[0] = TestHelper.CreateNewChannel();
     _oper.Action();
     Assert.IsTrue(_oper.ExitContacts[0].Value == 1);
 }
 public void TestMinus()
 {
     _oper = new Minus(_entity);
     _oper.EnterContacts[0] = TestHelper.CreateNewChannel(15);
     _oper.EnterContacts[1] = TestHelper.CreateNewChannel(10);
     _oper.ExitContacts[0] = TestHelper.CreateNewChannel();
     _oper.Action();
     Assert.IsTrue(_oper.ExitContacts[0].Value == 5);
 }
 public void TestIf_Out()
 {
     _oper = new If(_entity);
     _oper.EnterContacts[0] = TestHelper.CreateNewChannel(15); //currentValue
     _oper.EnterContacts[1] = TestHelper.CreateNewChannel(10); //downLimit
     _oper.EnterContacts[2] = TestHelper.CreateNewChannel(15); //upperLimit
     _oper.ExitContacts[0] = TestHelper.CreateNewChannel();
     _oper.Action();
     Assert.IsTrue(_oper.ExitContacts[0].Value == 0);
 }