public void SaveWithdrawAddressesAndRetreiveByAccountIdTest_SavesMultipleObjectsToDatabase_ChecksIfRetreivedOutputIsAsExpected()
        {
            WithdrawAddress withdrawAddress = new WithdrawAddress(new Currency("XBT", true), new BitcoinAddress("iambitcoin123"), "Description is for dummies",
                                                                  new AccountId(1), DateTime.Now);

            _persistanceRepository.SaveOrUpdate(withdrawAddress);

            WithdrawAddress deposit2 = new WithdrawAddress(new Currency("XBT", true), new BitcoinAddress("321nioctibmai"), "Description is for champs",
                                                           new AccountId(1), DateTime.Now);

            Thread.Sleep(500);

            _persistanceRepository.SaveOrUpdate(deposit2);

            List <WithdrawAddress> retrievedWithdrawAddressList = _withdrawAddressRepository.GetWithdrawAddressByAccountId(new AccountId(1));

            Assert.IsNotNull(retrievedWithdrawAddressList);
            Assert.AreEqual(2, retrievedWithdrawAddressList.Count);

            Assert.AreEqual(withdrawAddress.BitcoinAddress.Value, retrievedWithdrawAddressList[0].BitcoinAddress.Value);
            Assert.AreEqual(withdrawAddress.Description, retrievedWithdrawAddressList[0].Description);
            Assert.AreEqual(withdrawAddress.AccountId.Value, retrievedWithdrawAddressList[0].AccountId.Value);

            Assert.AreEqual(deposit2.BitcoinAddress.Value, retrievedWithdrawAddressList[1].BitcoinAddress.Value);
            Assert.AreEqual(deposit2.Description, retrievedWithdrawAddressList[1].Description);
            Assert.AreEqual(deposit2.AccountId.Value, retrievedWithdrawAddressList[1].AccountId.Value);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deletes the given address from the database
        /// </summary>
        /// <param name="deleteWithdrawAddressCommand"></param>
        /// <returns></returns>
        public DeleteWithdrawAddressResponse DeleteAddress(DeleteWithdrawAddressCommand deleteWithdrawAddressCommand)
        {
            List <WithdrawAddress> withdrawAddresses = _withdrawAddressRepository.GetWithdrawAddressByAccountId(new AccountId(deleteWithdrawAddressCommand.AccountId));

            foreach (var withdrawAddress in withdrawAddresses)
            {
                if (withdrawAddress.BitcoinAddress.Value == deleteWithdrawAddressCommand.BitcoinAddress)
                {
                    _fundsPersistenceRepository.Delete(withdrawAddress);
                    return(new DeleteWithdrawAddressResponse(true, "Deletion successful"));
                }
            }
            return(new DeleteWithdrawAddressResponse(false, "Address not found"));
        }