public void DestinationNotInZoneCoveredByRules() { var rule = new CountryToZoneRule(from: "GB", to: "EU", countries: ZoneRepo.Zones["EU"], requiresDoc: DocumentType.CommercialInvoice); var rulesEngine = new RulesEngine(rule); var result = rulesEngine.Run(from: "GB", to: "US", value: 100.10m); Assert.Empty(result); }
public void OneCountryToZoneRule() { var rule = new CountryToZoneRule(from: "GB", to: "EU", countries: ZoneRepo.Zones["EU"], requiresDoc: DocumentType.CommercialInvoice); var rulesEngine = new RulesEngine(rule); var result = rulesEngine.Run(from: "GB", to: "FR", value: 100.10m); Assert.Single(result); Assert.Contains(DocumentType.CommercialInvoice, result); }
public void NoDocumentAppliesOnlyToLessSpecificRules() { var commercialInvoice = new CountryToZoneRule(from: "GB", to: "EU", countries: ZoneRepo.Zones["EU"], requiresDoc: DocumentType.CommercialInvoice); var noDocument = new CountryToZoneRule(from: "GB", to: "EU", countries: ZoneRepo.Zones["EU"], requiresDoc: DocumentType.NoDocument); var cn22 = new CountryToCountryRule(from: "GB", to: "FR", requiresDoc: DocumentType.CN22); var rulesEngine = new RulesEngine(commercialInvoice, noDocument, cn22); var result = rulesEngine.Run(from: "GB", to: "FR", value: 100.10m); Assert.Single(result); Assert.Contains(DocumentType.CN22, result); }
public void TwoCountryToZoneRules() { var invoice = new CountryToZoneRule(from: "GB", to: "EU", countries: ZoneRepo.Zones["EU"], requiresDoc: DocumentType.CommercialInvoice); var cn22 = new CountryToZoneRule(from: "GB", to: "EU", countries: ZoneRepo.Zones["EU"], requiresDoc: DocumentType.CN22); var rulesEngine = new RulesEngine(invoice, cn22); var result = rulesEngine.Run(from: "GB", to: "FR", value: 100.10m); Assert.Equal(2, result.Count()); Assert.Contains(DocumentType.CommercialInvoice, result); Assert.Contains(DocumentType.CN22, result); }
public void IgnoreCountryToZoneNoDocumentWhichDoesNotApply() { var commercialInvoice = new CountryToZoneRule(from: "GB", to: "EU", countries: ZoneRepo.Zones["EU"], requiresDoc: DocumentType.CommercialInvoice); var noDocument = new CountryToZoneRule(from: "GB", to: "Non-Matching-Zone", countries: ZoneRepo.Zones["Non-Matching-Zone"], requiresDoc: DocumentType.NoDocument); var cn22 = new CountryToCountryRule(from: "GB", to: "FR", requiresDoc: DocumentType.CN22); var rulesEngine = new RulesEngine(commercialInvoice, noDocument, cn22); var result = rulesEngine.Run(from: "GB", to: "FR", value: 100.10m); Assert.Equal(2, result.Count()); Assert.Contains(DocumentType.CN22, result); Assert.Contains(DocumentType.CommercialInvoice, result); }