public void T12_ReadClassIgnoresNonPublicSetters() { Assert.IsTrue(plc.IsConnected, "Before executing this test, the plc must be connected. Check constructor."); TestClassWithPrivateSetters tc = new TestClassWithPrivateSetters(); tc.BitVariable00 = true; tc.BitVariable10 = true; tc.DIntVariable = -100000; tc.IntVariable = -15000; tc.LRealVariable = -154.789; tc.RealVariable = -154.789f; tc.DWordVariable = 850; plc.WriteClass(tc, DB2); TestClassWithPrivateSetters tc2 = new TestClassWithPrivateSetters(); // Values that are read from a class are stored inside the class itself, that is passed by reference plc.ReadClass(tc2, DB2); Assert.AreEqual(tc.BitVariable00, tc2.BitVariable00); Assert.AreEqual(tc.BitVariable10, tc2.BitVariable10); Assert.AreEqual(tc.DIntVariable, tc2.DIntVariable); Assert.AreEqual(tc.IntVariable, tc2.IntVariable); Assert.AreEqual(tc.LRealVariable, tc2.LRealVariable); Assert.AreEqual(tc.RealVariable, tc2.RealVariable); Assert.AreEqual(tc.DWordVariable, tc2.DWordVariable); Assert.AreEqual(TestClassWithPrivateSetters.PRIVATE_SETTER_VALUE, tc2.PrivateSetterProperty); Assert.AreEqual(TestClassWithPrivateSetters.PROTECTED_SETTER_VALUE, tc2.ProtectedSetterProperty); Assert.AreEqual(TestClassWithPrivateSetters.INTERNAL_SETTER_VALUE, tc2.InternalSetterProperty); Assert.AreEqual(TestClassWithPrivateSetters.JUST_A_GETTER_VALUE, tc2.JustAGetterProperty); }
public async Task Test_Async_ReadClassIgnoresNonPublicSetters() { Assert.IsTrue(plc.IsConnected, "Before executing this test, the plc must be connected. Check constructor."); TestClassWithPrivateSetters tc = new TestClassWithPrivateSetters { BitVariable00 = true, BitVariable10 = true, DIntVariable = -100000, IntVariable = -15000, RealVariableDouble = -154.789, RealVariableFloat = -154.789f, DWordVariable = 850 }; await plc.WriteClassAsync(tc, DB2); TestClassWithPrivateSetters tc2 = new TestClassWithPrivateSetters(); // Values that are read from a class are stored inside the class itself, that is passed by reference var res = await plc.ReadClassAsync(tc2, DB2); tc = (TestClassWithPrivateSetters)res.Item2; Assert.AreEqual(tc.BitVariable00, tc2.BitVariable00); Assert.AreEqual(tc.BitVariable10, tc2.BitVariable10); Assert.AreEqual(tc.DIntVariable, tc2.DIntVariable); Assert.AreEqual(tc.IntVariable, tc2.IntVariable); Assert.AreEqual(tc.RealVariableDouble, tc2.RealVariableDouble, 0.1); Assert.AreEqual(tc.RealVariableFloat, tc2.RealVariableFloat); Assert.AreEqual(tc.DWordVariable, tc2.DWordVariable); Assert.AreEqual(TestClassWithPrivateSetters.PRIVATE_SETTER_VALUE, tc2.PrivateSetterProperty); Assert.AreEqual(TestClassWithPrivateSetters.PROTECTED_SETTER_VALUE, tc2.ProtectedSetterProperty); Assert.AreEqual(TestClassWithPrivateSetters.INTERNAL_SETTER_VALUE, tc2.InternalSetterProperty); Assert.AreEqual(TestClassWithPrivateSetters.JUST_A_GETTER_VALUE, tc2.JustAGetterProperty); }