public void TransactionRepository_Update()
        {
            var dbHelper = new DbHelper(new SQLitePlatformWinRT(), new TestDatabasePath());

            using (var db = dbHelper.GetSqlConnection())
            {
                db.DeleteAll<FinancialTransaction>();
            }

            var repository = new TransactionRepository(new TransactionDataAccess(dbHelper));
            var account = new Account
            {
                Name = "TestAccount"
            };

            var transaction = new FinancialTransaction
            {
                ChargedAccount = account,
                Amount = 20,
                AmountWithoutExchange = 20
            };

            repository.Save(transaction);
            Assert.AreEqual(1, repository.Data.Count);
            Assert.AreSame(transaction, repository.Data[0]);

            transaction.Amount = 30;

            repository.Save(transaction);

            Assert.AreEqual(1, repository.Data.Count);
            Assert.AreEqual(30, repository.Data[0].Amount);
        }
        public void TransactionRepository_Update()
        {
            var dbHelper = new SqliteConnectionCreator(new WindowsSqliteConnectionFactory());

            using (var db = dbHelper.GetConnection())
            {
                db.DeleteAll<FinancialTransaction>();
            }

            var repository = new TransactionRepository(new TransactionDataAccess(dbHelper),
                new RecurringTransactionDataAccess(dbHelper));
            var account = new Account
            {
                Name = "TestAccount"
            };

            var transaction = new FinancialTransaction
            {
                ChargedAccount = account,
                Amount = 20
            };

            repository.Save(transaction);
            repository.Data.Count.ShouldBe(1);
            repository.Data[0].ShouldBeSameAs(transaction);

            transaction.Amount = 30;

            repository.Save(transaction);

            repository.Data.Count.ShouldBe(1);
            repository.Data[0].Amount.ShouldBe(30);
        }
        public void Save_DifferentTransactionTypes_CorrectlySaved(TransactionType type)
        {
            var transactionDataAccessMock = new TransactionDataAccessMock();
            var repository = new TransactionRepository(transactionDataAccessMock,
                new RecurringTransactionDataAccessMock());

            var account = new Account
            {
                Name = "TestAccount"
            };

            var transaction = new FinancialTransaction
            {
                ChargedAccount = account,
                TargetAccount = null,
                Amount = 20,
                Type = (int) type
            };

            repository.Save(transaction);

            transactionDataAccessMock.FinancialTransactionTestList[0].ShouldBeSameAs(transaction);
            transactionDataAccessMock.FinancialTransactionTestList[0].ChargedAccount.ShouldBeSameAs(account);
            transactionDataAccessMock.FinancialTransactionTestList[0].TargetAccount.ShouldBeNull();
            transactionDataAccessMock.FinancialTransactionTestList[0].Type.ShouldBe((int) type);
        }
        public void TransactionRepository_Delete()
        {
            var transactionDataAccessMock = new TransactionDataAccessMock();
            var repository = new TransactionRepository(transactionDataAccessMock);

            var account = new Account
            {
                Name = "TestAccount"
            };

            var transaction = new FinancialTransaction
            {
                ChargedAccount = account,
                Amount = 20,
                AmountWithoutExchange = 20
            };

            repository.Save(transaction);
            Assert.AreSame(transaction, transactionDataAccessMock.FinancialTransactionTestList[0]);

            repository.Delete(transaction);

            Assert.IsFalse(transactionDataAccessMock.FinancialTransactionTestList.Any());
            Assert.IsFalse(repository.Data.Any());
        }
        public void TransactionRepository_AddMultipleToCache()
        {
            var repository = new TransactionRepository(new TransactionDataAccessMock());

            var account = new Account
            {
                Name = "TestAccount"
            };

            var transaction = new FinancialTransaction
            {
                ChargedAccount = account,
                Amount = 20,
                AmountWithoutExchange = 20
            };

            var secondTransaction = new FinancialTransaction
            {
                ChargedAccount = account,
                Amount = 60,
                AmountWithoutExchange = 60
            };

            repository.Save(transaction);
            repository.Save(secondTransaction);

            Assert.AreEqual(2, repository.Data.Count);
            Assert.AreSame(transaction, repository.Data[0]);
            Assert.AreSame(secondTransaction, repository.Data[1]);
        }
        public void Save_TransferTransaction_CorrectlySaved()
        {
            var accountRepoSetup = new Mock<IDataAccess<Account>>();
            accountRepoSetup.Setup(x => x.LoadList(null)).Returns(new List<Account>());

            var transactionDataAccessMock = new TransactionDataAccessMock();
            var repository = new TransactionRepository(transactionDataAccessMock,
                new RecurringTransactionDataAccessMock());

            var account = new Account
            {
                Name = "TestAccount"
            };

            var targetAccount = new Account
            {
                Name = "targetAccount"
            };

            var transaction = new FinancialTransaction
            {
                ChargedAccount = account,
                TargetAccount = targetAccount,
                Amount = 20,
                Type = (int) TransactionType.Transfer
            };

            repository.Save(transaction);

            transactionDataAccessMock.FinancialTransactionTestList[0].ShouldBeSameAs(transaction);
            transactionDataAccessMock.FinancialTransactionTestList[0].ChargedAccount.ShouldBeSameAs(account);
            transactionDataAccessMock.FinancialTransactionTestList[0].TargetAccount.ShouldBeSameAs(targetAccount);
            transactionDataAccessMock.FinancialTransactionTestList[0].Type.ShouldBe((int) TransactionType.Transfer);
        }
        public void SaveWithouthAccount_NoAccount_InvalidDataException()
        {
            var repository = new TransactionRepository(new TransactionDataAccessMock(),
                new RecurringTransactionDataAccessMock());

            var transaction = new FinancialTransaction
            {
                Amount = 20
            };

            Assert.Throws<InvalidDataException>(() => repository.Save(transaction));
        }
        public void SaveWithouthAccount_NoAccount_InvalidDataException()
        {
            var accountRepoSetup = new Mock<IDataAccess<Account>>();
            accountRepoSetup.Setup(x => x.LoadList(null)).Returns(new List<Account>());

            var repository = new TransactionRepository(new TransactionDataAccessMock(),
                new RecurringTransactionDataAccessMock());

            var transaction = new FinancialTransaction
            {
                Amount = 20
            };

            Assert.Throws<AccountMissingException>(() => repository.Save(transaction));
        }
        public void AddTransactionViewModel_ReturnAddTransferTitle()
        {
            var dbHelper = new DbHelperStub();

            var transactionRepository = new TransactionRepository(new TransactionDataAccess(dbHelper))
            {
                Selected = new FinancialTransaction { Type = (int)TransactionType.Transfer }
            };

            var viewModel = new AddTransactionViewModel(transactionRepository,
                new AccountRepository(new AccountDataAccess(dbHelper)),
                new SettingDataAccess(),
                new NavigationServiceStub(),
                new DialogServiceStub())
            { IsEdit = false};

            Assert.AreEqual("add transfer", viewModel.Title);
        }
