Exemplo n.º 1
0
        public void NoDocument()
        {
            var countryToCountry = new CountryToCountryRule(from: "GB", to: "FR", requiresDoc: DocumentType.NoDocument);

            var rulesEngine = new RulesEngine(countryToCountry);

            var result = rulesEngine.Run(from: "GB", to: "FR", value: 100.10m);

            Assert.Empty(result);
        }
Exemplo n.º 2
0
        public void OneCountryToCountryRule()
        {
            var rule = new CountryToCountryRule(from: "GB", to: "FR", 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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }