コード例 #1
0
        public void CreatePayPalAccountSuccessfully()
        {
            var content = File.ReadAllText("../../Fixtures/paypal_account_create.json");
            var client  = GetMockClient(content);
            var repo    = new PayPalAccountRepository(client.Object);

            var userId  = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
            var account = new Dictionary <string, object>
            {
                { "user_id", userId },
                { "active", true },
                { "paypal", new Dictionary <string, object>
                  {
                      { "paypal_email", "*****@*****.**" }
                  } }
            };
            var resp           = repo.CreatePayPalAccount(account);
            var createdAccount = JsonConvert.DeserializeObject <IDictionary <string, object> >(JsonConvert.SerializeObject(resp.Values.First()));

            Assert.IsNotNull(createdAccount);
            Assert.IsNotNull(createdAccount["id"]);
            Assert.AreEqual("AUD", (string)createdAccount["currency"]); // It seems that currency is determined by country
            Assert.IsNotNull(createdAccount["created_at"]);
            Assert.IsNotNull(createdAccount["updated_at"]);
        }
コード例 #2
0
        public void GetPayPalAccountEmptyId()
        {
            var client = GetMockClient("");

            var repo = new PayPalAccountRepository(client.Object);

            Assert.Throws <ArgumentException>(() => repo.GetPayPalAccountById(string.Empty));
        }
コード例 #3
0
        public void DeletePayPalAccountSuccessfully()
        {
            var content = File.ReadAllText("../../Fixtures/paypal_account_delete.json");
            var client  = GetMockClient(content);
            var repo    = new PayPalAccountRepository(client.Object);

            var result = repo.DeletePayPalAccount("cd2ab053-25e5-491a-a5ec-0c32dbe76efa");

            Assert.IsTrue(result);
        }
コード例 #4
0
        public void GetPayPalAccountSuccessfully()
        {
            var id      = "cd2ab053-25e5-491a-a5ec-0c32dbe76efa";
            var content = File.ReadAllText("../../Fixtures/paypal_account_create.json");
            var client  = GetMockClient(content);
            var repo    = new PayPalAccountRepository(client.Object);

            var gotAccount = repo.GetPayPalAccountById(id);

            Assert.AreEqual(id, gotAccount.Id);
        }
コード例 #5
0
        public void GetPayPalAccountSuccessfully()
        {
            var id      = "cd2ab053-25e5-491a-a5ec-0c32dbe76efa";
            var content = File.ReadAllText("../../Fixtures/paypal_account_create.json");
            var client  = GetMockClient(content);
            var repo    = new PayPalAccountRepository(client.Object);

            var resp       = repo.GetPayPalAccountById(id);
            var gotAccount = JsonConvert.DeserializeObject <IDictionary <string, object> >(JsonConvert.SerializeObject(resp.Values.First()));

            Assert.AreEqual(id, (string)gotAccount["id"]);
        }
コード例 #6
0
        public void GetUserForPayPalAccountSuccessfully()
        {
            var id = "3a780d4a-5de0-409c-9587-080930ddea3c";

            var content = File.ReadAllText("../../Fixtures/paypal_account_get_users.json");
            var client  = GetMockClient(content);
            var repo    = new PayPalAccountRepository(client.Object);

            var userId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before

            var gotUser = repo.GetUserForPayPalAccount(id);

            Assert.IsNotNull(gotUser);

            Assert.AreEqual(userId, gotUser.Id);
        }
コード例 #7
0
        public void GetUserForPayPalAccountSuccessfully()
        {
            var id = "3a780d4a-5de0-409c-9587-080930ddea3c";

            var content = File.ReadAllText("../../Fixtures/paypal_account_get_users.json");
            var client  = GetMockClient(content);
            var repo    = new PayPalAccountRepository(client.Object);

            var userId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before

            var resp = repo.GetUserForPayPalAccount(id);

            Assert.IsNotNull(resp);
            var users = JsonConvert.DeserializeObject <IDictionary <string, object> >(JsonConvert.SerializeObject(resp["users"]));

            Assert.AreEqual(userId, users["id"]);
        }
コード例 #8
0
        public void CreatePayPalAccountSuccessfully()
        {
            var content = File.ReadAllText("../../Fixtures/paypal_account_create.json");
            var client  = GetMockClient(content);
            var repo    = new PayPalAccountRepository(client.Object);

            var userId  = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
            var account = new PayPalAccount
            {
                UserId = userId,
                Active = true,
                PayPal = new PayPal
                {
                    Email = "*****@*****.**"
                }
            };
            var createdAccount = repo.CreatePayPalAccount(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);
        }