public void TestInsertAndGet()
        {
            CrudProxy proxy = new BankAccountProxy();
            BankAccountDto dto1 = this.GetBankAccount();
            proxy.Insert(dto1);

            Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save.");

            BankAccountDto dto2 = (BankAccountDto) proxy.GetByUid(dto1.Uid);

            AssertEqual(dto1, dto2);
        }
        public void TestInsertAndNullMechantFeeId()
        {
            CrudProxy proxy = new BankAccountProxy();
            BankAccountDto dto1 = this.GetBankAccount();
            dto1.MerchantFeeAccountUid = null;

            proxy.Insert(dto1);

            Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save.");

            BankAccountDto dto2 = (BankAccountDto)proxy.GetByUid(dto1.Uid);

            Assert.AreEqual(dto1.MerchantFeeAccountUid, dto2.MerchantFeeAccountUid);
        }
        public void TestInsertInvalidMerchantFee()
        {
            CrudProxy proxy = new BankAccountProxy();
            BankAccountDto dto1 = this.GetBankAccount();
            dto1.MerchantFeeAccountUid = 99999;

            try
            {
                proxy.Insert(dto1);
                Assert.Fail("No exception thrown.");
            }
            catch(RestException rx)
            {
                Assert.AreEqual("The specified merchant fee account does not exist.", rx.Message, "Incorrect message.");
            }
        }
        public void TestDelete()
        {
            CrudProxy proxy = new BankAccountProxy();

            BankAccountDto dto1 = this.GetBankAccount();
            proxy.Insert(dto1);

            proxy.DeleteByUid(dto1.Uid);

            try
            {
                proxy.GetByUid(dto1.Uid);
                throw new Exception("The expected exception was not thrown.");
            }
            catch(RestException ex)
            {
                Assert.AreEqual("RecordNotFoundException", ex.Type, "Incorrect exception type.");
            }
        }
        private void SetupBankAccounts()
        {
            var proxySettings = (NameValueCollection)ConfigurationManager.GetSection("ola.restclient/proxySettings");

            CrudProxy bankAccount = new BankAccountProxy();

            this.Westpac = new BankAccountDto();
            this.Westpac.Type = AccountType.Asset;
            this.Westpac.Name = "Westpac " + System.Guid.NewGuid().ToString();
            this.Westpac.DisplayName = this.Westpac.Name;
            this.Westpac.BSB = "111-111";
            this.Westpac.AccountNumber = "12345-6789";
            this.Westpac.MerchantFeeAccountUid = int.Parse(proxySettings["MerchantFeeAccountUid"]);
            bankAccount.Insert(this.Westpac);

            this.StGeorge = new BankAccountDto();
            this.StGeorge.Type = AccountType.Asset;
            this.StGeorge.Name = "St. George " + System.Guid.NewGuid().ToString();
            this.StGeorge.DisplayName = this.StGeorge.Name;
            this.StGeorge.BSB = "222-222";
            this.StGeorge.AccountNumber = "9897-3698";
            bankAccount.Insert(this.StGeorge);
        }
        public void TestUpdate()
        {
            CrudProxy proxy = new BankAccountProxy();
            BankAccountDto dto1 = this.GetBankAccount();
            proxy.Insert(dto1);

            string lastUpdatedUid = dto1.LastUpdatedUid;

            dto1.Type = AccountType.Liability;

            proxy.Update(dto1);

            Assert.IsTrue(dto1.LastUpdatedUid != lastUpdatedUid);

            BankAccountDto dto2 = (BankAccountDto) proxy.GetByUid(dto1.Uid);

            AssertEqual(dto1, dto2);
        }