public void IsExpired_Correct(bool expectedResult, int minutesFromNow) { var basketDetails = new SDK.Basket.Models.Basket { ExpiredAt = DateTimeOffset.UtcNow.AddMinutes(minutesFromNow) }; var result = basketDetails.IsExpired(); Assert.AreEqual(expectedResult, result); }
private (int?sumOfPrices, SDK.Basket.Models.Basket basketDetails) CreateBasketDetailsFromDefaultPrices(Func <Price, int, Reservation> reservationFunc, Func <Reservation, Price> reverseFunc = null) { var defaultPrices = CreateDefaultListOfPrices(); var reservations = defaultPrices.Select(reservationFunc).ToList(); var sumOfPrices = reverseFunc != null?reservations.Sum(r => r.Quantity *reverseFunc(r).Value).Value : (int?)null; var basketDetails = new SDK.Basket.Models.Basket { Reservations = reservations }; return(sumOfPrices, basketDetails); }
public void ItemCount_Correct(int expectedResult, params int[] quantities) { var reservations = quantities?.Select(q => new Reservation { Quantity = q }).ToList(); var basketDetails = new SDK.Basket.Models.Basket { Reservations = reservations }; var result = basketDetails.ItemCount(); Assert.AreEqual(expectedResult, result); }
public void FromBasketToUpsertBasketRequest_CorrectlyMapped() { var sourceBasket = new SDK.Basket.Models.Basket { Reservations = Enumerable.Range(1, 3).Select(i => new Reservation { Quantity = i }).ToList(), Coupon = new Coupon { Code = "DISCOUNT" }, Reference = "1234567", AllowFlexiTickets = true, ChannelId = "test-channel", Delivery = new Delivery { Method = DeliveryMethod.Postage, Charge = new Price { Currency = DefaultCurrency, DecimalPlaces = DefaultDecimalPlaces, Value = 145, }, }, ShopperReference = "test reference", ShopperCurrency = "USD", }; var result = sourceBasket.Map <SDK.Basket.Models.Basket, UpsertBasketParameters>(); result.ShouldBeEquivalentToObjectWithMoreProperties(sourceBasket); Assert.AreEqual(sourceBasket.AllowFlexiTickets, result.HasFlexiTickets); result.Delivery.Should().BeEquivalentTo(sourceBasket.Delivery); result.Coupon.Should().BeEquivalentTo(sourceBasket.Coupon); for (var i = 0; i < result.Reservations.Count; i++) { result.Reservations[i].ShouldBeEquivalentToObjectWithMoreProperties(sourceBasket.Reservations[i]); } }