public void CreateCardAccountSuccessfully()
        {
            var content = File.ReadAllText("../../Fixtures/card_account_create.json");

            var client = GetMockClient(content);
            var repo = new CardAccountRepository(client.Object);

            const string userId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
            var account = new CardAccount
            {
                UserId = userId,
                Active = true,
                Card = new Card
                {
                    FullName = "Batman",
                    ExpiryMonth = "11",
                    ExpiryYear = "2020",
                    Number = "4111111111111111",
                    Type = "visa",
                    CVV = "123"
                }
            };
            var createdAccount = repo.CreateCardAccount(account);
            client.VerifyAll();
            Assert.IsNotNull(createdAccount);
            Assert.IsNotNull(createdAccount.Id);
            Assert.AreEqual("AUD", createdAccount.Currency); // It seems that currency is determined by country
            Assert.IsNotNull(createdAccount.CreatedAt);
            Assert.IsNotNull(createdAccount.UpdatedAt);
        }
 public void CreateCardAccountSuccessfully()
 {
     var repo = new CardAccountRepository();
     var userId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
     var account = new CardAccount
     {
         UserId = userId,
         Active = true,
         Card = new Card
         {
             FullName = "Batman",
             ExpiryMonth = "11",
             ExpiryYear = "2020",
             Number = "4111111111111111",
             Type = "visa",
             CVV = "123"
         }
     };
     var createdAccount = repo.CreateCardAccount(account);
     Assert.IsNotNull(createdAccount);
     Assert.IsNotNull(createdAccount.Id);
     Assert.AreEqual("AUD", createdAccount.Currency); // It seems that currency is determined by country
     Assert.IsNotNull(createdAccount.CreatedAt);
     Assert.IsNotNull(createdAccount.UpdatedAt);
 }
        public void DeleteCardAccountSuccessfully()
        {
            var repo = new CardAccountRepository();
            var userId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
            var account = new CardAccount
            {
                UserId = userId,
                Active = true,
                Card = new Card
                {
                    FullName = "Batman",
                    ExpiryMonth = "11",
                    ExpiryYear = "2020",
                    Number = "4111111111111111",
                    Type = "visa",
                    CVV = "123"
                }
            };
            var createdAccount = repo.CreateCardAccount(account);
            Assert.IsTrue(createdAccount.Active);
            var result = repo.DeleteCardAccount(createdAccount.Id);

            Assert.IsTrue(result);

            var gotAccount = repo.GetCardAccountById(createdAccount.Id);
            Assert.IsFalse(gotAccount.Active);
        }
        public CardAccount CreateCardAccount(CardAccount cardAccount)
        {
            var request = new RestRequest("/card_accounts", Method.POST);
            request.AddParameter("user_id", cardAccount.UserId);
            request.AddParameter("full_name", cardAccount.Card.FullName);
            request.AddParameter("number", cardAccount.Card.Number);
            request.AddParameter("expiry_month", cardAccount.Card.ExpiryMonth);
            request.AddParameter("expiry_year", cardAccount.Card.ExpiryYear);
            request.AddParameter("cvv", cardAccount.Card.CVV);

            var response = SendRequest(Client, request);
            return JsonConvert.DeserializeObject<IDictionary<string, CardAccount>>(response.Content).Values.First();
        }
        public void GetUserForCardAccountSuccessfully()
        {
            var repo = new CardAccountRepository();
            var userId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
            var account = new CardAccount
            {
                UserId = userId,
                Active = true,
                Card = new Card
                {
                    FullName = "Batman",
                    ExpiryMonth = "11",
                    ExpiryYear = "2020",
                    Number = "4111111111111111",
                    Type = "visa",
                    CVV = "123"
                }
            };
            var createdAccount = repo.CreateCardAccount(account);

            var gotUser = repo.GetUserForCardAccount(createdAccount.Id);

            Assert.IsNotNull(gotUser);

            Assert.AreEqual(userId, gotUser.Id);
        }