Esempio n. 10
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);
        }
        public void TransactionRepository_AddItemToDataList()
        {
            var repository = new TransactionRepository(new TransactionDataAccessMock());

            var account = new Account
            {
                Name = "TestAccount"
            };

            var transaction = new FinancialTransaction
            {
                ChargedAccount = account,
                Amount = 20,
                AmountWithoutExchange = 20,
                Type = (int) TransactionType.Transfer
            };

            repository.Save(transaction);
            Assert.IsTrue(repository.Data.Contains(transaction));
        }
        public void Title_TransactionTypeDifferentModes_CorrectTitle(TransactionType type, bool isEditMode,
            string result, string culture)
        {
            //Setup
            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(culture);
            Strings.Culture = new CultureInfo(culture);

            var dbHelper = new Mock<ISqliteConnectionCreator>().Object;
            var transactionRepository = new TransactionRepository(new TransactionDataAccess(dbHelper),
                new RecurringTransactionDataAccess(dbHelper))
            {
                Selected = new FinancialTransaction {Type = (int) type}
            };

            var transactionManager = new TransactionManager(transactionRepository,
                new Mock<IRepository<Account>>().Object,
                new Mock<IDialogService>().Object);

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

            var viewModel = new ModifyTransactionViewModel(transactionRepository,
                new AccountRepository(new AccountDataAccess(dbHelper)),
                new Mock<IDialogService>().Object,
                transactionManager,
                defaultManager)
            {
                IsEdit = isEditMode,
                IsTransfer = true
            };

            //Execute and assert
            viewModel.Title.ShouldBe(result);

            // Reset culture to current culture
            Strings.Culture = CultureInfo.CurrentCulture;
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CurrentCulture;
        }
        public void TransactionRepository_LoadDataFromDbThroughRepository()
        {
            var dbHelper = new SqliteConnectionCreator(new WindowsSqliteConnectionFactory());

            using (var db = dbHelper.GetConnection())
            {
                db.DeleteAll<FinancialTransaction>();
                db.InsertWithChildren(new FinancialTransaction
                {
                    Amount = 999,
                    ChargedAccount = new Account
                    {
                        Name = "testAccount"
                    }
                });
            }

            var repository = new TransactionRepository(new TransactionDataAccess(dbHelper),
                new RecurringTransactionDataAccess(dbHelper));

            repository.Data.Any().ShouldBeTrue();
            repository.Data[0].Amount.ShouldBe(999);
        }
        public void TransactionRepository_LoadDataFromDbThroughRepository()
        {
            var dbHelper = new DbHelper(new SQLitePlatformWinRT(), new TestDatabasePath());

            using (var db = dbHelper.GetSqlConnection())
            {
                db.DeleteAll<FinancialTransaction>();
                db.InsertWithChildren(new FinancialTransaction
                {
                    Amount = 999,
                    AmountWithoutExchange = 777,
                    ChargedAccount = new Account
                    {
                        Name = "testAccount"
                    }
                });
            }

            var repository = new TransactionRepository(new TransactionDataAccess(dbHelper));

            Assert.IsTrue(repository.Data.Any());
            Assert.AreEqual(999, repository.Data[0].Amount);
            Assert.AreEqual(777, repository.Data[0].AmountWithoutExchange);
        }
        public void Load_FinancialTransaction_DataInitialized()
        {
            var accountRepoSetup = new Mock<IDataAccess<Account>>();
            accountRepoSetup.Setup(x => x.LoadList(null)).Returns(new List<Account>());

            var dataAccessSetup = new Mock<IDataAccess<FinancialTransaction>>();
            dataAccessSetup.Setup(x => x.LoadList(null)).Returns(new List<FinancialTransaction>
            {
                new FinancialTransaction {Id = 10},
                new FinancialTransaction {Id = 15}
            });

            var categoryRepository = new TransactionRepository(dataAccessSetup.Object,
                new Mock<IDataAccess<RecurringTransaction>>().Object);
            categoryRepository.Load();

            categoryRepository.Data.Any(x => x.Id == 10).ShouldBeTrue();
            categoryRepository.Data.Any(x => x.Id == 15).ShouldBeTrue();
        }
        public void GetUnclearedTransactions_AccountNull()
        {
            var accountRepoSetup = new Mock<IDataAccess<Account>>();
            accountRepoSetup.Setup(x => x.LoadList(null)).Returns(new List<Account>());

            var repository = new TransactionRepository(new TransactionDataAccessMock(),
                new RecurringTransactionDataAccessMock());

            repository.Data.Add(new FinancialTransaction
            {
                Amount = 55,
                Date = DateTime.Today.AddDays(-1),
                Note = "this is a note!!!",
                IsCleared = false
            }
                );

            var transactions = repository.GetUnclearedTransactions();
            transactions.Count().ShouldBe(1);
        }
        public void GetUnclearedTransactions_FutureDate_PastTransactions()
        {
            var accountRepoSetup = new Mock<IDataAccess<Account>>();
            accountRepoSetup.Setup(x => x.LoadList(null)).Returns(new List<Account>());

            var repository = new TransactionRepository(new TransactionDataAccessMock(),
                new RecurringTransactionDataAccessMock());

            var account = new Account
            {
                Name = "TestAccount"
            };

            repository.Save(new FinancialTransaction
            {
                ChargedAccount = account,
                Amount = 55,
                Date = Utilities.GetEndOfMonth().AddDays(-1),
                Note = "this is a note!!!",
                IsCleared = false
            }
                );

            var transactions = repository.GetUnclearedTransactions();
            transactions.Count().ShouldBe(0);

            transactions = repository.GetUnclearedTransactions(Utilities.GetEndOfMonth());
            transactions.Count().ShouldBe(1);
        }
        public void GetUnclearedTransactions_PastDate_PastTransactions()
        {
            var accountRepoSetup = new Mock<IDataAccess<Account>>();
            accountRepoSetup.Setup(x => x.LoadList(null)).Returns(new List<Account>());

            var repository = new TransactionRepository(new TransactionDataAccessMock(),
                new RecurringTransactionDataAccessMock());

            var account = new Account
            {
                Name = "TestAccount"
            };

            repository.Data = new ObservableCollection<FinancialTransaction>(new List<FinancialTransaction>
            {
                new FinancialTransaction
                {
                    ChargedAccount = account,
                    Amount = 55,
                    Date = DateTime.Today.AddDays(-1),
                    Note = "this is a note!!!",
                    IsCleared = false
                }
            });

            var transactions = repository.GetUnclearedTransactions();

            transactions.Count().ShouldBe(1);
        }
        public void AddItemToDataList_SaveAccount_IsAddedToData()
        {
            var accountRepoSetup = new Mock<IDataAccess<Account>>();
            accountRepoSetup.Setup(x => x.LoadList(null)).Returns(new List<Account>());

            var repository = new TransactionRepository(new TransactionDataAccessMock(),
                new RecurringTransactionDataAccessMock());

            var account = new Account
            {
                Name = "TestAccount"
            };

            var transaction = new FinancialTransaction
            {
                ChargedAccount = account,
                Amount = 20,
                Type = (int) TransactionType.Transfer
            };

            repository.Save(transaction);
            repository.Data.Contains(transaction).ShouldBeTrue();
        }
        public void TransactionRepository_AddMultipleToCache()
        {
            var accountRepoSetup = new Mock<IDataAccess<Account>>();
            accountRepoSetup.Setup(x => x.LoadList(null)).Returns(new List<Account>());

            var repository = new TransactionRepository(new TransactionDataAccessMock(),
                new RecurringTransactionDataAccessMock());

            var account = new Account
            {
                Name = "TestAccount"
            };

            var transaction = new FinancialTransaction
            {
                ChargedAccount = account,
                Amount = 20
            };

            var secondTransaction = new FinancialTransaction
            {
                ChargedAccount = account,
                Amount = 60
            };

            repository.Save(transaction);
            repository.Save(secondTransaction);

            repository.Data.Count.ShouldBe(2);
            repository.Data[0].ShouldBeSameAs(transaction);
            repository.Data[1].ShouldBeSameAs(secondTransaction);
        }
        public void TransactionRepository_Delete()
        {
            var accountRepoSetup = new Mock<IDataAccess<Account>>();
            accountRepoSetup.Setup(x => x.LoadList(null)).Returns(new List<Account>());

            var transactionDataAccessMock = new TransactionDataAccessMock();
            var repository = new TransactionRepository(transactionDataAccessMock,
                new RecurringTransactionDataAccessMock());

            var account = new Account
            {
                Name = "TestAccount"
            };

            var transaction = new FinancialTransaction
            {
                ChargedAccount = account,
                Amount = 20
            };

            repository.Save(transaction);
            transactionDataAccessMock.FinancialTransactionTestList[0].ShouldBeSameAs(transaction);

            repository.Delete(transaction);

            transactionDataAccessMock.FinancialTransactionTestList.Any().ShouldBeFalse();
            repository.Data.Any().ShouldBeFalse();
        }
        public void TransactionRepository_Delete()
        {
            var transactionDataAccessMock = new TransactionDataAccessMock();
            var repository = new TransactionRepository(transactionDataAccessMock,
                new RecurringTransactionDataAccessMock());

            var account = new Account
            {
                Name = "TestAccount"
            };

            var transaction = new FinancialTransaction
            {
                ChargedAccount = account,
                Amount = 20
            };

            repository.Save(transaction);
            transactionDataAccessMock.FinancialTransactionTestList[0].ShouldBeSameAs(transaction);

            repository.Delete(transaction);

            transactionDataAccessMock.FinancialTransactionTestList.Any().ShouldBeFalse();
            repository.Data.Any().ShouldBeFalse();
        }
        public void AddTransactionViewModel_ReturnIncomeDefault()
        {
            var dbHelper = new DbHelperStub();

            var transactionRepository = new TransactionRepository(new TransactionDataAccess(dbHelper))
            {
                Selected = new FinancialTransaction { Type = (int)TransactionType.Income }
            };

            var viewModel = new AddTransactionViewModel(transactionRepository,
                new AccountRepository(new AccountDataAccess(dbHelper)),
                new SettingDataAccess(),
                new NavigationServiceStub(),
                new DialogServiceStub());
            Assert.AreEqual("add income", viewModel.Title);
        }
        public void LoadRecurringList_ListWithRecurringTransaction()
        {
            var dbHelper = new SqliteConnectionCreator(new WindowsSqliteConnectionFactory());

            var transactionDataAccess =
                new TransactionDataAccess(dbHelper);
            var recTransactionDataAccess =
                new RecurringTransactionDataAccess(dbHelper);
            var repository = new TransactionRepository(transactionDataAccess, recTransactionDataAccess);

            transactionDataAccess.SaveItem(new FinancialTransaction {Amount = 999, IsRecurring = false});
            transactionDataAccess.SaveItem(new FinancialTransaction
            {
                Amount = 123,
                IsRecurring = true,
                RecurringTransaction = new RecurringTransaction {IsEndless = true}
            });

            repository.Load();
            var result = repository.LoadRecurringList().ToList();

            result.Count.ShouldBe(1);

            result.First().Id.ShouldBe(2);
            result.First().RecurringTransaction.Id.ShouldBe(1);
        }
        public void GetRelatedTransactions_Account_CorrectAccounts()
        {
            var accountRepoSetup = new Mock<IDataAccess<Account>>();
            accountRepoSetup.Setup(x => x.LoadList(null)).Returns(new List<Account>());

            var dataAccessSetup = new Mock<IDataAccess<FinancialTransaction>>();
            dataAccessSetup.Setup(x => x.LoadList(null)).Returns(new List<FinancialTransaction>());

            var repo = new TransactionRepository(dataAccessSetup.Object,
                new Mock<IDataAccess<RecurringTransaction>>().Object);

            var account1 = new Account {Id = 1};
            var account3 = new Account {Id = 3};

            repo.Data = new ObservableCollection<FinancialTransaction>(new List<FinancialTransaction>
            {
                new FinancialTransaction {Id = 2, ChargedAccount = account1, ChargedAccountId = account1.Id},
                new FinancialTransaction {Id = 5, ChargedAccount = account3, ChargedAccountId = account3.Id}
            });

            var result = repo.GetRelatedTransactions(account1);

            result.Count().ShouldBe(1);
            result.First().Id.ShouldBe(2);
        }
        public void TransactionRepository_AddMultipleToCache()
        {
            var repository = new TransactionRepository(new TransactionDataAccessMock(),
                new RecurringTransactionDataAccessMock());

            var account = new Account
            {
                Name = "TestAccount"
            };

            var transaction = new FinancialTransaction
            {
                ChargedAccount = account,
                Amount = 20
            };

            var secondTransaction = new FinancialTransaction
            {
                ChargedAccount = account,
                Amount = 60
            };

            repository.Save(transaction);
            repository.Save(secondTransaction);

            repository.Data.Count.ShouldBe(2);
            repository.Data[0].ShouldBeSameAs(transaction);
            repository.Data[1].ShouldBeSameAs(secondTransaction);
        }
        public void LoadRecurringList_NoParameters_ListWithRecurringTrans()
        {
            var accountRepoSetup = new Mock<IDataAccess<Account>>();
            accountRepoSetup.Setup(x => x.LoadList(null)).Returns(new List<Account>());

            var dataAccessSetup = new Mock<IDataAccess<FinancialTransaction>>();
            dataAccessSetup.Setup(x => x.LoadList(null)).Returns(new List<FinancialTransaction>());

            var repo = new TransactionRepository(dataAccessSetup.Object,
                new Mock<IDataAccess<RecurringTransaction>>().Object)
            {
                Data = new ObservableCollection<FinancialTransaction>(new List<FinancialTransaction>
                {
                    new FinancialTransaction
                    {
                        Id = 1,
                        IsRecurring = true,
                        RecurringTransaction = new RecurringTransaction {Id = 1, IsEndless = true},
                        ReccuringTransactionId = 1
                    },
                    new FinancialTransaction {Id = 2, IsRecurring = false},
                    new FinancialTransaction
                    {
                        Id = 3,
                        IsRecurring = true,
                        RecurringTransaction =
                            new RecurringTransaction {Id = 2, IsEndless = false, EndDate = DateTime.Today.AddDays(10)},
                        ReccuringTransactionId = 2
                    },
                    new FinancialTransaction
                    {
                        Id = 4,
                        IsRecurring = true,
                        RecurringTransaction =
                            new RecurringTransaction {Id = 3, IsEndless = false, EndDate = DateTime.Today.AddDays(-10)},
                        ReccuringTransactionId = 3
                    }
                })
            };

            var result = repo.LoadRecurringList().ToList();

            result.Count.ShouldBe(2);
            result[0].Id.ShouldBe(1);
            result[1].Id.ShouldBe(3);
        }
        public void GetUnclearedTransactions_PastDate_PastTransactions()
        {
            var repository = new TransactionRepository(new TransactionDataAccessMock(),
                new RecurringTransactionDataAccessMock());

            var account = new Account
            {
                Name = "TestAccount"
            };

            repository.Save(new FinancialTransaction
            {
                ChargedAccount = account,
                Amount = 55,
                Date = DateTime.Today.AddDays(-1),
                Note = "this is a note!!!",
                IsCleared = false
            }
                );

            var transactions = repository.GetUnclearedTransactions();

            transactions.Count().ShouldBe(1);
        }
        public void GetUnclearedTransactions_AccountNull()
        {
            var repository = new TransactionRepository(new TransactionDataAccessMock(),
                new RecurringTransactionDataAccessMock());

            repository.Data.Add(new FinancialTransaction
            {
                Amount = 55,
                Date = DateTime.Today.AddDays(-1),
                Note = "this is a note!!!",
                IsCleared = false
            }
                );

            var transactions = repository.GetUnclearedTransactions();
            transactions.Count().ShouldBe(1);
        }
        public void TransactionRepository_SaveWithouthAccount()
        {
            try
            {
                var transactionDataAccessMock = new TransactionDataAccessMock();
                var repository = new TransactionRepository(transactionDataAccessMock);

                var transaction = new FinancialTransaction
                {
                    Amount = 20,
                    AmountWithoutExchange = 20
                };

                repository.Save(transaction);
            }
            catch (InvalidDataException)
            {
                return;
            }
            catch (Exception)
            {
                Assert.Fail("wrong exception.");
            }
            Assert.Fail("No excpetion thrown");
        }