public static TargetComparer New(TargetConfig targetConfig)
        {
            if (targetConfig == null)
            {
                return null;
            }

            if (targetConfig.LowerLimit == null && 
                targetConfig.UpperLimit == null && 
                targetConfig.BespokeTargetKey == null)
            {
                throw new FingertipsException(
                    "The configuration details for this target (ID:" + targetConfig.Id + ") has not been set");
            }

            var bespokeKey = targetConfig.BespokeTargetKey;
            if (string.IsNullOrEmpty(bespokeKey) == false)
            {
                switch (bespokeKey)
                {
                    case BespokeTargets.ComparedWithPreviousYearEnglandValue:
                        return new BespokeTargetPreviousYearEnglandValueComparer(targetConfig);
                    case BespokeTargets.TargetPercentileRange:
                        return new BespokeTargetPercentileRangeComparer(targetConfig);
                }

                throw new FingertipsException(
                    "The bespoke target key was not recognised: " + bespokeKey);
            }

            if (targetConfig.UpperLimit.HasValue)
            {
                return new RangeTargetComparer(targetConfig);
            }
            
            if (targetConfig.LowerLimit.HasValue)
            {
                return new SingleValueTargetComparer(targetConfig);
            }

            throw new FingertipsException("Bespoke comparison not implemented");
        }
 public void Init()
 {
     _targetConfig = new TargetConfig() { LowerLimit = 50, UpperLimit = 90, PolarityId = 1 };
     _lowerTargetPercentileValue = 9.3;
     _upperTargetPercentileValue = 37.2;
 }
 private BespokeTargetPercentileRangeComparer GetComparer(TargetConfig targetConfig)
 {
     return new BespokeTargetPercentileRangeComparer(_targetConfig)
     {
         LowerTargetPercentileBenchmarkData = new CoreDataSet() { Value = _lowerTargetPercentileValue },
         UpperTargetPercentileBenchmarkData = new CoreDataSet() { Value = _upperTargetPercentileValue }
     };
 }
 public RangeTargetComparer(TargetConfig config)
     : base(config)
 {
     ValidateConfig();
     PolarityId = config.PolarityId;
 }
 public BespokeTargetPreviousYearEnglandValueComparer(TargetConfig config)
     : base(config)
 {
 }
 private static PholioReader MockPholioReader(int targetId, TargetConfig config)
 {
     var mock = new Moq.Mock<PholioReader>();
     mock.Setup(x => x.GetTargetConfig(targetId)).Returns(config);
     return mock.Object;
 }
 protected TargetComparer(TargetConfig config)
 {
     Config = config;
 }
 public SingleValueTargetComparer(TargetConfig config)
     : base(config)
 {
     PolarityId = config.PolarityId;
 }
 public BespokeTargetPercentileRangeComparer(TargetConfig config)
     : base(config)
 {
 }