示例#1
0
        public void TestDeleteAccount()
        {
            // Account for test
            var account = new Account
            {
                AccountName = "Test Account",
                AccountType = AccountType.Checking.ToString(),
                Currency = "USD"
            };

            // Mock setup for DataService
            var mockAccountSet = new Mock<DbSet<Account>>();
            var mockContext = new Mock<SoCashDbContext>();
            mockContext.Setup(m => m.Set<Account>()).Returns(mockAccountSet.Object);

            // Delete the account
            using (var service = new DataService(mockContext.Object))
                service.DeleteAccount(account);

            // Verify that the service removed the account on the mock db exactly once
            mockAccountSet.Verify(m => m.Remove(account), Times.Once());

            // Verify that the transaction ended properly
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
示例#2
0
        /// <summary>
        /// Deletes the selected account from the database
        /// </summary>
        public void DeleteSelectedAccount()
        {
            using (var dataService = new DataService())
            {
                // Delete the account
                dataService.DeleteAccount(SelectedAccount);
            }

            // Set to no account
            SelectedAccount = null;

            // Return to no tab selected
            SelectedTabSource = null;

            // Update the list of accounts
            UpdateAccounts();
        }