Exemplo n.º 1
0
        public object ImportFile(string path, int month, int year, string provider)
        {
            JoeUtils.YearMonthCheck(year, month);

            if (provider.ToLower() == "oxford")
            {
                List<OxfordLineItem> items =  OxfordUtils.ReadFile(path);
                OxfordLineItemCollection coll = new OxfordLineItemCollection(items);
                coll.SaveToDatabase(year, month, true);

                return new
                {
                    LineItems = items.Count
                };
            }
            else if (provider.ToLower() == "horizon")
            {
                List<HorizonLineItem> items = HorizonUtils.ReadFile(path);
                HorizonLineItemCollection coll = new HorizonLineItemCollection(items);
                coll.SaveToDatabase(year, month, true);

                return new
                {
                    LineItems = items.Count
                };
            }
            else {
                throw new InvalidOperationException(String.Format("'{0}' is not a valid provider name.", provider));
            }
        }
Exemplo n.º 2
0
        public void TestOverwrite()
        {
            HorizonLineItemCollection Horizons = new HorizonLineItemCollection(HorizonUtils.ReadFile(HorizonTestFileText));

            // try to overwrite
            try
            {
                Horizons.SaveToDatabase(1990, 1);
                Assert.Fail("Records Overwritten!");
            }
            catch
            {
                Assert.IsTrue(true, "");
            }
        }
        public void TestTotals()
        {
            HorizonFile file = repos.HorizonFile(93);

            HorizonLineItemCollection collection = new HorizonLineItemCollection(
                HorizonUtils.ReadFile("../../TestFiles/" + file.Filename));

            // calculated with excel
            // 4495816.46
            // 269079.10
            Assert.AreEqual(269079.10m, collection.CommissionReceived, "Commission calculated incorrectly.");
            Assert.AreEqual(4495816.46m, collection.PremiumReceived, "Premium calculated incorrectly.");

            // check for range
            Assert.IsTrue(.0598m < collection.CommissionPercentage, "Percentage calculated incorrectly.");
            Assert.IsTrue(.0599m > collection.CommissionPercentage, "Percentage calculated incorrectly.");
        }
Exemplo n.º 4
0
        public void TestSaveAndDeleteRecordsText()
        {
            int month = 1;
            int year = 1990;

            repos.DeleteHorizonRecords(year, month);
            repos.SaveChanges();

            int count = repos.RawHorizonRecordsCount(year, month);
            Assert.AreEqual(0, count, String.Format("Should be no records (M/Y): {0}/{1}, they were deleted; found: {2}.", month, year, count));

            // read from file, save items
            HorizonLineItemCollection Horizons = new HorizonLineItemCollection(HorizonUtils.ReadFile(HorizonTestFileText));
            Horizons.SaveToDatabase(year, month, true);

            count = repos.RawHorizonRecordsCount(year, month);
            Assert.AreEqual(4269, count, String.Format("Should be 318 records (M/Y): {0}/{1}; found {2}.", month, year, count));
        }