public async Task ShouldChangeCartDiscountsDiscountCodeAsync() { // Arrange var discountCode = await Helper.CreateTestDiscountCode(this._project, this._client, true, true, true); var oldCartDiscountId = discountCode.CartDiscounts.First().Id; var cartDiscount = await Helper.CreateTestCartDiscount(this._project, this._client, true, true); var reference = new List <Reference>() { new Reference { ReferenceType = ReferenceType.CartDiscount, Id = cartDiscount.Id } }; var changeCartDiscounts = new ChangeCartDiscountsAction(reference); // Act var updatedDiscountCodeResponse = await this._client.DiscountCodes() .UpdateDiscountCodeAsync(discountCode, changeCartDiscounts); // Assert var updatedDiscountCode = updatedDiscountCodeResponse.Result; Assert.IsNotNull(updatedDiscountCode); Assert.IsNotNull(updatedDiscountCode.Id); updatedDiscountCode.CartDiscounts.ShouldAllBeEquivalentTo(changeCartDiscounts.CartDiscounts); // Cleanup await Helper.DeleteDiscountCode(this._client, updatedDiscountCode); await this._client.CartDiscounts().DeleteCartDiscountAsync(oldCartDiscountId, 1); }
public async Task ShouldChangeCartDiscountsDiscountCodeAsync() { // Arrange var discountCode = await Helper.CreateTestDiscountCode(this._project, this._client); var oldCartDiscountId = discountCode.CartDiscounts.First().Id; var cartDiscount = await Helper.CreateTestCartDiscount(this._project, this._client, true); var reference = new List <Reference>() { new Reference { ReferenceType = ReferenceType.CartDiscount, Id = cartDiscount.Id } }; var changeCartDiscounts = new ChangeCartDiscountsAction(reference); // Act var updatedDiscountCodeResponse = await this._client.DiscountCodes() .UpdateDiscountCodeAsync(discountCode, changeCartDiscounts); // Assert var updatedDiscountCode = updatedDiscountCodeResponse.Result; Assert.NotNull(updatedDiscountCode); Assert.NotNull(updatedDiscountCode.Id); for (var i = 0; i < discountCode.CartDiscounts.Count; i++) { var crtDiscount = updatedDiscountCode.CartDiscounts[i]; var cartDiscountReference = changeCartDiscounts.CartDiscounts[i]; Assert.Equal(crtDiscount.Id, cartDiscountReference.Id); Assert.Equal(crtDiscount.ReferenceType, cartDiscountReference.ReferenceType); } // Cleanup await Helper.DeleteDiscountCode(this._client, updatedDiscountCode); await this._client.CartDiscounts().DeleteCartDiscountAsync(oldCartDiscountId, 1); }