public void Can_set_option_set_value_using_int() { var entity = new xts_entity { Id = Guid.NewGuid() }; entity.Set(e => e.xts_optionsetvalue, 12); Assert.Equal(12, entity.Get(e => e.xts_optionsetvalue).Value); entity.Set(e => e.xts_optionsetvalue, (int?)15); Assert.Equal(15, entity.Get(e => e.xts_optionsetvalue).Value); entity.Set(e => e.xts_optionsetvalue, (int?)null); Assert.Null(entity.Get(e => e.xts_optionsetvalue)); }
public void Can_set_money_using_decimal() { var entity = new xts_entity { Id = Guid.NewGuid() }; entity.Set(e => e.xts_money, 1234); Assert.Equal(1234m, entity.Get(e => e.xts_money).Value); }
public void Can_set_option_set_value_using_enum() { var entity = new xts_entity { Id = Guid.NewGuid() }; entity.Set(e => e.xts_optionsetvalue, TestOptions.SomeValue); Assert.Equal(47, entity.Get(e => e.xts_optionsetvalue).Value); }
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() }; entity.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); entity.Set(e => e.xts_datetime, dateValueProvider); Assert.Equal(date, entity.Get(e => e.xts_datetime)); }
public void Can_get_attribute_value_generic() { var entity = new xts_entity { Id = Guid.NewGuid() }; var reference = new EntityReference("reference", Guid.NewGuid()); entity["xts_attribute"] = reference; Assert.Equal(reference, entity.Get(e => e.xts_attribute)); }
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() }; entity.Set(e => e.xts_money, decimalValueProvider); Assert.Equal(1500m, entity.Get(e => e.xts_money).Value); }
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() }; entity.Set(e => e.xts_string, valueProvider); Assert.Equal("1234", entity.Get(e => e.xts_string)); }
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() }; entity.Set(e => e.xts_string, valueProvider); Assert.Equal("1234", entity.Get(e => e.xts_string)); }