public void TestBalanceSheetNoAccounts() { ILoggerFactory loggerFactory = new LoggerFactory(); using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { var currencyFactory = new CurrencyFactory(); var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true); currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity); var accountService = new AccountService( loggerFactory, sqliteMemoryWrapper.DbContext ); var currencyService = new CurrencyService( loggerFactory, sqliteMemoryWrapper.DbContext ); var balanceSheetService = new BalanceSheetService( loggerFactory, sqliteMemoryWrapper.DbContext ); BalanceSheet balanceSheet = balanceSheetService.Generate(new DateTime(2018, 1, 1)); Assert.AreEqual(usdCurrencyEntity.Symbol, balanceSheet.CurrencySymbol); Assert.AreEqual(0, balanceSheet.TotalAssets); Assert.AreEqual(0, balanceSheet.TotalLiabilities); Assert.AreEqual(0, balanceSheet.Assets.Count()); Assert.AreEqual(0, balanceSheet.Liabilities.Count()); } }
public void TestAccountCreateViewModelCancel() { ILoggerFactory loggerFactory = new LoggerFactory(); using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { var currencyFactory = new CurrencyFactory(); var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true); currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity); var accountService = new AccountService( loggerFactory, sqliteMemoryWrapper.DbContext); var currencyService = new CurrencyService( loggerFactory, sqliteMemoryWrapper.DbContext); var viewModel = new AccountCreateViewModel( loggerFactory, accountService, currencyService ); viewModel.Name = "MyAccount"; viewModel.SelectedAccountType = AccountType.Asset; viewModel.SelectedAccountSubType = AccountSubType.Investment; viewModel.CancelCommand.Execute(this); List <Account> accounts = accountService.GetAll().ToList(); Assert.AreEqual(0, accounts.Count); } }
public SqlDataStrategy( ICurrencyRepository currencyRepository, CurrencyFactory currencyFactory) { _currencyRepository = currencyRepository; _currencyFactory = currencyFactory; }
public async Task Consume(ConsumeContext <AccountCreated> context) { //var ser = JsonSerializer.Serialize(context.Message); var acc = context.Message.Event.To(); Console.WriteLine($"Receive created account with {acc.Id.Value.Value} with convId = {context.ConversationId} "); var createTran = new CreateTransaction( acc.Id, new TransactionId(UniqId.New()), new TransactionLabel("user2user_source"), new CreateAmountCompletedIncome(AmountFactory.New("10.00", CurrencyFactory.New("MXN"))), "asdasd" ); await context.Publish(CreateTransactionCommand.From(createTran)); createTran = new CreateTransaction( acc.Id, new TransactionId(UniqId.New()), new TransactionLabel("user2user_destination"), new CreateAmountCompletedIncome(AmountFactory.New("10.00", CurrencyFactory.New("MXN"))), "asdasd" ); await context.Publish(CreateTransactionCommand.From(createTran)); }
public void TestGetAllManyCurrencies() { ILoggerFactory loggerFactory = new LoggerFactory(); using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { var currencyFactory = new CurrencyFactory(); var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true); var gbpCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Gbp, false); currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity); currencyFactory.Add(sqliteMemoryWrapper.DbContext, gbpCurrencyEntity); var currencyService = new CurrencyService(loggerFactory, sqliteMemoryWrapper.DbContext); List <Currency> currencies = currencyService.GetAll().ToList(); Assert.AreEqual(2, currencies.Count); Assert.AreEqual(usdCurrencyEntity.Name, currencies[0].Name); Assert.AreEqual(usdCurrencyEntity.ShortName, currencies[0].ShortName); Assert.AreEqual(usdCurrencyEntity.Symbol, currencies[0].Symbol); Assert.AreEqual(usdCurrencyEntity.IsPrimary, currencies[0].IsPrimary); Assert.AreEqual(gbpCurrencyEntity.Name, currencies[1].Name); Assert.AreEqual(gbpCurrencyEntity.ShortName, currencies[1].ShortName); Assert.AreEqual(gbpCurrencyEntity.Symbol, currencies[1].Symbol); Assert.AreEqual(gbpCurrencyEntity.IsPrimary, currencies[1].IsPrimary); } }
[TestMethod] public void CreateTest() { var b = GetRandom.Object <CurrencyData>(); o = CurrencyFactory.Create(b.ID, b.Name, b.Code, b.ValidFrom, b.ValidTo); validateResults(b.ID, b.Name, b.Code, b.ValidFrom, b.ValidTo); }
[TestMethod] public void CreateWithRegionInfoTest() { var i = new RegionInfo("ee-EE"); o = CurrencyFactory.Create(i); validateResults(i.ISOCurrencySymbol, i.CurrencyEnglishName, i.CurrencySymbol); }
public void TestBudgetCreateViewModelCancel() { ILoggerFactory loggerFactory = new LoggerFactory(); using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { var currencyFactory = new CurrencyFactory(); var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true); currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity); var budgetService = new BudgetService( loggerFactory, sqliteMemoryWrapper.DbContext); var viewModel = new BudgetCreateViewModel( loggerFactory, budgetService, new Mock <IBudgetTransactionListViewModelFactory>().Object ); viewModel.Name = "My First Budget"; viewModel.CancelCommand.Execute(this); List <Budget> budgets = budgetService.GetAll().ToList(); Assert.AreEqual(0, budgets.Count); } }
public static void Initialize(ApplicationDbContext c) { c.Database.EnsureCreated(); if (c.Currencies.Any()) { return; } var list = new List <string>(); var regions = SystemRegionInfo.GetRegionsList(); foreach (var r in regions) { if (!SystemRegionInfo.IsCountry(r)) { continue; } if (list.Contains(r.ISOCurrencySymbol)) { continue; } var e = CurrencyFactory.Create(r); c.Currencies.Add(e.Data); list.Add(r.ISOCurrencySymbol); } c.SaveChanges(); }
public CurrencySystem(params CurrencyData[] currencies) { this.currencies = generateCurrencyLookup(currencies); this.factory = new CurrencyFactory(); this.food = new FoodSystem(); this.food.SetAmount(startingDogFood); }
public void Initialize(CraftingTree craftingTree, EquipmentFactory equipmentFactory, CurrencyFactory currencyFactory, List <ItemPrototypeModel> itemPrototypes, double baseItemCost) { _craftingTree = craftingTree; _craftingTree.ClearCurrencySpent(); _currencyFactory = currencyFactory; _equipmentFactory = equipmentFactory; _itemPrototypes = itemPrototypes.OrderByDescending(x => x.Value).ThenBy(x => x.ItemName).ToList(); MatchingItems.Clear(); EquipmentList.Clear(); foreach (var prototype in _itemPrototypes) { MatchingItems.Add(prototype, new List <Equipment>()); } if (_task != null && _task.Status == TaskStatus.Running) { _cancellationTokenSource.Cancel(); } Progress = -1; ScourCount = 0; BaseItemCount = 0; BaseItemCost = baseItemCost; OnPropertyChanged(nameof(Message)); OnPropertyChanged(nameof(Progress)); OnPropertyChanged(nameof(MessageVisibility)); }
public SimulationWindow( BaseSelectionControl baseSelection, ItemListControl itemList, CraftingControl crafting, CraftingResultsControl results, EquipmentFactory equipmentFactory, CurrencyFactory currencyFactory) { BaseSelection = baseSelection; ItemList = itemList; Crafting = crafting; Results = results; _controls = new List <ISimulationControl> { BaseSelection, ItemList, Crafting, Results }; Crafting.OnCompletion = () => OnNextClick(this, null); SelectedStep = BaseSelection; BaseSelection.Initialize(() => OnPropertyChanged(nameof(IsReady))); InitializeComponent(); DataContext = this; _equipmentFactory = equipmentFactory; _currencyFactory = currencyFactory; }
public void TestGetAccount() { ILoggerFactory loggerFactory = new LoggerFactory(); using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { var currencyFactory = new CurrencyFactory(); var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true); currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity); var accountFactory = new AccountFactory(); Entities.Account checkingAccountEntity = accountFactory.Create(AccountPrefab.Checking, usdCurrencyEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, checkingAccountEntity); var accountService = new AccountService(loggerFactory, sqliteMemoryWrapper.DbContext); Account checkingAccount = accountService.Get(checkingAccountEntity.AccountId); Assert.AreEqual(checkingAccountEntity.AccountId, checkingAccount.AccountId); Assert.AreEqual(checkingAccountEntity.Name, checkingAccount.Name); Assert.AreEqual(AccountType.Asset, checkingAccount.Type); Assert.AreEqual(usdCurrencyEntity.CurrencyId, checkingAccount.Currency.CurrencyId); Assert.AreEqual(usdCurrencyEntity.IsPrimary, checkingAccount.Currency.IsPrimary); Assert.AreEqual(usdCurrencyEntity.Name, checkingAccount.Currency.Name); Assert.AreEqual(usdCurrencyEntity.ShortName, checkingAccount.Currency.ShortName); Assert.AreEqual(usdCurrencyEntity.Symbol, checkingAccount.Currency.Symbol); } }
public CraftingTestbedModel(EquipmentFactory factory, CurrencyFactory currencyFactory, EquipmentFetch equipmentFetch) { _equipmentFetch = equipmentFetch; _factory = factory; CurrencyFactory = currencyFactory; ItemSubtypeNames = equipmentFetch.FetchSubtypes(); Status = new ItemStatus(); }
public void TestGetAllAccountRelationships() { ILoggerFactory loggerFactory = new LoggerFactory(); using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { var currencyFactory = new CurrencyFactory(); var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true); currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity); var accountFactory = new AccountFactory(); Entities.Account incomeAccountEntity = accountFactory.Create(AccountPrefab.Income, usdCurrencyEntity); Entities.Account checkingAccountEntity = accountFactory.Create(AccountPrefab.Checking, usdCurrencyEntity); Entities.Account groceriesPrepaymentAccountEntity = accountFactory.Create(AccountPrefab.GroceriesPrepayment, usdCurrencyEntity); Entities.Account rentPrepaymentAccountEntity = accountFactory.Create(AccountPrefab.RentPrepayment, usdCurrencyEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, incomeAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, checkingAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, groceriesPrepaymentAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, rentPrepaymentAccountEntity); var checkingToGroceriesPrepaymentRelationship = new Entities.AccountRelationship { SourceAccount = checkingAccountEntity, DestinationAccount = groceriesPrepaymentAccountEntity, Type = AccountRelationshipType.PhysicalToLogical }; var checkingToRentPrepaymentRelationship = new Entities.AccountRelationship { SourceAccount = checkingAccountEntity, DestinationAccount = rentPrepaymentAccountEntity, Type = AccountRelationshipType.PhysicalToLogical }; sqliteMemoryWrapper.DbContext.AccountRelationships.Add(checkingToGroceriesPrepaymentRelationship); sqliteMemoryWrapper.DbContext.AccountRelationships.Add(checkingToRentPrepaymentRelationship); sqliteMemoryWrapper.DbContext.SaveChanges(); var accountRelationshipService = new AccountRelationshipService(loggerFactory, sqliteMemoryWrapper.DbContext); List <AccountRelationship> accountRelationships = accountRelationshipService.GetAll().ToList(); Assert.AreEqual(2, accountRelationships.Count); Assert.AreEqual(AccountRelationshipType.PhysicalToLogical, accountRelationships[0].Type); Assert.AreEqual(checkingAccountEntity.AccountId, accountRelationships[0].SourceAccount.AccountId); Assert.AreEqual(checkingAccountEntity.Name, accountRelationships[0].SourceAccount.Name); Assert.AreEqual(groceriesPrepaymentAccountEntity.AccountId, accountRelationships[0].DestinationAccount.AccountId); Assert.AreEqual(groceriesPrepaymentAccountEntity.Name, accountRelationships[0].DestinationAccount.Name); Assert.AreEqual(AccountRelationshipType.PhysicalToLogical, accountRelationships[1].Type); Assert.AreEqual(checkingAccountEntity.AccountId, accountRelationships[1].SourceAccount.AccountId); Assert.AreEqual(checkingAccountEntity.Name, accountRelationships[1].SourceAccount.Name); Assert.AreEqual(rentPrepaymentAccountEntity.AccountId, accountRelationships[1].DestinationAccount.AccountId); Assert.AreEqual(rentPrepaymentAccountEntity.Name, accountRelationships[1].DestinationAccount.Name); } }
public void TestCreateManyTransactions() { ILoggerFactory loggerFactory = new LoggerFactory(); using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { var currencyFactory = new CurrencyFactory(); var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true); currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity); var accountFactory = new AccountFactory(); Entities.Account incomeAccountEntity = accountFactory.Create(AccountPrefab.Income, usdCurrencyEntity); Entities.Account checkingAccountEntity = accountFactory.Create(AccountPrefab.Checking, usdCurrencyEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, incomeAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, checkingAccountEntity); var accountService = new AccountService( loggerFactory, sqliteMemoryWrapper.DbContext ); var transactionService = new TransactionService( loggerFactory, sqliteMemoryWrapper.DbContext ); var newTransactions = new Transaction[] { new Transaction { CreditAccount = accountService.GetAsLink(incomeAccountEntity.AccountId), DebitAccount = accountService.GetAsLink(checkingAccountEntity.AccountId), Amount = 100m, At = new DateTime(2018, 1, 1, 9, 0, 0) }, new Transaction { CreditAccount = accountService.GetAsLink(incomeAccountEntity.AccountId), DebitAccount = accountService.GetAsLink(checkingAccountEntity.AccountId), Amount = 70m, At = new DateTime(2018, 1, 1, 9, 25, 0) } }; transactionService.CreateMany(newTransactions); List <Entities.Transaction> transactionEntities = sqliteMemoryWrapper.DbContext.Transactions.ToList(); Assert.AreEqual(2, transactionEntities.Count); Assert.AreEqual(newTransactions[0].TransactionId, transactionEntities[0].TransactionId); Assert.AreEqual(newTransactions[0].CreditAccount.AccountId, transactionEntities[0].CreditAccount.AccountId); Assert.AreEqual(newTransactions[0].DebitAccount.AccountId, transactionEntities[0].DebitAccount.AccountId); Assert.AreEqual(newTransactions[0].Amount, transactionEntities[0].Amount); Assert.AreEqual(newTransactions[0].At, transactionEntities[0].At); Assert.AreEqual(newTransactions[1].TransactionId, transactionEntities[1].TransactionId); Assert.AreEqual(newTransactions[1].CreditAccount.AccountId, transactionEntities[1].CreditAccount.AccountId); Assert.AreEqual(newTransactions[1].DebitAccount.AccountId, transactionEntities[1].DebitAccount.AccountId); Assert.AreEqual(newTransactions[1].Amount, transactionEntities[1].Amount); Assert.AreEqual(newTransactions[1].At, transactionEntities[1].At); } }
public void TestAccountRelationshipEditViewModelOK() { ILoggerFactory loggerFactory = new LoggerFactory(); using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { var currencyFactory = new CurrencyFactory(); var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true); currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity); var accountFactory = new AccountFactory(); Entities.Account checkingAccountEntity = accountFactory.Create(AccountPrefab.Checking, usdCurrencyEntity); Entities.Account rentPrepaymentAccountEntity = accountFactory.Create(AccountPrefab.RentPrepayment, usdCurrencyEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, checkingAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, rentPrepaymentAccountEntity); var checkingToRentPrepaymentRelationship = new Entities.AccountRelationship { SourceAccount = checkingAccountEntity, DestinationAccount = rentPrepaymentAccountEntity, Type = AccountRelationshipType.PhysicalToLogical }; sqliteMemoryWrapper.DbContext.AccountRelationships.Add(checkingToRentPrepaymentRelationship); sqliteMemoryWrapper.DbContext.SaveChanges(); var accountService = new AccountService( loggerFactory, sqliteMemoryWrapper.DbContext); var accountRelationshipService = new AccountRelationshipService( loggerFactory, sqliteMemoryWrapper.DbContext); var viewModel = new AccountRelationshipEditViewModel( loggerFactory, accountService, accountRelationshipService, checkingToRentPrepaymentRelationship.AccountRelationshipId ); viewModel.SelectedType = AccountRelationshipType.PrepaymentToExpense; viewModel.OKCommand.Execute(this); List <AccountRelationship> accountRelationships = accountRelationshipService.GetAll().ToList(); Assert.AreEqual(1, accountRelationships.Count); Assert.AreEqual(checkingToRentPrepaymentRelationship.SourceAccountId, accountRelationships[0].SourceAccount.AccountId); Assert.AreEqual(checkingToRentPrepaymentRelationship.DestinationAccountId, accountRelationships[0].DestinationAccount.AccountId); Assert.AreEqual(viewModel.SelectedType, accountRelationships[0].Type); } }
public void TestTransactionCreateViewModelCancel() { ILoggerFactory loggerFactory = new LoggerFactory(); using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { var currencyFactory = new CurrencyFactory(); var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true); currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity); var accountFactory = new AccountFactory(); Entities.Account incomeAccountEntity = accountFactory.Create(AccountPrefab.Income, usdCurrencyEntity); Entities.Account checkingAccountEntity = accountFactory.Create(AccountPrefab.Checking, usdCurrencyEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, incomeAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, checkingAccountEntity); var accountService = new AccountService( loggerFactory, sqliteMemoryWrapper.DbContext); var transactionService = new TransactionService( loggerFactory, sqliteMemoryWrapper.DbContext); var mockViewModelFactory = new Mock <IAccountLinkViewModelFactory>(); mockViewModelFactory .Setup(f => f.Create(It.IsAny <AccountLink>())) .Returns((AccountLink accountLink) => { return(new AccountLinkViewModel( loggerFactory, accountLink)); }); var hint = new Transaction { CreditAccount = accountService.GetAsLink(incomeAccountEntity.AccountId), DebitAccount = accountService.GetAsLink(checkingAccountEntity.AccountId), Amount = 10m, At = new DateTime(2018, 1, 1, 9, 0, 0) }; var viewModel = new TransactionCreateViewModel( loggerFactory, accountService, transactionService, mockViewModelFactory.Object, hint ); viewModel.CancelCommand.Execute(this); List <Transaction> transactions = transactionService.GetAll().ToList(); Assert.AreEqual(0, transactions.Count); } }
public CraftingProcessView(CurrencyFactory factory, IItemConfigRepository configRepository, EquipmentFactory equipmentFactory) { _configRepository = configRepository; _equipmentFactory = equipmentFactory; CraftingTree = new CraftingTree(factory); Tree = new CraftingTreeViewModel(CraftingTree, _selected); InitializeComponent(); DataContext = this; }
public void TestReloadAccountRelationship() { const string path = "TestData/AccountRelationshipReload.xml"; ILoggerFactory loggerFactory = new LoggerFactory(); var currencyFactory = new CurrencyFactory(); var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true); var accountFactory = new AccountFactory(); Entities.Account checkingAccountEntity = accountFactory.Create(AccountPrefab.Checking, usdCurrencyEntity); Entities.Account rentPrepaymentAccountEntity = accountFactory.Create(AccountPrefab.RentPrepayment, usdCurrencyEntity); var accountRelationship = new Entities.AccountRelationship { SourceAccount = checkingAccountEntity, DestinationAccount = rentPrepaymentAccountEntity, Type = AccountRelationshipType.PhysicalToLogical }; using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, checkingAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, rentPrepaymentAccountEntity); sqliteMemoryWrapper.DbContext.AccountRelationships.Add(accountRelationship); sqliteMemoryWrapper.DbContext.SaveChanges(); var service = new DatabaseSerializationXmlService(loggerFactory, sqliteMemoryWrapper.DbContext); service.Save(path); } using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { var service = new DatabaseSerializationXmlService(loggerFactory, sqliteMemoryWrapper.DbContext); service.Load(path); List <Entities.Account> accounts = sqliteMemoryWrapper.DbContext.Accounts.ToList(); List <Entities.AccountRelationship> accountRelationships = sqliteMemoryWrapper.DbContext.AccountRelationships.ToList(); List <Entities.Currency> currencies = sqliteMemoryWrapper.DbContext.Currencies.ToList(); List <Entities.Transaction> transactions = sqliteMemoryWrapper.DbContext.Transactions.ToList(); Assert.AreEqual(2, accounts.Count); Assert.AreEqual(1, accountRelationships.Count); Assert.AreEqual(1, currencies.Count); Assert.AreEqual(0, transactions.Count); Assert.AreEqual(checkingAccountEntity.Name, accountRelationships[0].SourceAccount.Name); Assert.AreEqual(rentPrepaymentAccountEntity.Name, accountRelationships[0].DestinationAccount.Name); Assert.AreEqual(accountRelationship.Type, accountRelationships[0].Type); } }
public void TestCreateAccountRelationship() { ILoggerFactory loggerFactory = new LoggerFactory(); using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { var currencyFactory = new CurrencyFactory(); var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true); currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity); var accountFactory = new AccountFactory(); Entities.Account incomeAccountEntity = accountFactory.Create(AccountPrefab.Income, usdCurrencyEntity); Entities.Account checkingAccountEntity = accountFactory.Create(AccountPrefab.Checking, usdCurrencyEntity); Entities.Account groceriesPrepaymentAccountEntity = accountFactory.Create(AccountPrefab.GroceriesPrepayment, usdCurrencyEntity); Entities.Account rentPrepaymentAccountEntity = accountFactory.Create(AccountPrefab.RentPrepayment, usdCurrencyEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, incomeAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, checkingAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, groceriesPrepaymentAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, rentPrepaymentAccountEntity); var accountService = new AccountService( loggerFactory, sqliteMemoryWrapper.DbContext ); AccountLink checkingAccountLink = accountService.GetAsLink(checkingAccountEntity.AccountId); AccountLink rentPrepaymentAccountLink = accountService.GetAsLink(rentPrepaymentAccountEntity.AccountId); var accountRelationshipService = new AccountRelationshipService( loggerFactory, sqliteMemoryWrapper.DbContext ); var newRelationship = new AccountRelationship { SourceAccount = checkingAccountLink, DestinationAccount = rentPrepaymentAccountLink, Type = AccountRelationshipType.PhysicalToLogical }; accountRelationshipService.Create(newRelationship); List <Entities.AccountRelationship> accountRelationshipEntities = sqliteMemoryWrapper.DbContext.AccountRelationships.ToList(); Assert.AreEqual(1, accountRelationshipEntities.Count); Assert.AreEqual(AccountRelationshipType.PhysicalToLogical, accountRelationshipEntities[0].Type); Assert.AreEqual(checkingAccountEntity.AccountId, accountRelationshipEntities[0].SourceAccount.AccountId); Assert.AreEqual(checkingAccountEntity.Name, accountRelationshipEntities[0].SourceAccount.Name); Assert.AreEqual(rentPrepaymentAccountEntity.AccountId, accountRelationshipEntities[0].DestinationAccount.AccountId); Assert.AreEqual(rentPrepaymentAccountEntity.Name, accountRelationshipEntities[0].DestinationAccount.Name); } }
public void TestGetLogicalAccountIds() { ILoggerFactory loggerFactory = new LoggerFactory(); using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { var currencyFactory = new CurrencyFactory(); var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true); currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity); var accountFactory = new AccountFactory(); Entities.Account incomeAccountEntity = accountFactory.Create(AccountPrefab.Income, usdCurrencyEntity); Entities.Account checkingAccountEntity = accountFactory.Create(AccountPrefab.Checking, usdCurrencyEntity); Entities.Account groceriesPrepaymentAccountEntity = accountFactory.Create(AccountPrefab.GroceriesPrepayment, usdCurrencyEntity); Entities.Account rentPrepaymentAccountEntity = accountFactory.Create(AccountPrefab.RentPrepayment, usdCurrencyEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, incomeAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, checkingAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, groceriesPrepaymentAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, rentPrepaymentAccountEntity); var checkingToGroceriesPrepaymentRelationship = new Entities.AccountRelationship { SourceAccount = checkingAccountEntity, DestinationAccount = groceriesPrepaymentAccountEntity, Type = AccountRelationshipType.PhysicalToLogical }; var checkingToRentPrepaymentRelationship = new Entities.AccountRelationship { SourceAccount = checkingAccountEntity, DestinationAccount = rentPrepaymentAccountEntity, Type = AccountRelationshipType.PhysicalToLogical }; sqliteMemoryWrapper.DbContext.AccountRelationships.Add(checkingToGroceriesPrepaymentRelationship); sqliteMemoryWrapper.DbContext.AccountRelationships.Add(checkingToRentPrepaymentRelationship); sqliteMemoryWrapper.DbContext.SaveChanges(); var accountService = new AccountService(loggerFactory, sqliteMemoryWrapper.DbContext); var incomeAccountLogicalAccountIds = new HashSet <int>(accountService.GetLogicalAccountIds(incomeAccountEntity.AccountId)); var checkingAccountLogicalAccountIds = new HashSet <int>(accountService.GetLogicalAccountIds(checkingAccountEntity.AccountId)); var groceriesPrepaymentAccountLogicalAccountIds = new HashSet <int>(accountService.GetLogicalAccountIds(groceriesPrepaymentAccountEntity.AccountId)); Assert.AreEqual(0, incomeAccountLogicalAccountIds.Count); Assert.AreEqual(2, checkingAccountLogicalAccountIds.Count); Assert.IsTrue(checkingAccountLogicalAccountIds.Contains(groceriesPrepaymentAccountEntity.AccountId)); Assert.IsTrue(checkingAccountLogicalAccountIds.Contains(rentPrepaymentAccountEntity.AccountId)); Assert.AreEqual(0, groceriesPrepaymentAccountLogicalAccountIds.Count); } }
public void TestTransactionDelete() { ILoggerFactory loggerFactory = new LoggerFactory(); using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { var currencyFactory = new CurrencyFactory(); var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true); currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity); var accountFactory = new AccountFactory(); Entities.Account incomeAccountEntity = accountFactory.Create(AccountPrefab.Income, usdCurrencyEntity); Entities.Account checkingAccountEntity = accountFactory.Create(AccountPrefab.Checking, usdCurrencyEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, incomeAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, checkingAccountEntity); var transactionEntities = new Entities.Transaction[] { new Entities.Transaction { CreditAccount = incomeAccountEntity, DebitAccount = checkingAccountEntity, Amount = 100m, At = new DateTime(2018, 1, 1, 8, 30, 0) }, new Entities.Transaction { CreditAccount = incomeAccountEntity, DebitAccount = checkingAccountEntity, Amount = 60m, At = new DateTime(2018, 1, 1, 8, 31, 0) } }; sqliteMemoryWrapper.DbContext.Transactions.AddRange(transactionEntities); sqliteMemoryWrapper.DbContext.SaveChanges(); var transactionService = new TransactionService(loggerFactory, sqliteMemoryWrapper.DbContext); transactionService.Delete(transactionEntities[0].TransactionId); List <Transaction> transactions = transactionService.GetAll().ToList(); Assert.AreEqual(1, transactions.Count); Assert.AreEqual(transactionEntities[1].TransactionId, transactions[0].TransactionId); Assert.AreEqual(transactionEntities[1].Amount, transactions[0].Amount); Assert.AreEqual(transactionEntities[1].At, transactions[0].At); Assert.AreEqual(transactionEntities[1].CreditAccountId, transactions[0].CreditAccount.AccountId); Assert.AreEqual(transactionEntities[1].DebitAccountId, transactions[0].DebitAccount.AccountId); } }
public LoginController() { try { var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; ViewBag.Version = string.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision); } catch { } _factory = new CurrencyFactory(); }
WeightedRandomBuffer <CurrencyData> populateGifts( string[] giftTypes, int[] giftAmounts, float[] giftChances, float discountPercent) { ParallelArray <string, int> giftData = new ParallelArray <string, int>(giftTypes, giftAmounts); CurrencyFactory giftFactory = new CurrencyFactory(); CurrencyData[] gifts = giftFactory.CreateGroup(giftData, discountPercent); return(new WeightedRandomBuffer <CurrencyData>(gifts, giftChances)); }
public CraftingSimulator( SimBaseItemInfo baseItemInfo, SimFinanceInfo financeInfo, SimCraftingInfo craftingInfo) { _affixFactory = new AffixFactory(); _itemFactory = new ItemFactory(_affixFactory); _fossilFactory = new FossilFactory(_affixFactory); _masterModFactory = new MasterModFactory(_affixFactory, _itemFactory); _essenceFactory = new EssenceFactory(_itemFactory, _affixFactory); var currencyFactory = new CurrencyFactory( new PoeRandom(), _essenceFactory, _fossilFactory, _masterModFactory); var clientToDomainMapper = new ClientToDomainMapper(_itemFactory, currencyFactory); var domainToClientMapper = new DomainToClientMapper(); _clientToDomain = clientToDomainMapper.GenerateMapper(); _domainToClient = domainToClientMapper.GenerateMapper(); _financeInfo = financeInfo; _craftingInfo = craftingInfo; _baseItemInfo = baseItemInfo; _baseItem = _itemFactory.Items.First(x => x.Name == _baseItemInfo.ItemName); var itemAffixes = _affixFactory.GetAffixesForItem( _baseItem.Tags, _baseItem.ItemClass, _baseItemInfo.ItemLevel); var fossilAffixes = _fossilFactory.Fossils .SelectMany(x => x.AddedAffixes) .ToList(); var essenceAffixes = _essenceFactory.GetAffixesByItemClass(_baseItem.ItemClass) .ToList(); var currencyAffixes = fossilAffixes.Union(essenceAffixes).ToList(); var influences = new List <Influence>((Influence[])Enum.GetValues(typeof(Influence))); var affixesByInfluence = _affixFactory.GetAffixesByInfluence(influences, _baseItem.ItemClass, _baseItemInfo.ItemLevel); var influenceSpawnTag = _affixFactory.GetInfluenceSpawnTags(_baseItem.ItemClass); _affixManager = new AffixManager(_baseItem, itemAffixes, currencyAffixes, affixesByInfluence, influenceSpawnTag); _currencyValues = _currencyValueFactory.GetCurrencyValues(financeInfo.League); }
public void TestBalanceSheetNoTransactions() { ILoggerFactory loggerFactory = new LoggerFactory(); using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { var currencyFactory = new CurrencyFactory(); var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true); currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity); var accountFactory = new AccountFactory(); Entities.Account incomeAccountEntity = accountFactory.Create(AccountPrefab.Income, usdCurrencyEntity); Entities.Account checkingAccountEntity = accountFactory.Create(AccountPrefab.Checking, usdCurrencyEntity); Entities.Account capitalAccountEntity = accountFactory.Create(AccountPrefab.Capital, usdCurrencyEntity); Entities.Account rentExpenseAccountEntity = accountFactory.Create(AccountPrefab.RentExpense, usdCurrencyEntity); Entities.Account creditCardAccountEntity = accountFactory.Create(AccountPrefab.CreditCard, usdCurrencyEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, incomeAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, checkingAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, capitalAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, rentExpenseAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, creditCardAccountEntity); var accountService = new AccountService( loggerFactory, sqliteMemoryWrapper.DbContext ); var currencyService = new CurrencyService( loggerFactory, sqliteMemoryWrapper.DbContext ); var balanceSheetService = new BalanceSheetService( loggerFactory, sqliteMemoryWrapper.DbContext ); BalanceSheet balanceSheet = balanceSheetService.Generate(new DateTime(2018, 1, 1)); List <BalanceSheetItem> balanceSheetAssets = balanceSheet.Assets.ToList(); List <BalanceSheetItem> balanceSheetLiabilities = balanceSheet.Liabilities.ToList(); Assert.AreEqual(usdCurrencyEntity.Symbol, balanceSheet.CurrencySymbol); Assert.AreEqual(0, balanceSheet.TotalAssets); Assert.AreEqual(0, balanceSheet.TotalLiabilities); Assert.AreEqual(0, balanceSheetAssets.Count); Assert.AreEqual(0, balanceSheetLiabilities.Count); } }
public void ClientToDomainMapperTest() { var currencyFactory = new CurrencyFactory( new PoeRandom(), _essenceFactory, _fossilFactory, _masterModFactory); var mapper = new ClientToDomainMapper(_itemFactory, currencyFactory); var config = mapper.GenerateMapper(); config.ConfigurationProvider.AssertConfigurationIsValid(); }
public void TestCreateAccountRelationshipsInDbContext() { using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { var currencyFactory = new CurrencyFactory(); Entities.Currency usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true); currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity); var accountFactory = new AccountFactory(); Entities.Account checkingAccountEntity = accountFactory.Create(AccountPrefab.Checking, usdCurrencyEntity); Entities.Account rentPrepaymentAccountEntity = accountFactory.Create(AccountPrefab.RentPrepayment, usdCurrencyEntity); Entities.Account rentExpenseAccountEntity = accountFactory.Create(AccountPrefab.RentExpense, usdCurrencyEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, checkingAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, rentPrepaymentAccountEntity); accountFactory.Add(sqliteMemoryWrapper.DbContext, rentExpenseAccountEntity); var checkingToRentPrepaymentRelationship = new AccountRelationship { SourceAccount = checkingAccountEntity, DestinationAccount = rentPrepaymentAccountEntity, Type = AccountRelationshipType.PhysicalToLogical }; var rentPrepaymentToExpenseRelationship = new AccountRelationship { SourceAccount = rentPrepaymentAccountEntity, DestinationAccount = rentExpenseAccountEntity, Type = AccountRelationshipType.PrepaymentToExpense }; sqliteMemoryWrapper.DbContext.AccountRelationships.Add(checkingToRentPrepaymentRelationship); sqliteMemoryWrapper.DbContext.AccountRelationships.Add(rentPrepaymentToExpenseRelationship); sqliteMemoryWrapper.DbContext.SaveChanges(); List <Account> accounts = sqliteMemoryWrapper.DbContext.Accounts.ToList(); List <AccountRelationship> accountRelationsips = sqliteMemoryWrapper.DbContext.AccountRelationships.ToList(); List <Currency> currencies = sqliteMemoryWrapper.DbContext.Currencies.ToList(); List <Transaction> transactions = sqliteMemoryWrapper.DbContext.Transactions.ToList(); Assert.AreEqual(3, accounts.Count); Assert.AreEqual(2, accountRelationsips.Count); Assert.AreEqual(1, currencies.Count); Assert.AreEqual(0, transactions.Count); Assert.AreEqual(checkingToRentPrepaymentRelationship.SourceAccount.Name, accountRelationsips[0].SourceAccount.Name); Assert.AreEqual(checkingToRentPrepaymentRelationship.DestinationAccount.Name, accountRelationsips[0].DestinationAccount.Name); Assert.AreEqual(rentPrepaymentToExpenseRelationship.SourceAccount.Name, accountRelationsips[1].SourceAccount.Name); Assert.AreEqual(rentPrepaymentToExpenseRelationship.DestinationAccount.Name, accountRelationsips[1].DestinationAccount.Name); } }
public async Task <IActionResult> Create([Bind(properties)] CurrencyView c) { await validateId(c.IsoCode, ModelState); if (!ModelState.IsValid) { return(View(c)); } var o = CurrencyFactory.Create(c.IsoCode, c.Name, c.Symbol, c.ValidFrom, c.ValidTo); await reporitory.AddObject(o); return(RedirectToAction("Index")); }
private void MatchValues(CurrencyFactory pFactory, string[] pValues, string[] pPrefixes, bool pMatch) { foreach (string value in pValues) { MatchParagraphs<string>(pFactory, string.Format("${0}", value), value, pMatch); MatchParagraphs<string>(pFactory, string.Format("$ {0}", value), value, pMatch); MatchParagraphs<string>(pFactory, string.Format("{0}", value), value, pMatch); foreach (string prefix in pPrefixes) { foreach (string token in new string[] { ":", "#", ">", "-" }) { MatchParagraphs<string>(pFactory, string.Format("{0}{1} ${2}", prefix, token, value), value, pMatch); MatchParagraphs<string>(pFactory, string.Format("{0}{1} {2}", prefix, token, value), value, pMatch); MatchParagraphs<string>(pFactory, string.Format("{0}{1} ${2}", prefix, token, value), value, pMatch); MatchParagraphs<string>(pFactory, string.Format("{0}{1} {2}", prefix, token, value), value, pMatch); } MatchParagraphs<string>(pFactory, string.Format("{0} ${1}", prefix, value), value, pMatch); MatchParagraphs<string>(pFactory, string.Format("{0} {1}", prefix, value), value, pMatch); MatchParagraphs<string>(pFactory, string.Format("{0} ${1}", prefix, value), value, pMatch); MatchParagraphs<string>(pFactory, string.Format("{0} {1}", prefix, value), value, pMatch); } } }
public void The_Big_Test() { CurrencyFactory factory = new CurrencyFactory("Amount", CurrencyFactory.Totals, false); MatchValues(factory, GoodAmounts, CurrencyFactory.Totals, true); MatchValues(factory, BadAmounts, CurrencyFactory.Totals, false); factory = new CurrencyFactory("Tax", CurrencyFactory.Taxes, false); MatchValues(factory, GoodAmounts, CurrencyFactory.Taxes, true); MatchValues(factory, BadAmounts, CurrencyFactory.Taxes, false); }