public void AddRuleViolationRuleBreachAddsToRuleBreachRepository() { var ruleViolationService = new RuleViolationService( this.queueCasePublisher, this.ruleBreachRepository, this.ruleBreachOrdersRepository, this.ruleBreachToRuleBreachOrdersMapper, this.ruleBreachToRuleBreachMapper, this.logger); var tradePosition = new TradePosition(new List <Order> { OrderHelper.Orders(OrderStatus.Filled) }); A.CallTo(() => this.ruleBreach.Trades).Returns(tradePosition); A.CallTo(() => this.ruleBreach.RuleParameters.TunedParameters).Returns(null); A.CallTo(() => this.ruleBreachRepository.Create(A <RuleBreach> .Ignored)).Returns(100); ruleViolationService.AddRuleViolation(this.ruleBreach); ruleViolationService.ProcessRuleViolationCache(); A.CallTo(() => this.ruleBreachToRuleBreachMapper.RuleBreachItem(this.ruleBreach)) .MustHaveHappenedOnceExactly(); A.CallTo(() => this.ruleBreachRepository.Create(A <RuleBreach> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo( () => this.ruleBreachToRuleBreachOrdersMapper.ProjectToOrders( A <IRuleBreach> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => this.ruleBreachRepository.HasDuplicate(A <string> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => this.queueCasePublisher.Send(A <CaseMessage> .Ignored)).MustHaveHappenedOnceExactly(); }
public void AddRuleViolationNullRuleBreachDoesNotThrow() { var ruleViolationService = new RuleViolationService( this.queueCasePublisher, this.ruleBreachRepository, this.ruleBreachOrdersRepository, this.ruleBreachToRuleBreachOrdersMapper, this.ruleBreachToRuleBreachMapper, this.logger); Assert.DoesNotThrow(() => ruleViolationService.AddRuleViolation(null)); }
public void AddRuleViolationRuleBreachWithNoOrdersAddsToRuleBreachRepository() { var ruleViolationService = new RuleViolationService( this.queueCasePublisher, this.ruleBreachRepository, this.ruleBreachOrdersRepository, this.ruleBreachToRuleBreachOrdersMapper, this.ruleBreachToRuleBreachMapper, this.logger); ruleViolationService.AddRuleViolation(this.ruleBreach); ruleViolationService.ProcessRuleViolationCache(); A.CallTo(() => this.ruleBreachToRuleBreachMapper.RuleBreachItem(this.ruleBreach)).MustNotHaveHappened(); A.CallTo(() => this.ruleBreachRepository.Create(A <RuleBreach> .Ignored)).MustNotHaveHappened(); A.CallTo( () => this.ruleBreachToRuleBreachOrdersMapper.ProjectToOrders( A <IRuleBreach> .Ignored, A <string> .Ignored)).MustNotHaveHappened(); A.CallTo(() => this.ruleBreachRepository.HasDuplicate(A <string> .Ignored)).MustNotHaveHappened(); }