コード例 #1
0
 /// <summary>
 ///     Creates an MainViewModel object.
 /// </summary>
 public MainViewModel(ModifyAccountViewModel modifyAccountViewModel,
     ModifyTransactionViewModel modifyTransactionViewModel,
     IBalanceViewModel balanceViewModel)
 {
     this.modifyAccountViewModel = modifyAccountViewModel;
     this.modifyTransactionViewModel = modifyTransactionViewModel;
     this.balanceViewModel = balanceViewModel;
 }
コード例 #2
0
 public AccountListViewModel(IRepository<Account> accountRepository,
     TransactionListViewModel transactionListViewModel,
     BalanceViewModel balanceViewModel, ModifyAccountViewModel modifyAccountViewModel,
     IDialogService dialogService)
 {
     this.accountRepository = accountRepository;
     this.transactionListViewModel = transactionListViewModel;
     this.balanceViewModel = balanceViewModel;
     this.modifyAccountViewModel = modifyAccountViewModel;
     this.dialogService = dialogService;
 }
コード例 #3
0
        public void Title_AddAccount_CorrectTitle()
        {
            var accountname = "Sparkonto";

            var accountRepositorySetup = new Mock<IAccountRepository>();
            accountRepositorySetup.SetupGet(x => x.Selected).Returns(new Account {Id = 2, Name = accountname});

            var viewmodel = new ModifyAccountViewModel(accountRepositorySetup.Object)
            {IsEdit = false};

            viewmodel.Title.ShouldBe(Strings.AddAccountTitle);
        }
コード例 #4
0
        public void Title_EditAccount_CorrectTitle()
        {
            var accountname = "Sparkonto";

            var accountRepositorySetup = new Mock<IAccountRepository>();
            accountRepositorySetup.SetupGet(x => x.Selected).Returns(new Account {Id = 2, Name = accountname});

            var viewmodel = new ModifyAccountViewModel(accountRepositorySetup.Object, new BalanceViewModel(
                accountRepositorySetup.Object, new Mock<ITransactionRepository>().Object))
            {IsEdit = true};

            viewmodel.Title.ShouldBe(Strings.EditLabel + " " + accountname);
        }
コード例 #5
0
        public void Title_AddAccount_CorrectTitle()
        {
            Strings.Culture = new CultureInfo("en-US");
            var accountname = "Sparkonto";

            var accountRepositorySetup = new Mock<IRepository<Account>>();
            accountRepositorySetup.SetupGet(x => x.Selected).Returns(new Account {Id = 2, Name = accountname});

            var viewmodel = new ModifyAccountViewModel(accountRepositorySetup.Object, new BalanceViewModel(
                accountRepositorySetup.Object, new Mock<ITransactionRepository>().Object))
            {IsEdit = false};

            viewmodel.Title.ShouldBe(Strings.AddAccountTitle);
        }
コード例 #6
0
        public void GoToAddTransaction_Transactiontype_CorrectPreparation(string typestring, TransactionType type)
        {
            Setup();
            // for navigation parsing
            Ioc.RegisterSingleton<IMvxStringToTypeParser>(new MvxStringToTypeParser());

            var dbHelper = new Mock<ISqliteConnectionCreator>().Object;
            var accountRepository = new AccountRepository(new AccountDataAccess(dbHelper));
            var transactionRepository = new TransactionRepository(new TransactionDataAccess(dbHelper),
                new RecurringTransactionDataAccess(dbHelper));
            var transactionManager = new TransactionManager(transactionRepository, accountRepository,
                new Mock<IDialogService>().Object);

            var defaultManager = new DefaultManager(accountRepository,
                new SettingDataAccess(new Mock<IRoamingSettings>().Object));

            var modifyTransactionViewModel =
                new ModifyTransactionViewModel(transactionRepository,
                    accountRepository,
                    new Mock<IDialogService>().Object,
                    transactionManager,
                    defaultManager);

            var modifyAccountViewModel = new ModifyAccountViewModel(accountRepository,
                new BalanceViewModel(accountRepository, new Mock<ITransactionRepository>().Object));

            var mainViewModel = new MainViewModel(modifyAccountViewModel, modifyTransactionViewModel,
                new BalanceViewModel(accountRepository, transactionRepository));

            mainViewModel.GoToAddTransactionCommand.Execute(typestring);

            Assert.False(modifyTransactionViewModel.IsEdit);
            Assert.True(modifyTransactionViewModel.IsEndless);
            if (type == TransactionType.Transfer)
            {
                Assert.True(modifyTransactionViewModel.IsTransfer);
            }
            else
            {
                Assert.False(modifyTransactionViewModel.IsTransfer);
            }
            Assert.Equal((int) type, modifyTransactionViewModel.SelectedTransaction.Type);
        }
