public void TestIfNoPromoGetPromoRulesReturnsEmptyList( ) { var ruleFile = TestAssistant.GetPromoRuleFileNameFromAppConfig( ); File.AppendAllText(ruleFile, string.Empty); var ruleFactory = new ComaSeparatedFileSpecialPricingRuleFactory(ruleFile); var rules = ruleFactory.GetPromoRules( ); Assert.IsNotNull(rules); Assert.IsTrue(0 == rules.Count( )); }
public void TestGetPromoRulesReturnsListOfInitialisedRules( ) { var ruleFile = TestAssistant.GetPromoRuleFileNameFromAppConfig( ); var allLines = new List <string>( ) { PROMORULEHEADER, RULEONE, RULETWO }; File.AppendAllLines(ruleFile, allLines); var ruleFactory = new ComaSeparatedFileSpecialPricingRuleFactory(ruleFile); var rules = ruleFactory.GetPromoRules( ); File.Delete(ruleFile); Assert.IsNotNull(rules); Assert.IsTrue(2 == rules.Count( )); // We should expected 2 rules excluding the header }
/// <summary> /// Get rules /// </summary> /// <returns></returns> public static List <CheckoutKata.Business.ISpecialPricingRule> CreateRulesFromTexFile( ) { var ruleFile = TestAssistant.GetPromoRuleFileNameFromAppConfig( ); var allLines = new List <string>( ) { PROMORULEHEADER, RULEONE, RULETWO }; // Write the promotion rules to the file File.AppendAllLines(ruleFile, allLines); var ruleFactory = new ComaSeparatedFileSpecialPricingRuleFactory(ruleFile); File.Delete(ruleFile); // Any test calling this will fail if the an exception is thrown whist tring to get the List of promo rules. // Its ok, as it is a test. It will force the engineer to debug why their test is failing return(ruleFactory.GetPromoRules( ).ToList( )); }