Exemplo n.º 1
0
 public void ConvertToVerified()
 {
     var ls = new LocalSystem { IsOwnerInnerObject = true };
     var dls = ls.AsDynamic;
     using (ls.BeginConstruct())
     {
         var vp = ls.GetOrConvertVerifiedProperty("Foobar");
         Assert.IsInstanceOfType(vp, typeof(VerifiedProperty));
         vp.Value = 100;
         Assert.IsTrue(dls.Foobar == 100);
     }
 }
Exemplo n.º 2
0
        public void ValidatePropertyTest()
        {
            var ls = new LocalSystem { IsOwnerInnerObject = true };
            var dls = ls.AsDynamic;
            var lstReasonFailure = new List<string>();
            VerifiedProperty vp;
            using (ls.BeginConstruct())
                vp = ls.GetOrConvertVerifiedProperty("Foobar");
            dls.Foobar = 20;
            // Создаем валидаторы с описанием
            vp.ValidateHnd += VerifiedProperty.CreateValidator<int>((prop, value) => value <= 100, ">100");
            vp.ValidateHnd += VerifiedProperty.CreateValidator<int>((prop, value) => value <= 50, ">50");

            Assert.IsFalse(ls.VerifySetPropertyValue("Foobar", 101, lstReasonFailure));
            Assert.AreEqual(lstReasonFailure.Count, 2);
            Assert.IsTrue(lstReasonFailure.Contains(">100"));
            Assert.IsTrue(lstReasonFailure.Contains(">50"));
            lstReasonFailure.Clear();

            Assert.IsFalse(ls.VerifySetPropertyValue("Foobar", 70, lstReasonFailure));
            Assert.IsTrue(lstReasonFailure.Contains(">50"));
        }
Exemplo n.º 3
0
 public void ConvertToVerifiedFailed()
 {
     var ls = new LocalSystem { IsOwnerInnerObject = true };
     ls.GetOrConvertVerifiedProperty("Foobar");
 }
Exemplo n.º 4
0
 public void CalculatePropertyTest()
 {
     var ls = new LocalSystem { IsOwnerInnerObject = true };
     var dls = ls.AsDynamic;
     VerifiedProperty vp;
     using (ls.BeginConstruct())
         vp = ls.GetOrConvertVerifiedProperty("Foobar");
     var a = 100;
     vp.IsCalculated = true;
     vp.CalculateHnd += prop => a;
     Assert.AreEqual(dls.Foobar, 100);
     a = 200;
     Assert.AreEqual(dls.Foobar, 200);
 }