Пример #1
0
        public void TestCtor()
        {
            var testInput   = new AmericanEmployment();
            var testSubject = new AmericanDeductions(testInput);

            Assert.IsNotNull(testSubject.MyItems);
            Assert.AreEqual(0, testSubject.MyItems.Count);
            Assert.AreEqual(Pecuniam.Zero, testSubject.Total);

            testSubject.AddItem("FICA", "Government", 1200D.ToPecuniam());
            var testResultSum = testSubject.Total;

            Assert.IsNotNull(testResultSum);
            Assert.AreNotEqual(Pecuniam.Zero, testResultSum);
            Assert.AreEqual(1200M.ToPecuniam().GetNeg(), testResultSum);

            testSubject.AddItem("State Tax", "Government", 600D.ToPecuniam());
            testResultSum = testSubject.Total;
            Assert.IsNotNull(testResultSum);
            Assert.AreNotEqual(Pecuniam.Zero, testResultSum);
            Assert.AreEqual(1800M.ToPecuniam().GetNeg(), testResultSum);
        }
Пример #2
0
        public void TestAddItems()
        {
            var testSubject = new AmericanEmployment();

            var testResult = testSubject.Total;

            Assert.AreEqual(Pecuniam.Zero, testResult);
            testResult = testSubject.TotalAnnualNetPay;
            Assert.AreEqual(Pecuniam.Zero, testResult);

            var v = 55000M.ToPecuniam();

            var occ = new SocDetailedOccupation {
                Value = "Accountant"
            };

            testSubject.Occupation = occ;
            testSubject.AddItem("Salary", null, 55000.0);
            testResult = testSubject.Total;
            Assert.AreEqual(v, testResult);
            testResult = testSubject.TotalAnnualNetPay;
            Assert.AreEqual(v, testResult);

            var tax = new AmericanDeductions(testSubject);

            testSubject.Deductions = tax;
            testResult             = testSubject.Total;
            Assert.AreEqual(v, testResult);
            testResult = testSubject.TotalAnnualNetPay;
            Assert.AreEqual(v, testResult);

            var fedTax = 55000.0D * AmericanEquations.FederalIncomeTaxRate.SolveForY(55000.0);

            tax.AddItem("Federal", null, fedTax);
            testResult = testSubject.Total;
            Assert.AreEqual(v, testResult);
            testResult = testSubject.TotalAnnualNetPay;
            Assert.AreEqual((55000.0D - fedTax).ToPecuniam(), testResult);

            testSubject.AddItem("Commission", null, 5000.0D);
            testResult = testSubject.Total;
            Assert.AreEqual(60000.ToPecuniam(), testResult);
            testResult = testSubject.TotalAnnualNetPay;
            Assert.AreEqual(49841.5.ToPecuniam(), testResult);
        }
Пример #3
0
        public void TestAddItems()
        {
            var testSubject = new AmericanIncome();

            var testResult = testSubject.TotalAnnualGrossEmploymentIncome;

            Assert.AreEqual(Pecuniam.Zero, testResult);
            testResult = testSubject.TotalAnnualNetEmploymentIncome;
            Assert.AreEqual(Pecuniam.Zero, testResult);
            testResult = testSubject.Total;
            Assert.AreEqual(Pecuniam.Zero, testResult);

            testSubject.AddItem("stocks", "securities", 9000.0D.ToPecuniam());

            testResult = testSubject.TotalAnnualGrossEmploymentIncome;
            Assert.AreEqual(Pecuniam.Zero, testResult);
            testResult = testSubject.TotalAnnualNetEmploymentIncome;
            Assert.AreEqual(Pecuniam.Zero, testResult);
            testResult = testSubject.Total;
            Assert.AreEqual(9000.0D.ToPecuniam(), testResult);

            testSubject.AddItem("savings", "Banks", 600.0D.ToPecuniam());

            testResult = testSubject.TotalAnnualGrossEmploymentIncome;
            Assert.AreEqual(Pecuniam.Zero, testResult);
            testResult = testSubject.TotalAnnualNetEmploymentIncome;
            Assert.AreEqual(Pecuniam.Zero, testResult);
            testResult = testSubject.Total;
            Assert.AreEqual(9600.0D.ToPecuniam(), testResult);

            var testEmployment = new AmericanEmployment();
            var occ            = new SocDetailedOccupation {
                Value = "Accountant"
            };

            testEmployment.Occupation = occ;
            testEmployment.AddItem("Salary", null, 55000.0);

            testSubject.AddEmployment(testEmployment);
            testResult = testSubject.TotalAnnualGrossEmploymentIncome;
            Assert.AreEqual(55000.0.ToPecuniam(), testResult);
            testResult = testSubject.TotalAnnualNetEmploymentIncome;
            Assert.AreEqual(55000.0.ToPecuniam(), testResult);
            testResult = testSubject.Total;
            Assert.AreEqual((55000.0 + 9600.0D).ToPecuniam(), testResult);

            var tax = new AmericanDeductions(testEmployment);

            testEmployment.Deductions = tax;

            var fedTax = 55000.0D * AmericanEquations.FederalIncomeTaxRate.SolveForY(55000.0);

            tax.AddItem("Federal", null, fedTax);

            testResult = testSubject.TotalAnnualGrossEmploymentIncome;
            Assert.AreEqual(55000.0.ToPecuniam(), testResult);
            testResult = testSubject.TotalAnnualNetEmploymentIncome;
            Assert.AreEqual((55000.0 - fedTax).ToPecuniam(), testResult);
            testResult = testSubject.Total;
            Assert.AreEqual((55000.0 + 9600.0D - fedTax).ToPecuniam(), testResult);
        }