예제 #1
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);
        }
예제 #2
0
        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);
        }
예제 #3
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);
        }
예제 #4
0
        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);
        }