Example #1
0
        private static void SetupBankAccounts()
        {
            CrudProxy bankAccount = new BankAccountProxy();

            var bankAccountDto = new Ola.RestClient.Dto.BankAccountDto()
            {
                Type          = AccountType.Asset,
                Name          = "TestBank " + System.Guid.NewGuid().ToString(),
                DisplayName   = "TestBank " + System.Guid.NewGuid().ToString(),
                BSB           = "111-111",
                AccountNumber = "12345-6789"
            };

            bankAccount.Insert(bankAccountDto);
            _bankAccount01Id = bankAccountDto.Uid;

            bankAccountDto = new Ola.RestClient.Dto.BankAccountDto()
            {
                Type          = AccountType.Asset,
                Name          = "TestBank " + System.Guid.NewGuid().ToString(),
                DisplayName   = "TestBank " + System.Guid.NewGuid().ToString(),
                BSB           = "222-222",
                AccountNumber = "2345-6789"
            };
            bankAccount.Insert(bankAccountDto);
            _bankAccount02Id = bankAccountDto.Uid;
        }
        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);
        }
        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 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 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);
        }
        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.");
            }
        }