public async Task CreateAsync() { var fileURL = "http://file.com/file"; var product = new SendOwlProduct { Name = TestProductName, Price = "18.99", Product_type = ProductType.software, License_type = "MIT", Self_hosted_url = fileURL }; var result = await endpoint.CreateAsync(product); result.Self_hosted_url.ShouldBe(fileURL); CreatedProductIds.Add(result.Id); result.Name.ShouldBe(product.Name); result.Price.ShouldBe(product.Price); result.Product_type.ShouldBe(product.Product_type); result.Id.ShouldBeGreaterThan(1); result.Add_to_cart_url.ShouldNotBeNull(); result.Instant_buy_url.ShouldNotBeNull(); result.Created_at.Date.ShouldBe(DateTime.UtcNow.Date); result.Updated_at.Date.ShouldBe(DateTime.UtcNow.Date); }
public async Task DeleteAsync() { var product = new SendOwlProduct { Name = TestProductName + "[Delete]" }; var result = await endpoint.CreateAsync(product); CreatedProductIds.Add(result.Id); result.ShouldNotBeNull(); await Task.Delay(5000); //API returns 500 if deleting too fast after creation await endpoint.DeleteAsync(result.Id); }
public async Task CreateAsync_With_File_Upload() { var product = new SendOwlProduct { Name = TestProductName + "[Cat]", Price = "1.99", Product_type = ProductType.digital, }; using (var stream = File.OpenRead("cat.jpg")) { var result = await endpoint.CreateAsync(product, stream, "cat.jpg"); CreatedProductIds.Add(result.Id); result.Name.ShouldBe(product.Name); result.Price.ShouldBe(product.Price); result.Product_type.ShouldBe(product.Product_type); result.Attachment.Filename.ShouldBe("cat.jpg"); result.Id.ShouldBeGreaterThan(1); } }
public async Task UpdateAsync() { var product = new SendOwlProduct { Name = TestProductName + "[Update]", Price = "10.00" }; var created = await endpoint.CreateAsync(product); await Task.Delay(5000); //API returns 500 if updating too fast after creation CreatedProductIds.Add(created.Id); created.Price.ShouldBe(product.Price); created.Name.ShouldBe(product.Name); created.Price = "5.00"; created.Product_type = ProductType.service; var updatedProduct = await endpoint.UpdateAsync(created); updatedProduct.Price.ShouldBe(created.Price); updatedProduct.Product_type.ShouldBe(created.Product_type); }