Exemple #1
0
        public void CreateItemSuccessfully()
        {
            var content = File.ReadAllText("../../Fixtures/items_create.json");

            var client = GetMockClient(content);
            var repo = new ItemRepository(client.Object);
            const string id = "5e81906c-e14b-42a8-952f-4a0d1f1a4bb8";
            const string buyerId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
            const string sellerId = "fdf58725-96bd-4bf8-b5e6-9b61be20662e"; //some user created before
            var item = new Item
            {
                Id = id,
                Name = "Test Item #1",
                Amount = 1000,
                PaymentType = PaymentType.Express,
                BuyerId = buyerId, //optional field
                SellerId = sellerId, //optional field
                //No fee at this stage, optional field
                Description = "Test item #1 description"
            };
            var createdItem = repo.CreateItem(item);
            Assert.AreEqual(item.Id, createdItem.Id);
            Assert.AreEqual(item.Name, createdItem.Name);
            Assert.AreEqual(item.Amount, createdItem.Amount);
            Assert.AreEqual(item.PaymentType, createdItem.PaymentType);
            Assert.AreEqual(item.Description, createdItem.Description);
        }
 public void MakePaymentSuccessfully()
 {
     var repo = new ItemRepository();
     var itemId = "7c269f52-2236-4aa5-899e-a2e3ecadbc3f";
     var cardId = "2e2ed4fb-4eb2-458e-99f9-2bf0b3004933";
     var userId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c";
     repo.MakePayment(itemId, cardId, userId);
 }
Exemple #3
0
 public void DeleteItemSuccessful()
 {
     var id = "db3d95aa-2e35-4d87-95b4-5c9b41ba7346";
     var content = File.ReadAllText("../../Fixtures/items_delete.json");
     var client = GetMockClient(content);
     var repo = new ItemRepository(client.Object);
     Assert.IsTrue(repo.DeleteItem(id));
     client.VerifyAll();
 }
Exemple #4
0
        public void DeleteItemMissingId()
        {
            var content = File.ReadAllText("../../Fixtures/items_delete_unsuccessful.json");
            var response = new Mock<IRestResponse>(MockBehavior.Strict);
            response.SetupGet(x => x.Content).Returns(content);
            response.SetupGet(x => x.ResponseUri).Returns(new Uri("http://google.com"));
            response.SetupGet(x => x.StatusDescription).Returns("Unauthorized");
            response.SetupGet(x => x.StatusCode).Returns(HttpStatusCode.Unauthorized);

            var client = new Mock<IRestClient>(MockBehavior.Strict);
            client.SetupSet(x => x.BaseUrl = It.IsAny<Uri>());
            client.SetupSet(x => x.Authenticator = It.IsAny<IAuthenticator>());
            client.Setup(x => x.Execute(It.IsAny<IRestRequest>())).Returns(response.Object);
            var repo = new ItemRepository(client.Object);
            var id = Guid.NewGuid().ToString();
            Assert.IsFalse(repo.DeleteItem(id));
        }
        public void DeleteItemSuccessful()
        {
            //First, create a item with known id
            var repo = new ItemRepository();
            var id = Guid.NewGuid().ToString();
            var buyerId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
            var sellerId = "fdf58725-96bd-4bf8-b5e6-9b61be20662e"; //some user created before
            var item = new Item
            {
                Id = id,
                Name = "Test Item #1",
                Amount = 1000,
                PaymentType = PaymentType.Express,
                BuyerId = buyerId, //optional field
                SellerId = sellerId, //optional field
                //No fee at this stage, optional field
                Description = "Test item #1 description"
            };

            repo.CreateItem(item);

            //Then, get item
            var gotItem = repo.GetItemById(id);
            Assert.IsNotNull(gotItem);
            Assert.AreEqual(gotItem.Id, id);

            //Now, delete item
            Assert.IsTrue(repo.DeleteItem(id));

            //And check whether item exists now

            var deletedItem = repo.GetItemById(id);

            //Exists, but unactive
            Assert.AreEqual("cancelled",deletedItem.State);
        }
 public void CreateItemSuccessfully()
 {
     var repo = new ItemRepository();
     var id = Guid.NewGuid().ToString();
     var buyerId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
     var sellerId = "fdf58725-96bd-4bf8-b5e6-9b61be20662e"; //some user created before
     var item = new Item
     {
         Id = id,
         Name = "Test Item #1",
         Amount = 1000,
         PaymentType = PaymentType.Express,
         BuyerId = buyerId, //optional field
         SellerId = sellerId, //optional field
         //No fee at this stage, optional field
         Description = "Test item #1 description"
     };
     var createdItem = repo.CreateItem(item);
     Assert.AreEqual(item.Id, createdItem.Id);
     Assert.AreEqual(item.Name, createdItem.Name);
     Assert.AreEqual(item.Amount, createdItem.Amount);
     Assert.AreEqual(item.PaymentType, createdItem.PaymentType);
     Assert.AreEqual(item.Description, createdItem.Description);
 }
