public RatingEngine(ILoggerConsole logger, IPolicySource policySource, IPolicySerializer policySerializer, RaterFactory raterFactory) { _logger = logger; _policySource = policySource; _policySerializer = policySerializer; _raterFactory = raterFactory; }
public RatingEngineRate() { this.logger = new FakeLogger(); this.policySource = new FakePolicySource(); this.policySerializer = new JsonPolicySerializer(); this.raterFactory = new RaterFactory(this.logger); this.engine = new RatingEngine(this.logger, this.policySource, this.policySerializer, this.raterFactory); }
public void Setup() { _logger = new Mock <ILogger>(); _policySource = new Mock <IPolicySource>(); _policySerializer = new Mock <IPolicySerializer>(); _raterFactory = new RaterFactory(_logger.Object); _ratingEngine = new RatingEngine(_logger.Object, _policySource.Object, _policySerializer.Object, _raterFactory); }
public RatingEngineRate() { _logger = new FakeLogger(); _policySource = new FakePolicySource(); _policySerializer = new JsonPolicySerializer(); _raterFactory = new RaterFactory(_logger); _engine = new RatingEngine(_logger, _policySource, _policySerializer, _raterFactory); }
public RatingEngine(ILogger logger, IPolicySource policySource, IPolicySerializer policySerializer, RaterFactory raterFactory) { this.logger = logger; this.policySource = policySource; this.policySerializer = policySerializer; this.raterFactory = raterFactory; this.Context = new DefaultRatingContext(this.policySource, this.policySerializer); Context.Engine = this; }
// these properties were encapsulated inside the context //public ConsoleLogger Logger { get; set; } = new ConsoleLogger(); //public FilePolicySource PolicySource { get; set; } = new FilePolicySource(); //public JsonPolicySerializer PolicySerializer { get; set; } = new JsonPolicySerializer(); public RatingEngine(ILogger logger, IPolicySource policySource, IPolicySerializer policySerializer, RaterFactory raterFactory) { _logger = logger; _policySource = policySource; _policySerializer = policySerializer; _raterFactory = raterFactory; //Context = new DefaultRatingContext(_policySource, _policySerializer) //{ // Engine = this //}; }
public void Rate() { Loger.Log($"Start {nameof(RatingEngine.Rate)}"); string policySource = PolicySource.GetPolicyFromSource(); var policy = PolicySerializer.GetPolicyFromString(policySource); AbsRater rater = new RaterFactory().Create(policy, this); Rating = rater.Rate(policy); Loger.Log($"End {nameof(RatingEngine.Rate)}"); }
public void Rate() { _Logger.Log("Starting rate."); _Logger.Log("Loading policy."); // load policy - open file policy.json string policyJson = _PolicyIO.GetPolicyFromSource(); Policy policy = _PolicyIO.DeserializePolicy(policyJson); var rater = new RaterFactory().Create(this, policy); rater.Rate(); _Logger.Log("Rating completed."); }
public void Rate() { _logger.Log("Starting rate."); _logger.Log("Loading policy."); string policyJson = _policySource.GetPolicy(); var policy = _policySerializer.GetPolicyFromJsonString(policyJson); var raterFactory = new RaterFactory(this, _logger); var rater = raterFactory.CreateRater(policy.Type); rater?.Rate(policy); _logger.Log("Rating completed."); }
public void Rate() { ConsoleLogger.Log("Starting rate."); ConsoleLogger.Log("Loading policy."); var policyJson = FilePolicySource.GetPolicyFromSource(); var policy = JsonPolicySerializer.GetPolicyFromJsonString(policyJson); var rater2 = new RaterFactory().CreateByReflection(policy, this); rater2.Rate(policy); ConsoleLogger.Log("Rating completed."); }
public void Rate() { Logger.Log("Starting rate."); Logger.Log("Loading policy."); var policyJson = PolicySource.GetPolicyFromSource(); var policy = PolicySerializer.GetPolicyFromJsonString(policyJson); var factory = new RaterFactory(); var rater = factory.Create(this, policy); rater?.Rate(policy); Logger.Log("Rating completed."); }
public void Rate() { ConsoleLogger.Log("Starting rate."); ConsoleLogger.Log("Loading policy."); var policyJson = FilePolicySource.GetPolicyFromSource(); var policy = JsonPolicySerializer.GetPolicyFromJsonString(policyJson); var rater2 = new RaterFactory().CreateByReflection(policy, new LSP.RatingEngine()); //new RaterFactory().CreateByReflection(policy, this); if (rater2 == null) { ConsoleLogger.Log("Uknown policy type"); } else { rater2.Rate(policy); } ConsoleLogger.Log("Rating completed."); }