Example #1
0
        public static void TestPropertySettingItsValueTo1IfParamIsLessThan1(RawSerialProtocol prot, string propertyName,int testValue)
        {
            PropertyInfo prop = typeof(RawSerialProtocol).GetProperty(propertyName);

            // create an open "getter" delegate
            Func<RawSerialProtocol, int> getForAnyRawSerialProtocolIntProp = (Func<RawSerialProtocol, int>)
                Delegate.CreateDelegate(typeof(Func<RawSerialProtocol, int>), null,
                    prop.GetGetMethod());

            Action<RawSerialProtocol, int> setForAnyRawSerialProtocolIntProp = (Action<RawSerialProtocol, int>)
            Delegate.CreateDelegate(typeof(Action<RawSerialProtocol, int>), null,
                prop.GetSetMethod());

            setForAnyRawSerialProtocolIntProp(prot, testValue);
            Assert.AreEqual(1, getForAnyRawSerialProtocolIntProp(prot));
        }
Example #2
0
 public void Properties_ShouldSetValueTo1AndThrowExceptionOnLessThan1ms(int testValue)
 {
     RawSerialProtocol prot = new RawSerialProtocol();
     TestHelper.TestPropertySettingItsValueTo1IfParamIsLessThan1(prot, "SilentInterval", testValue);
     TestHelper.TestPropertySettingItsValueTo1IfParamIsLessThan1(prot, "TangentaSetPinTimePeriodMsec", testValue);
     TestHelper.TestPropertySettingItsValueTo1IfParamIsLessThan1(prot, "Retries", testValue);
 }
Example #3
0
 public void DefaultCtorShouldSetProperties()
 {
     RawSerialProtocol prot = new RawSerialProtocol();
     Assert.AreEqual(false, prot.IsConnected);
     Assert.AreEqual(20, prot.SilentInterval);
     Assert.That(prot.StatusString, Is.EqualTo("Not connected"));
     Assert.AreEqual(SerialPortPin.None, prot.TangentaPin);
     Assert.AreEqual(100, prot.TangentaSetPinTimePeriodMsec);
     //Assert.AreEqual(false, prot.SaveExceptionsToLog);
     //Assert.AreEqual(AppDomain.CurrentDomain.BaseDirectory, prot.ExceptionLogsPath);
     Assert.AreEqual(1, prot.Retries);
 }
Example #4
0
 public void Connect_ShouldSetStatusStringToErrorAndSaveItToLog(string port)
 {
     RawSerialProtocol prot = new RawSerialProtocol();
     prot.Connect(port);
     Assert.That(prot.StatusString, Is.StringContaining("Error"));
     prot.Disconnect();
 }