Exemple #7
0
        public void ListAllItemsSuccessfully()
        {
            var content = File.ReadAllText("../../Fixtures/items_list.json");

            var client = GetMockClient(content);
            var repo = new ItemRepository(client.Object);
            //Then, list items
            var items = repo.ListItems(200);

            Assert.IsNotNull(items);
            Assert.IsTrue(items.Any());
        }
Exemple #8
0
 public void ListAllItemsNegativeParams()
 {
     var client = GetMockClient("");
     var repo = new ItemRepository(client.Object);
     //Then, list items
     var items = repo.ListItems(-10,-10);
 }
        public void GetItemSuccessful()
        {
            //First, create a user with known id
            var repo = new ItemRepository();
            var id = Guid.NewGuid().ToString();
            var buyerId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
            var sellerId = "fdf58725-96bd-4bf8-b5e6-9b61be20662e"; //some user created before
            var item = new Item
            {
                Id = id,
                Name = "Test Item #1",
                Amount = 1000,
                PaymentType = PaymentType.Express,
                BuyerId = buyerId, //optional field
                SellerId = sellerId, //optional field
                //No fee at this stage, optional field
                Description = "Test item #1 description"
            };

            repo.CreateItem(item);

            //Then, get user
            var gotItem = repo.GetItemById(id);

            Assert.IsNotNull(gotItem);
            Assert.AreEqual(gotItem.Id, id);
        }
Exemple #10
0
 public void GetStatusForItem()
 {
     var content = File.ReadAllText("../../Fixtures/items_get_status.json");
     var client = GetMockClient(content);
     var repo = new ItemRepository(client.Object);
     var status = repo.GetStatusForItem("7c269f52-2236-4aa5-899e-a2e3ecadbc3f");
     Assert.IsNotNull(status);
 }
Exemple #11
0
        public void GetWireDetailsForItemSuccessfully()
        {
            var content = File.ReadAllText("../../Fixtures/items_get_wire_details.json");
            var client = GetMockClient(content);
            var repo = new ItemRepository(client.Object);

            var wireDetails = repo.GetWireDetailsForItem("7c269f52-2236-4aa5-899e-a2e3ecadbc3f");
            Assert.IsNotNull(wireDetails);
        }
 public void GetStatusForItem()
 {
     var repo = new ItemRepository();
     var status = repo.GetStatusForItem("7c269f52-2236-4aa5-899e-a2e3ecadbc3f");
     Assert.IsNotNull(status);
 }
 public void ListAllItemsNegativeParams()
 {
     var repo = new ItemRepository();
     //Then, list items
     var items = repo.ListItems(-10,-10);
 }
Exemple #14
0
        public void EditItemMissingId()
        {
            var content = File.ReadAllText("../../Fixtures/items_edit_unsuccessful.json");
            var response = new Mock<IRestResponse>(MockBehavior.Strict);
            response.SetupGet(x => x.Content).Returns(content);
            response.SetupGet(x => x.ResponseUri).Returns(new Uri("http://google.com"));
            response.SetupGet(x => x.StatusDescription).Returns("Unauthorized");
            response.SetupGet(x => x.StatusCode).Returns(HttpStatusCode.Unauthorized);

            var client = new Mock<IRestClient>(MockBehavior.Strict);
            client.SetupSet(x => x.BaseUrl = It.IsAny<Uri>());
            client.SetupSet(x => x.Authenticator = It.IsAny<IAuthenticator>());
            client.Setup(x => x.Execute(It.IsAny<IRestRequest>())).Returns(response.Object);
            var repo = new ItemRepository(client.Object);
            var id = Guid.NewGuid().ToString();
            var buyerId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
            var sellerId = "fdf58725-96bd-4bf8-b5e6-9b61be20662e"; //some user created before
            var item = new Item
            {
                Id = id,
                Name = "Test Item #1",
                Amount = 1000,
                PaymentType = PaymentType.Express,
                BuyerId = buyerId, //optional field
                SellerId = sellerId, //optional field
                //No fee at this stage, optional field
                Description = "Test item #1 description"
            };

            repo.UpdateItem(item);
        }
 public void GetSellerForItemSuccessfully()
 {
     var repo = new ItemRepository();
     var sellers = repo.GetSellerForItem("7c269f52-2236-4aa5-899e-a2e3ecadbc3f");
     Assert.IsNotNull(sellers);
 }
 public void ListTransactionsForItem()
 {
     var repo = new ItemRepository();
     var transactions = repo.ListTransactionsForItem("7c269f52-2236-4aa5-899e-a2e3ecadbc3f");
 }
 public void DeleteItemMissingId()
 {
     var repo = new ItemRepository();
     var id = Guid.NewGuid().ToString();
     Assert.IsFalse(repo.DeleteItem(id));
 }
 public void ListFeesForItem()
 {
     var repo = new ItemRepository();
     var fees = repo.ListFeesForItem("7c269f52-2236-4aa5-899e-a2e3ecadbc3f");
 }
 public void ListAllItemsTooHighLimit()
 {
     var repo = new ItemRepository();
     //Then, list items
     var items = repo.ListItems(500);
 }
        public void ListAllItemsSuccessfully()
        {
            var repo = new ItemRepository();
            //Then, list items
            var items = repo.ListItems(200);

            Assert.IsNotNull(items);
            Assert.IsTrue(items.Any());
        }
