Ejemplo n.º 1
0
        public void PropertyValueHolderTest()
        {
            SampleTestHolderClass model = new SampleTestHolderClass();

            Assert.Null(model.Property1);
            Assert.Equal(model.Date, DateTime.MinValue);
            Assert.Equal(model.Val, 0);
            Assert.Equal(model.Money, 0);


            model.Property1 = "Teste";
            model.Val       = 19922;
            var date = DateTime.Now;

            model.Date  = date;
            model.Money = (decimal) - 222.21;

            Assert.Equal(model.Date, date);
            Assert.Equal(model.Val, 19922);
            Assert.Equal(model.Money, (decimal) - 222.21);

            //simula submit changes

            string sql = model.PropertyValuesString;

            Assert.NotNull(sql);
            Assert.Contains("Teste", sql);
            Assert.Contains("19922", sql);
            Assert.Contains("222", sql);

            SampleTestHolderClass model2 = SampleTestHolderClass.Create(sql);

            Assert.Equal(model.Property1, model2.Property1);
            Assert.Equal(model.Val, model2.Val);
            Assert.Equal(model.Money, model2.Money);
            Assert.Equal(model.Date.Day, model2.Date.Day);
            Assert.Equal(model.Date.Year, model2.Date.Year);
            Assert.Equal(model.Date.Minute, model2.Date.Minute);
            Assert.Equal(model.Date.Millisecond, model2.Date.Millisecond);
            //Assert.Equal(model.Date.Ticks, model2.Date.Ticks);  --problema: não está batendo os ticks
        }
Ejemplo n.º 2
0
 public static void Sync(SampleTestHolderClass holder)
 {
     holder._propValuesStr = holder.ToJSon();
 }