Beispiel #1
0
        public void TestUnlinkAccount()
        {
            // Mocked FI User
            var mockFiUser = new Mock<FinancialInstitutionUser>();
            mockFiUser.SetupAllProperties();

            // Account for test
            var account = new Account
            {
                AccountName = "Test Account",
                AccountType = AccountType.Checking.ToString(),
                Currency = "USD",
                FinancialInstitutionUser = mockFiUser.Object
            };

            // Mock setup for DataService
            var data = new List<Account> { account };
            var dataMock = new Mock<IList<Account>>();
            dataMock.As<IQueryable<Account>>().Setup(m => m.Provider).Returns(data.AsQueryable().Provider);
            dataMock.As<IQueryable<Account>>().Setup(m => m.Expression).Returns(data.AsQueryable().Expression);
            dataMock.As<IQueryable<Account>>().Setup(m => m.ElementType).Returns(data.AsQueryable().ElementType);
            dataMock.As<IQueryable<Account>>().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            var mockContext = new Mock<SoCashDbContext>();
            mockFiUser.Setup(m => m.Accounts).Returns(dataMock.Object);

            // Unlink the account
            using (var service = new DataService(mockContext.Object))
                service.UnlinkAccount(account);

            // Verify that the service attached the account on the mock db exactly once
            mockContext.Verify(m => m.SetModified(account), Times.Once());

            // Verify that the account has the FiUser removed
            dataMock.Verify(m => m.Remove(account), Times.Once());

            // Verify that the transaction ended properly
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
Beispiel #2
0
        /// <summary>
        /// Unlink the selected automatic update account, turning it into a manual update account
        /// </summary>
        public void UnlinkSelectedAccount()
        {
            using (var dataService = new DataService())
            {
                // Unlink from fiUser
                dataService.UnlinkAccount(SelectedAccount);
            }

            // Manual and automatic account properties changed 
            RaisePropertyChanged(() => IsAutomaticAccount);
            RaisePropertyChanged(() => IsManualAccount);
        }