Exemple #21
0
        public void ListAllItemsTooHighLimit()
        {
            var client = GetMockClient("");
            var repo = new ItemRepository(client.Object);

            //Then, list items
            var items = repo.ListItems(500);
        }
Exemple #22
0
        public void EditItemSuccessful()
        {
            //First, create a item we'll work with
            var content = File.ReadAllText("../../Fixtures/items_edit.json");
            var client = GetMockClient(content);
            var repo = new ItemRepository(client.Object);

            var id = "172500df-0f2a-4e43-8fe7-f4a36dfbd1a2";
            var buyerId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
            var sellerId = "fdf58725-96bd-4bf8-b5e6-9b61be20662e"; //some user created before
            var item = new Item
            {
                Id = id,
                Name = "Test Item #1",
                Amount = 1000,
                PaymentType = PaymentType.Express,
                BuyerId = buyerId, //optional field
                SellerId = sellerId, //optional field
                //No fee at this stage, optional field
                Description = "Test item #1 description"
            };

            //Now, try to edit newly created item
            item.Name = "Test123";
            item.Description = "Test123";
            var updatedItem = repo.UpdateItem(item);

            Assert.AreEqual("Test123", updatedItem.Name);
            Assert.AreEqual("Test123", updatedItem.Description);
        }
Exemple #23
0
        public void ListTransactionsForItem()
        {
            var content = File.ReadAllText("../../Fixtures/items_list_transactions.json");
            var client = GetMockClient(content);
            var repo = new ItemRepository(client.Object);

            var transactions = repo.ListTransactionsForItem("7c269f52-2236-4aa5-899e-a2e3ecadbc3f");
            Assert.NotNull(transactions);
        }
Exemple #24
0
        public void GetItemSuccessful()
        {
            //First, create a user with known id
            var content = File.ReadAllText("../../Fixtures/items_get_by_id.json");

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

            const string id = "5e81906c-e14b-42a8-952f-4a0d1f1a4bb8";
            var gotItem = repo.GetItemById(id);

            Assert.IsNotNull(gotItem);
            Assert.AreEqual(id, gotItem.Id);
        }
 public void GetItemMissingId()
 {
     var repo = new ItemRepository();
     var id = Guid.NewGuid().ToString();
     repo.GetItemById(id);
 }
 public void GetWireDetailsForItemSuccessfully()
 {
     var repo = new ItemRepository();
     var wireDetails = repo.GetWireDetailsForItem("7c269f52-2236-4aa5-899e-a2e3ecadbc3f");
     Assert.IsNotNull(wireDetails);
 }
        public void EditItemMissingId()
        {
            var repo = new ItemRepository();
            var id = Guid.NewGuid().ToString();
            var buyerId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
            var sellerId = "fdf58725-96bd-4bf8-b5e6-9b61be20662e"; //some user created before
            var item = new Item
            {
                Id = id,
                Name = "Test Item #1",
                Amount = 1000,
                PaymentType = PaymentType.Express,
                BuyerId = buyerId, //optional field
                SellerId = sellerId, //optional field
                //No fee at this stage, optional field
                Description = "Test item #1 description"
            };

            repo.UpdateItem(item);
        }
        public void EditItemSuccessful()
        {
            //First, create a item we'll work with
            var repo = new ItemRepository();
            var id = Guid.NewGuid().ToString();
            var buyerId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
            var sellerId = "fdf58725-96bd-4bf8-b5e6-9b61be20662e"; //some user created before
            var item = new Item
            {
                Id = id,
                Name = "Test Item #1",
                Amount = 1000,
                PaymentType = PaymentType.Express,
                BuyerId = buyerId, //optional field
                SellerId = sellerId, //optional field
                //No fee at this stage, optional field
                Description = "Test item #1 description"
            };

            repo.CreateItem(item);

            //Now, try to edit newly created item
            item.Name = "Test123";
            item.Description = "Test123";
            var updatedItem = repo.UpdateItem(item);

            Assert.AreEqual("Test123", updatedItem.Name);
            Assert.AreEqual("Test123", updatedItem.Description);
        }