protected override RangeConstrainedValueProviderContext <T> CreateContext(ValueProviderObjectContext objectContext) { var rangeContstraints = RangeContstraints <T> .FromMember(objectContext.Member) ?? new RangeContstraints <T>(DefaultMinValue, DefaultMaxValue); return(new RangeConstrainedValueProviderContext <T>(objectContext, rangeContstraints)); }
protected override RangeConstrainedValueProviderContext <double> CreateContext(ValueProviderObjectContext objectContext) { var rangeContstraints = RangeContstraints <double> .FromMember(objectContext.Member) ?? new RangeContstraints <double>(double.MinValue, double.MaxValue); return(new RangeConstrainedValueProviderContext <double>(objectContext, rangeContstraints)); }
public FromPropertySpecK() { Specify(_ => RangeContstraints <int> .FromMember(Member)) // .Case("FromProperty without range attribute", _ => _ .Given(PropertyInfoContext(false)) .It("should return null", x => x.Result.Should().BeNull())) // .Case("FromProperty with wrongly typed range property", _ => _ .Given(PropertyInfoContext(true, typeof(double), "3", "5")) .It("should return null", x => x.Result.Should().BeNull())) // .Case("FromProperty with correctly typed range property", _ => _ .Given(PropertyInfoContext(true, typeof(int), "3", "5")) .It("should return correct min value", x => x.Result.MinValue.Should().Be(3)) .It("should return correct max value", x => x.Result.MaxValue.Should().Be(5))) // .Case("FromProperty with correctly typed range property but wrong ranges", _ => _ .Given(PropertyInfoContext(true, typeof(int), "5", "3")) .ItThrows(typeof(ArgumentOutOfRangeException))); }