public async Task PriceIdExists_ReturnsResult() { cataloguePriceResult.Add(Price1); var price = await context.GetPricingByPriceIdHandler.Handle( new GetPriceByPriceIdQuery(PriceId), cancellationToken); price.CataloguePriceId.Should().Be(PriceId); price.CatalogueItemId.Should().BeEquivalentTo(Price1.CatalogueItemId); price.CatalogueItemName.Should().BeEquivalentTo(Price1.CatalogueItemName); price.Type.Should().BeEquivalentTo( Enumerator.FromValue <CataloguePriceType>(Price1.CataloguePriceTypeId).Name); price.ProvisioningType.Should().BeEquivalentTo( Enumerator.FromValue <ProvisioningType>(Price1.CataloguePriceTypeId).Name); price.PricingUnit.Name.Should().BeEquivalentTo(Price1.PricingUnitName); price.PricingUnit.Description.Should().BeEquivalentTo(Price1.PricingUnitDescription); price.PricingUnit.TierName.Should().BeEquivalentTo(Price1.PricingUnitTierName); price.TimeUnit.Name.Should().BeEquivalentTo( Price1.TimeUnitId is null ? null : Enumerator.FromValue <TimeUnit>(Price1.TimeUnitId.Value).Name); price.TimeUnit.Description.Should().BeEquivalentTo( Price1.TimeUnitId is null ? null : Enumerator.FromValue <TimeUnit>(Price1.TimeUnitId.Value).Description); price.CurrencyCode.Should().BeEquivalentTo(Price1.CurrencyCode); }
private static IEnumerable <CataloguePriceBase> ProcessPriceItems(IEnumerable <ICataloguePriceListResult> priceItems) { Dictionary <int, CataloguePriceBase> priceDictionary = new Dictionary <int, CataloguePriceBase>(); foreach (var price in priceItems) { var cataloguePriceType = Enumerator.FromValue <CataloguePriceType>(price.CataloguePriceTypeId); if (Equals(cataloguePriceType, CataloguePriceType.Flat)) { priceDictionary.Add(price.CataloguePriceId, GetFlatPrice(price)); } else if (Equals(cataloguePriceType, CataloguePriceType.Tiered)) { CataloguePriceTier tier; if (priceDictionary.ContainsKey(price.CataloguePriceId)) { tier = priceDictionary[price.CataloguePriceId] as CataloguePriceTier; UpdateTierPrices(tier, price); } else { tier = GetTierPrice(price); priceDictionary.Add(price.CataloguePriceId, tier); } } } return(priceDictionary.Values); }
public void FromValueGivenValueFourShouldThrow() { const int expectedValue = 4; var exception = Assert.Throws <InvalidOperationException>( () => _ = Enumerator.FromValue <SizeType>(expectedValue)); // ReSharper disable once PossibleNullReferenceException exception.Message.Should().Be($"'{expectedValue}' is not a valid value in {typeof(SizeType)}"); }
public void FromValueGivenValueFourShouldThrow() { var expectedValue = 4; var exception = Assert.Throws <InvalidOperationException>(() => { var actual = Enumerator.FromValue <SupplierStatus>(expectedValue); }); exception.Message.Should().Be($"'{expectedValue}' is not a valid value in {typeof(SupplierStatus)}"); }
private static CataloguePriceFlat GetFlatPrice(ICataloguePriceListResult price) { var flatPrice = new CataloguePriceFlat { CataloguePriceId = price.CataloguePriceId, CatalogueItemName = price.CatalogueItemName, CatalogueItemId = price.CatalogueItemId, PricingUnit = new PricingUnit { Description = price.PricingUnitDescription, Name = price.PricingUnitName, TierName = price.PricingUnitTierName }, TimeUnit = price.TimeUnitId == 0 ? null : Enumerator.FromValue <TimeUnit>(price.TimeUnitId), CurrencyCode = price.CurrencyCode, Price = price.FlatPrice.GetValueOrDefault(), ProvisioningType = Enumerator.FromValue <ProvisioningType>(price.ProvisioningTypeId) }; return(flatPrice); }
private static CataloguePriceTier GetTierPrice(ICataloguePriceListResult price) { CataloguePriceTier tier = new CataloguePriceTier { CataloguePriceId = price.CataloguePriceId, CatalogueItemName = price.CatalogueItemName, CatalogueItemId = price.CatalogueItemId, CurrencyCode = price.CurrencyCode, PricingUnit = new PricingUnit { Name = price.PricingUnitName, Description = price.PricingUnitDescription, TierName = price.PricingUnitTierName }, TimeUnit = Enumerator.FromValue <TimeUnit>(price.TimeUnitId), ProvisioningType = Enumerator.FromValue <ProvisioningType>(price.ProvisioningTypeId) }; UpdateTierPrices(tier, price); return(tier); }
public void FromValueGivenValueTwoShouldBeAuthorityReview() { Enumerator.FromValue <SupplierStatus>(2).Should().Be(SupplierStatus.AuthorityReview); }
public void FromValueGivenValueOneShouldBeDraft() { Enumerator.FromValue <SupplierStatus>(1).Should().Be(SupplierStatus.Draft); }
public void FromValueGivenValueSmallShouldBeEqual() { Enumerator.FromValue <SizeType>(1).Should().Be(SizeType.Small); }