public void RatioConvertTest() { var fixture = new Fixture(); var converter = new RatioConverter(); var value = fixture.Create <double>(); var parameter = fixture.Create <double>(); var result = converter.Convert(value, null, parameter, CultureInfo.CurrentCulture); Assert.That(result, Is.EqualTo(value * parameter)); Assert.That(result, Is.TypeOf <double>()); }
public Boolean Validate(IMediaFeature feature, IRenderDevice device) { var ratio = RatioConverter.Convert(feature.Value); if (ratio != null) { var desired = ratio.AsNumber(); var available = device.ViewPortWidth / (Double)device.ViewPortHeight; if (feature.IsMaximum) { return(available <= desired); } else if (feature.IsMinimum) { return(available >= desired); } return(desired == available); } return(false); }
public void InitializeConverter() { _converter = new RatioConverter(); }
public override object ProvideValue(IServiceProvider serviceProvider) { return(_instance ?? (_instance = new RatioConverter())); }