public void check_low_with_two_unvalid_merchandise_in_statement()
        {
            List <string> merchandises = new List <string>();

            merchandises.Add("berenj");
            merchandises.Add("gandom");
            List <string> companies = new List <string>();

            companies.Add("tabarok");
            companies.Add("golestan");
            List <string> licenseNeeded = new List <string>();
            DateTime      issuanceDate  = new DateTime(2015, 1, 18);
            //stub
            bool expected = false;
            //drivers
            Law lawTest = new Law(DateTime.MinValue, DateTime.MaxValue, 200, 5000, 200
                                  , "", "", double.MinValue, merchandises, companies, licenseNeeded);
            Statement statement = new Statement();

            statement.SetParameters(issuanceDate, 200000, "", "");
            MerchandiseInStatement mis  = new MerchandiseInStatement("berenj", "tabarok", 0, 1000, 100);
            MerchandiseInStatement mis2 = new MerchandiseInStatement("gandom", "golestan", 0, 100, 1000);

            statement.AddNewMerchandise(mis);
            statement.AddNewMerchandise(mis2);
            Assert.AreEqual(lawTest.IsValidPerMerchandise(statement), expected, "low with tow unvalid merchandise in statement isn't correctly coded!");
        }
Example #2
0
        public void UnitPriceInvalidCountCompanyValidTest()
        {
            double        minUnitPrice  = 0;
            double        maxUnitPrice  = 100;
            int           minCount      = 50;
            double        wholeValue    = 7500;
            string        goodName      = "gun";
            string        company       = "googoolParvar";
            double        weight        = 100;
            double        unitPrice     = 150;
            int           count         = 50;
            DateTime      issuanceDate  = new DateTime(2015, 1, 20);
            List <string> merchandises  = new List <string>();
            List <string> companies     = new List <string>();
            List <string> licenseNeeded = new List <string>();

            companies.Add("googoolParvar");
            bool expected = false;
            //drivers
            Law lawTest = new Law(DateTime.MinValue, DateTime.MaxValue, minUnitPrice, maxUnitPrice, minCount,
                                  "", "", double.MinValue, merchandises, companies, licenseNeeded);
            Statement statement = new Statement();

            statement.SetParameters(issuanceDate, wholeValue, "", "");
            MerchandiseInStatement MIS = new MerchandiseInStatement(goodName, company, weight, count, unitPrice);

            statement.AddNewMerchandise(MIS);
            Assert.AreEqual(lawTest.IsValidWithoutMerchandise(statement), expected, "Wrong Check in ");
        }
        public void AddNewMerchandiseToStatement(string name, string company, string weight, string number, string price)
        {
            // these should not be empty
            double _weight = String.IsNullOrEmpty(weight) ? -1 : Convert.ToDouble(weight);
            int    _number = String.IsNullOrEmpty(number) ? -1 : Convert.ToInt32(number);
            double _price  = String.IsNullOrEmpty(price) ? -1 : Convert.ToDouble(price);

            MerchandiseInStatement merchandise = new MerchandiseInStatement(name, company, _weight, _number, _price);

            statement.AddNewMerchandise(merchandise);
        }
Example #4
0
        public void CompanyCountUnitPriceValidUnionFlagsTest()
        {
            double        minUnitPrice  = 0;
            double        maxUnitPrice  = 100;
            int           minCount      = 10;
            double        wholeValue    = 7500;
            string        goodName1     = "gun";
            string        company1      = "googoolParvar";
            double        weight1       = 100;
            double        unitPrice1    = 50;
            int           count1        = 9;
            string        goodName2     = "WarMachine";
            string        company2      = "googoolParvar";
            double        weight2       = 1000;
            double        unitPrice2    = 500;
            int           count2        = 10;
            DateTime      issuanceDate  = new DateTime(2015, 1, 20);
            List <string> merchandises  = new List <string>();
            List <string> companies     = new List <string>();
            List <string> licenseNeeded = new List <string>();

            companies.Add("USI");
            companies.Add("googoolParvar");
            bool expected = false;
            //drivers
            Law lawTest = new Law(DateTime.MinValue, DateTime.MaxValue, minUnitPrice, maxUnitPrice, minCount,
                                  "", "", double.MinValue, merchandises, companies, licenseNeeded);
            Statement statement = new Statement();

            statement.SetParameters(issuanceDate, wholeValue, "", "");
            MerchandiseInStatement MIS1 = new MerchandiseInStatement(goodName1, company1, weight1, count1, unitPrice1);
            MerchandiseInStatement MIS2 = new MerchandiseInStatement(goodName2, company2, weight2, count2, unitPrice2);

            statement.AddNewMerchandise(MIS1);
            statement.AddNewMerchandise(MIS2);
            Assert.AreEqual(lawTest.IsValidWithoutMerchandise(statement), expected, "Wrong Check in ");
        }