コード例 #7
0
        public void GoToAddPayment_PaymentType_CorrectPreparation(string typestring, PaymentType type)
        {
            Setup();
            // for navigation parsing
            Ioc.RegisterSingleton<IMvxStringToTypeParser>(new MvxStringToTypeParser());

            var dbHelper = new Mock<ISqliteConnectionCreator>().Object;
            var accountRepository = new AccountRepository(new AccountDataAccess(dbHelper));
            var paymentRepository = new PaymentRepository(new PaymentDataAccess(dbHelper),
                new RecurringPaymentDataAccess(dbHelper),
                accountRepository,
                new CategoryRepository(new CategoryDataAccess(dbHelper)));
            var paymentManager = new PaymentManager(paymentRepository, accountRepository,
                new Mock<IDialogService>().Object);

            var defaultManager = new DefaultManager(accountRepository,
                new SettingDataAccess(new Mock<IRoamingSettings>().Object));

            var modifyPaymentViewModel =
                new ModifyPaymentViewModel(paymentRepository,
                    accountRepository,
                    new Mock<IDialogService>().Object,
                    paymentManager,
                    defaultManager);

            var modifyAccountViewModel = new ModifyAccountViewModel(accountRepository);

            var mainViewModel = new MainViewModel(modifyAccountViewModel);

            mainViewModel.GoToAddPaymentCommand.Execute(typestring);

            Assert.False(modifyPaymentViewModel.IsEdit);
            Assert.True(modifyPaymentViewModel.IsEndless);
            if (type == PaymentType.Transfer)
            {
                Assert.True(modifyPaymentViewModel.IsTransfer);
            }
            else
            {
                Assert.False(modifyPaymentViewModel.IsTransfer);
            }
            Assert.Equal((int) type, modifyPaymentViewModel.SelectedPayment.Type);
        }
コード例 #8
0
        public void Title_EditAccount_CorrectTitle()
        {
            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
            Strings.Culture = new CultureInfo("en-US");

            var accountname = "Sparkonto";

            var accountRepositorySetup = new Mock<IRepository<Account>>();
            accountRepositorySetup.SetupGet(x => x.Selected).Returns(new Account {Id = 2, Name = accountname});

            var viewmodel = new ModifyAccountViewModel(accountRepositorySetup.Object, new BalanceViewModel(
                accountRepositorySetup.Object, new Mock<ITransactionRepository>().Object)) {IsEdit = true};

            viewmodel.Title.ShouldBe("Edit " + accountname);

            // Reset culture to current culture
            Strings.Culture = CultureInfo.CurrentCulture;
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CurrentCulture;
        }
コード例 #9
0
 /// <summary>
 ///     Creates an MainViewModel object.
 /// </summary>
 public MainViewModel(ModifyAccountViewModel modifyAccountViewModel)
 {
     this.modifyAccountViewModel = modifyAccountViewModel;
 }
コード例 #10
0
ファイル: MainViewModel.cs プロジェクト: M-Zuber/MoneyManager
 /// <summary>
 ///     Creates an MainViewModel object.
 /// </summary>
 public MainViewModel(ModifyAccountViewModel modifyAccountViewModel,
     ModifyTransactionViewModel modifyTransactionViewModel)
 {
     this.modifyAccountViewModel = modifyAccountViewModel;
     this.modifyTransactionViewModel = modifyTransactionViewModel;
 }