public void TestGetGroupNames2Portions() { var testInput = new AmericanEmployment(); var testSubject = new AmericanDeductions(testInput); var testResults = testSubject.GetGroupNames2Portions(null); Assert.IsTrue(testResults.Any(t => t.Item1 == AmericanDomusOpesBase.DeductionGroupNames.INSURANCE)); Assert.AreNotEqual(0, testResults.First(t => t.Item1 == AmericanDomusOpesBase.DeductionGroupNames.INSURANCE).Item2); Assert.IsTrue(testResults.Any(t => t.Item1 == AmericanDomusOpesBase.DeductionGroupNames.EMPLOYMENT)); Assert.AreNotEqual(0, testResults.First(t => t.Item1 == AmericanDomusOpesBase.DeductionGroupNames.EMPLOYMENT).Item2); Assert.IsTrue(testResults.Any(t => t.Item1 == AmericanDomusOpesBase.DeductionGroupNames.GOVERNMENT)); Assert.AreNotEqual(0, testResults.First(t => t.Item1 == AmericanDomusOpesBase.DeductionGroupNames.GOVERNMENT).Item2); Assert.IsTrue(testResults.Any(t => t.Item1 == AmericanDomusOpesBase.DeductionGroupNames.JUDGMENTS)); Assert.AreEqual(0, testResults.First(t => t.Item1 == AmericanDomusOpesBase.DeductionGroupNames.JUDGMENTS).Item2); var testOptions = new AmericanDomusOpesOptions(); testOptions.AddGivenDirectly(AmericanDomusOpesBase.DeductionGroupNames.JUDGMENTS, 1000); testResults = testSubject.GetGroupNames2Portions(testOptions); Assert.IsTrue(testResults.Any(t => t.Item1 == AmericanDomusOpesBase.DeductionGroupNames.JUDGMENTS)); Assert.AreNotEqual(0, testResults.First(t => t.Item1 == AmericanDomusOpesBase.DeductionGroupNames.JUDGMENTS).Item2); }
public void TestGetEmploymentDeductionName2Rates() { var testInput = new AmericanEmployment(); var testSubject = new AmericanDeductions(testInput); var testOptions = new AmericanDomusOpesOptions { Inception = DateTime.Today.AddYears(-1) }; var testResult = testSubject.GetEmploymentDeductionName2Rates(testOptions); Assert.IsNotNull(testResult); Assert.AreNotEqual(0, testResult.Count); foreach (var tr in testResult) { Console.WriteLine(tr); } var testResultSum = testResult.Select(kv => kv.Value).Sum(); Assert.AreEqual(1D, Math.Round(testResultSum)); Assert.IsNotNull(testOptions.SumTotal); Assert.AreNotEqual(0D, testOptions.SumTotal); Console.WriteLine(testOptions.SumTotal); }
public void TestResolveItemsWithJudgements() { var testInput = new AmericanEmployment(); var options = new AmericanDomusOpesOptions { Inception = DateTime.Today.AddYears(-1), SumTotal = 75000D }; testInput.RandomizeAllItems(options); var testSubject = new AmericanDeductions(testInput); options.IsPayingChildSupport = true; testSubject.RandomizeAllItems(options); Assert.IsNotNull(testSubject.MyItems); Assert.AreNotEqual(0, testSubject.MyItems.Count); var testResultItem = testSubject.MyItems.FirstOrDefault(x => x.Name == "Child Support"); Assert.IsNotNull(testResultItem); Assert.AreNotEqual(0.ToPecuniam(), testResultItem.Value); Console.WriteLine(testResultItem.Value); }
public void TestDeductionsAllPresent() { var testInput = new AmericanEmployment(); var options = new AmericanDomusOpesOptions { Inception = DateTime.Today.AddYears(-1), SumTotal = 75000D }; testInput.RandomizeAllItems(options); //check input is good Assert.IsNotNull(testInput.MyItems); Assert.AreNotEqual(0, testInput.MyItems.Count); var diff = Math.Abs(testInput.Total.ToDouble() - 75000); Console.WriteLine(diff); Assert.IsTrue(Math.Round(diff) == 0.0D); var testSubject = new AmericanDeductions(testInput); testSubject.RandomizeAllItems(null); var testResults = testSubject.GetAt(DateTime.Today.AddDays(-182)); var allDeductionsItesm = WealthBaseTests.GetExpectedNamesFromXml("deduction"); Assert.IsNotNull(testResults); Assert.IsNotNull(allDeductionsItesm); Assert.AreEqual(allDeductionsItesm.Count, testResults.Length); }
public void TestGetItemNames() { var testSubject = new AmericanDeductions(); var testNames = testSubject.GetItemNames(testSubject.DivisionName); var allNames = WealthBaseTests.GetExpectedNamesFromXml("deduction"); var expectations = allNames.Select(n => n.Item2).Distinct(); foreach (var tn in testNames) { Assert.IsTrue(expectations.Any(e => string.Equals(e, tn.Name, StringComparison.OrdinalIgnoreCase))); Console.WriteLine(tn); } }
public void TestResolveItems() { var testInput = new AmericanEmployment(); var testSubject = new AmericanDeductions(testInput); testSubject.RandomizeAllItems(null); Assert.IsNotNull(testSubject.MyItems); Assert.AreNotEqual(0, testSubject.MyItems.Count); foreach (var p in testSubject.MyItems) { Console.WriteLine(p); } }
public void TestToData() { var testSubjectContext = AmericanEmployment.RandomEmployment(); var testSubject = new AmericanDeductions(testSubjectContext); testSubject.RandomizeAllItems(null); Assert.IsNotNull(testSubject); var testResult = testSubject.ToData(KindsOfTextCase.Kabab); Assert.IsNotNull(testResult); Assert.AreNotEqual(0, testResult.Count); foreach (var tr in testResult.Keys) { Console.WriteLine($"{tr}, {testResult[tr]}"); } }
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); }
public void TestDeductionsRatioToIncome() { var testInput = new AmericanEmployment(); var annualIncome = 75000.ToPecuniam(); var options = new AmericanDomusOpesOptions { Inception = DateTime.Today.AddYears(-1), SumTotal = annualIncome.ToDouble() }; testInput.RandomizeAllItems(options); //check input is good Assert.IsNotNull(testInput.MyItems); Assert.AreNotEqual(0, testInput.MyItems.Count); var diff = Math.Abs(testInput.Total.ToDouble() - annualIncome.ToDouble()); Console.WriteLine(diff); Assert.IsTrue(Math.Round(diff) == 0.0D); var testSubject = new AmericanDeductions(testInput); testSubject.RandomizeAllItems(null); Assert.IsNotNull(testSubject.MyItems); Assert.AreNotEqual(0, testSubject.MyItems.Count); var totalDeductions = testSubject.Total; Assert.AreNotEqual(0.0D.ToPecuniam(), totalDeductions); //expect deductions as a negative number Assert.IsTrue(totalDeductions.ToDouble() < 0.0D); Console.WriteLine(totalDeductions); var ratio = Math.Abs(Math.Round(((annualIncome + totalDeductions) / annualIncome).ToDouble(), 2)); Assert.IsTrue(ratio < 1.0); Assert.IsTrue(ratio > 0.5); Console.WriteLine(totalDeductions); }
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); }
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); }