Exemplo n.º 1
0
        public void UpdateAccountTest()
        {
            var storage = new MemoryAccountStorage(new RegularAccountFactory());
            var account = storage.CreateAccount("New Account", "Old description", "UAH");

            var viewModel = new EditAccountViewModel(storage, account);

            viewModel.Name        = TestAccount;
            viewModel.Description = Description;
            viewModel.Currency    = Usd;

            viewModel.UpdateAccount();
            var newAccount = storage.GetAllAccounts().FirstOrDefault();

            Assert.IsNotNull(newAccount);
            Assert.AreEqual(account.Id, newAccount.Id);
            Assert.AreEqual(TestAccount, newAccount.Name);
            Assert.AreEqual(Description, newAccount.Description);
            Assert.AreEqual(Usd, newAccount.Currency);
        }
Exemplo n.º 2
0
 public EditAccount(IAccount account = null)
 {
     this.InitializeComponent();
     if (account == null)
     {
         ViewModel          = new EditAccountViewModel(MainPage.GlobalSettings.Storages.AccountStorage);
         _saveAccountAction = delegate { ViewModel.CreateNewAccount(); };
         Title               = "Create Account";
         PrimaryButtonText   = "Create Account";
         SecondaryButtonText = "Cancel";
     }
     else
     {
         ViewModel          = new EditAccountViewModel(MainPage.GlobalSettings.Storages.AccountStorage, account);
         _saveAccountAction = delegate { ViewModel.UpdateAccount(); };
         Title               = "Edit Account";
         PrimaryButtonText   = "Save";
         SecondaryButtonText = "Cancel";
     }
 }