Esempio n. 1
0
        public void Can_get_money_value()
        {
            var entity = new xts_entity
            {
                Id = Guid.NewGuid()
            };

            entity["xts_money"] = null;

            var accessor = new EntityAccessor <xts_entity>(entity);

            Assert.Equal(0m, accessor.GetValue(e => e.xts_money));
            Assert.Equal(10m, accessor.GetValue(e => e.xts_money, 10m));

            entity["xts_money"] = new Money(250m);
            Assert.Equal(250m, accessor.GetValue(e => e.xts_money, 250m));
        }
Esempio n. 2
0
        public void Can_get_value_nullable_type()
        {
            var entity   = new xts_entity();
            var accessor = new EntityAccessor <xts_entity>(entity);

            Assert.Equal(0, accessor.GetValue(e => e.xts_int));
            Assert.Equal(111, accessor.GetValue(e => e.xts_int, 111));
            entity.Set(e => e.xts_int, 123);
            Assert.Equal(123, accessor.GetValue(e => e.xts_int));
            Assert.Equal(123, accessor.GetValue(e => e.xts_int, 3333));

            Assert.Equal(0m, accessor.GetValue(e => e.xts_decimal));
            Assert.Equal(1000m, accessor.GetValue(e => e.xts_decimal, 1000m));
            entity.Set(e => e.xts_decimal, 2300m);
            Assert.Equal(2300m, accessor.GetValue(e => e.xts_decimal));
            Assert.Equal(2300m, accessor.GetValue(e => e.xts_decimal, 4000m));
        }