예제 #1
0
        public void Can_execute_attribute_changing()
        {
            var entity = new MsGenerated.Account
            {
                Id          = Guid.NewGuid(),
                CreditLimit = new Money(200m)
            };

            var txEntity = new TransactionContextEntity <MsGenerated.Account>(entity);

            Entity senderEntity           = null;
            AttributeChangingEventArgs ev = null;
            Money value = null;

            txEntity.AttributeChanging += (sender, e) =>
            {
                senderEntity = (Entity)sender;
                ev           = e;
                value        = ((Entity)sender).GetAttributeValue <Money>(e.AttributeName);
            };

            txEntity.Entity.CreditLimit = new Money(450m);

            Assert.Equal(entity, senderEntity);
            Assert.Equal("CreditLimit", ev.PropertyName);
            Assert.Equal("creditlimit", ev.AttributeName);
            Assert.Equal(200m, value.Value);
        }
예제 #2
0
        public void Can_execute_attribute_changing()
        {
            var entity = new Entity("entity")
            {
                Id = Guid.NewGuid(),
                ["xts_attribute"] = new Money(200m)
            };

            var txEntity = new TransactionContextEntity <Entity>(entity);

            Entity senderEntity           = null;
            AttributeChangingEventArgs ev = null;
            Money value = null;

            txEntity.AttributeChanging += (sender, e) =>
            {
                senderEntity = (Entity)sender;
                ev           = e;
                value        = ((Entity)sender).GetAttributeValue <Money>(e.AttributeName);
            };

            txEntity["xts_attribute"] = new Money(450m);

            Assert.Equal(entity, senderEntity);
            Assert.Null(ev.PropertyName);
            Assert.Equal("xts_attribute", ev.AttributeName);
            Assert.Equal(200m, value.Value);
        }
예제 #3
0
        private static void RemoveFormattedValue(object entity, AttributeChangingEventArgs e)
        {
            var source = (Entity)entity;

            source.FormattedValues.Remove(e.AttributeName);
        }
예제 #4
0
 internal void FireEvent(MapNode node, AttributeChangingEventArgs args)
 {
     AttributeChanging(node, args);
 }