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); }
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); }
[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)); }
public void Can_get_attribute_value() { var entity = new xts_entity { Id = Guid.NewGuid() }; var reference = new EntityReference("reference", Guid.NewGuid()); entity["xts_attribute"] = reference; var accessor = new EntityAccessor <xts_entity>(entity); Assert.Equal(reference, accessor.Get <EntityReference>("xts_attribute")); }
[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)); }
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")); }