Exemplo n.º 1
0
        public void Can_set_option_set_value_using_int()
        {
            var entity = new xts_entity {
                Id = Guid.NewGuid()
            };
            var accessor = new EntityAccessor <xts_entity>(entity);

            accessor.Set(e => e.xts_optionsetvalue, 12);
            Assert.Equal(12, accessor.Get(e => e.xts_optionsetvalue).Value);
        }
Exemplo n.º 2
0
        public void Can_set_money_using_decimal()
        {
            var entity = new xts_entity {
                Id = Guid.NewGuid()
            };
            var accessor = new EntityAccessor <xts_entity>(entity);

            accessor.Set(e => e.xts_money, 1234);
            Assert.Equal(1234m, accessor.Get(e => e.xts_money).Value);
        }
Exemplo n.º 3
0
        public void Can_set_attribute_value()
        {
            var entity = new xts_entity
            {
                Id = Guid.NewGuid()
            };
            var accessor  = new EntityAccessor <xts_entity>(entity);
            var reference = new EntityReference("reference", Guid.NewGuid());

            accessor.Set("xts_attribute", reference);

            Assert.Equal(reference, entity["xts_attribute"]);
        }
Exemplo n.º 4
0
        [Fact] // Assume ActivityParty
        public void Can_set_entity_collection_using_single_entity_reference()
        {
            var entityReference = new EntityReference("equipment", Guid.NewGuid());
            var entity          = new xts_entity();
            var accessor        = new EntityAccessor <xts_entity>(entity);

            accessor.Set(e => e.xts_activityparties, entityReference);

            var collection    = accessor.Get(e => e.xts_activityparties);
            var activityParty = collection.Entities[0].ToEntity <ActivityParty>();

            Assert.Equal(entityReference, activityParty.Get(e => e.PartyId));
        }
Exemplo n.º 5
0
        public void Can_set_through_value_provider()
        {
            var valueProvider = Substitute.For <IValueProvider>();

            valueProvider.GetValue().Returns("1234");

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

            accessor.Set("xts_attribute", valueProvider);

            Assert.Equal("1234", entity.Get <string>("xts_attribute"));
        }
Exemplo n.º 6
0
        public void Can_set_nullable_value_type_through_value_provider_generic_value_type()
        {
            var intValueProvider = Substitute.For <IValueProvider <int> >();

            intValueProvider.GetValue().Returns(1234);
            var entity = new xts_entity {
                Id = Guid.NewGuid()
            };
            var accessor = new EntityAccessor <xts_entity>(entity);

            accessor.Set(e => e.xts_int, intValueProvider);

            Assert.Equal(1234, entity.Get(e => e.xts_int));

            var date = new DateTime(2017, 3, 2);
            var dateValueProvider = Substitute.For <IValueProvider <DateTime> >();

            dateValueProvider.GetValue().Returns(date);
            accessor.Set(e => e.xts_datetime, dateValueProvider);

            Assert.Equal(date, entity.Get(e => e.xts_datetime));
        }
Exemplo n.º 7
0
        [Fact] // Assume ActivityParty
        public void Can_set_entity_collection_using_entity_references()
        {
            var equipmentReference = new EntityReference("equipment", Guid.NewGuid());
            var leadReference      = new EntityReference("lead", Guid.NewGuid());
            var references         = new[] { equipmentReference, leadReference };
            var entity             = new xts_entity();
            var accessor           = new EntityAccessor <xts_entity>(entity);

            accessor.Set(e => e.xts_activityparties, references);

            var collection = accessor.Get(e => e.xts_activityparties);

            Assert.Equal(equipmentReference, collection.Entities[0].ToEntity <ActivityParty>().Get(e => e.PartyId));
            Assert.Equal(leadReference, collection.Entities[1].ToEntity <ActivityParty>().Get(e => e.PartyId));
        }
Exemplo n.º 8
0
        public void Can_set_through_value_provider_generic()
        {
            var valueProvider = Substitute.For <IValueProvider <string> >();

            valueProvider.GetValue().Returns("1234");

            var entity = new xts_entity {
                Id = Guid.NewGuid()
            };
            var accessor = new EntityAccessor <xts_entity>(entity);

            accessor.Set(e => e.xts_string, valueProvider);

            Assert.Equal("1234", entity.Get(e => e.xts_string));
        }
Exemplo n.º 9
0
        public void Can_set_through_attribute_value_provider_generic()
        {
            var valueProvider = Substitute.For <IAttributeValueProvider <xts_entity, string> >();

            valueProvider.GetValueFor(Arg.Any <Expression <Func <xts_entity, string> > >()).Returns("1234");

            var entity = new xts_entity {
                Id = Guid.NewGuid()
            };
            var accessor = new EntityAccessor <xts_entity>(entity);

            accessor.Set(e => e.xts_string, valueProvider);

            Assert.Equal("1234", entity.Get(e => e.xts_string));
        }
Exemplo n.º 10
0
        public void Can_set_money_from_decimal_value_provider()
        {
            var decimalValueProvider = Substitute.For <IValueProvider <decimal> >();

            decimalValueProvider.GetValue().Returns(1500m);

            var entity = new xts_entity {
                Id = Guid.NewGuid()
            };
            var accessor = new EntityAccessor <xts_entity>(entity);

            accessor.Set(e => e.xts_money, decimalValueProvider);

            Assert.Equal(1500m, entity.Get(e => e.xts_money).Value);
        }
Exemplo n.º 11
0
        public void Can_set_primary_field()
        {
            var id         = Guid.NewGuid();
            var testEntity = new new_testentity
            {
                Id = id
            };

            var accessor = new EntityAccessor <new_testentity>(testEntity);

            Assert.Equal(id, accessor.Entity.Id);
            Assert.Equal(id, accessor.Get <Guid>("new_testentityid"));

            testEntity = new new_testentity();
            accessor   = new EntityAccessor <new_testentity>(testEntity);
            accessor.Set("new_testentityid", id);
            Assert.Equal(id, accessor.Entity.Id);
            Assert.Equal(id, accessor.Get <Guid>("new_testentityid"));
        }