public void ListAllCloseablePlans() { const string accountName = "ExpenseManagerAccount01"; const string typeName = "Food"; var account = new AccountModel { Badges = new List <AccountBadgeModel>(), Costs = new List <CostInfoModel>(), Name = accountName }; var type = new CostTypeModel { Name = typeName, CostInfoList = new EditableList <CostInfoModel>(), Account = account }; var plan = new PlanModel { Description = "I want money for food!", PlanType = PlanTypeModel.Save, PlannedMoney = 10000, IsCompleted = false, }; using ( var db = new ExpenseDbContext( Effort.DbConnectionFactory.CreatePersistent(TestInstaller.ExpenseManagerTestDbConnection))) { db.Accounts.Add(account); db.CostTypes.Add(type); db.SaveChanges(); var accountId = account.Id; plan.AccountId = accountId; plan.PlannedType = type; db.Plans.Add(plan); db.SaveChanges(); var item = new CostInfoModel() { Description = "bread", AccountId = accountId, TypeId = type.Id, IsIncome = true, Money = 10001, Created = DateTime.Now.Subtract(new TimeSpan(100, 0, 0, 0)), Account = db.Accounts.Find(accountId), Type = db.CostTypes.Find(type.Id), Periodicity = PeriodicityModel.None, PeriodicMultiplicity = 3 }; db.CostInfos.Add(item); db.SaveChanges(); } Assert.IsTrue(_balanceFacade.ListPlans(null, null).Count == 1, "Plan not present"); Assert.IsTrue(_balanceFacade.ListAllCloseablePlans(account.Id).Count == 1, "Plan not found as closeable"); }
private List <PlanViewModel> GetClosablePlans(Account account) { var plans = _balanceFacade.ListAllCloseablePlans(account.Id); return(Mapper.Map <List <PlanViewModel> >(plans)); }