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);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public void GetItemMissingId()
        {
            var content = File.ReadAllText("../../Fixtures/items_not_found.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();
            repo.GetItemById(id);
        }
        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);
        }
 public void GetItemMissingId()
 {
     var repo = new ItemRepository();
     var id = Guid.NewGuid().ToString();
     repo.GetItemById(id);
 }