public void AnonymizePosts_Constuctor_PopulatesHandler() { AnonymizePosts parent = new AnonymizePosts(null); AnonymizePosts current = new AnonymizePosts(parent); Assert.Equal(parent, current.Handler); }
public static PostHandler ChainPrePostHandlers(PostHandler baseHandler, Report report) { PostHandler handler = baseHandler; // anonymize_posts removes all meaningful information from xact payee's and // account names, for the sake of creating useful bug reports. if (report.AnonHandler.Handled) { handler = new AnonymizePosts(handler); } // This filter_posts will only pass through posts matching the `predicate'. if (report.LimitHandler.Handled) { Logger.Current.Debug("report.predicate", () => String.Format("Report predicate expression = {0}", report.LimitHandler.Str())); handler = new FilterPosts(handler, new Predicate(report.LimitHandler.Str(), report.WhatToKeep()), report); } // budget_posts takes a set of posts from a data file and uses them to // generate "budget posts" which balance against the reported posts. // // forecast_posts is a lot like budget_posts, except that it adds xacts // only for the future, and does not balance them against anything but the // future balance. if (report.BudgetFlags != ReportBudgetFlags.BUDGET_NO_BUDGET) { BudgetPosts budgetHandler = new BudgetPosts(handler, (Date)report.Terminus.Date, report.BudgetFlags); budgetHandler.AddPeriodXacts(report.Session.Journal.PeriodXacts); handler = budgetHandler; // Apply this before the budget handler, so that only matching posts are // calculated toward the budget. The use of filter_posts above will // further clean the results so that no automated posts that don't match // the filter get reported. if (report.LimitHandler.Handled) { handler = new FilterPosts(handler, new Predicate(report.LimitHandler.Str(), report.WhatToKeep()), report); } } else if (report.ForecastWhileHandler.Handled) { ForecastPosts forecastPosts = new ForecastPosts(handler, new Predicate(report.ForecastWhileHandler.Str(), report.WhatToKeep()), report, report.ForecastYearsHandler.Handled ? int.Parse(report.ForecastYearsHandler.Value) : 5); forecastPosts.AddPeriodXacts(report.Session.Journal.PeriodXacts); handler = forecastPosts; // See above, under budget_posts. if (report.LimitHandler.Handled) { handler = new FilterPosts(handler, new Predicate(report.LimitHandler.Str(), report.WhatToKeep()), report); } } return(handler); }
public void AnonymizePosts_RenderCommodity_HidesCommodityName() { string commodityName1 = "comm-name-1"; string commodityName2 = "comm-name-2"; Commodity commodity1 = CommodityPool.Current.FindOrCreate(commodityName1); Commodity commodity2 = CommodityPool.Current.FindOrCreate(commodityName2); Amount amount1 = new Amount(10, commodity1); Amount amount2 = new Amount(10, commodity2); AnonymizePosts anonymizePosts = new AnonymizePosts(null); anonymizePosts.RenderCommodity(amount1); anonymizePosts.RenderCommodity(amount2); Assert.Equal("A", amount1.Commodity.Symbol); Assert.Equal("B", amount2.Commodity.Symbol); Assert.Equal(commodityName1, anonymizePosts.CommodityIndexMap.Keys.First().BaseSymbol); Assert.Equal(commodityName2, anonymizePosts.CommodityIndexMap.Keys.Last().BaseSymbol); }
public void AnonymizePosts_Constuctor_AcceptsNulls() { AnonymizePosts anonymizePosts = new AnonymizePosts(null); Assert.Null(anonymizePosts.Handler); }