public void GivenNoSalePricing_Validate_ShouldNotHaveAValidationError() { // Arrange. SalePricing salePricing = null; // Act & Assert. _validator.ShouldHaveChildValidator(listing => listing.Pricing, typeof(SalePricingValidator)); _validator.ShouldNotHaveValidationErrorFor(listing => listing.Pricing, salePricing); }
private static void ExtractSoldOn(XElement element, SalePricing salePricing) { element.ShouldNotBe(null); // SoldOn could be date or soldData. Thanks REA for such a great schema. var soldOnText = element.ValueOrDefault(); if (!string.IsNullOrWhiteSpace(soldOnText)) { salePricing.SoldOn = ToDateTime(soldOnText); } }
public void GivenASalePricing_Validate_ShouldNotHaveAValidationError() { // Arrange. var salePricing = new SalePricing { SalePrice = 1234, SalePriceText = "Contact agent" }; // Act & Assert. _validator.ShouldHaveChildValidator(listing => listing.Pricing, typeof(SalePricingValidator)); _validator.ShouldNotHaveValidationErrorFor(listing => listing.Pricing, salePricing); }
private static SalePricing ExtractSalePricing(XElement document, CultureInfo cultureInfo) { document.ShouldNotBe(null); var salePricing = new SalePricing { SalePrice = document.MoneyValueOrDefault(cultureInfo, "price") }; // Selling data. var salePriceText = document.ValueOrDefault("priceView"); var displayAttributeValue = document.ValueOrDefault("priceView", "display"); var isDisplay = string.IsNullOrWhiteSpace(displayAttributeValue) || displayAttributeValue.ParseOneYesZeroNoToBool(); salePricing.SalePriceText = isDisplay ? salePriceText : string.IsNullOrWhiteSpace(salePriceText) ? "Price Witheld" : salePriceText; var isUnderOffer = document.ValueOrDefault("underOffer", "value"); salePricing.IsUnderOffer = !string.IsNullOrWhiteSpace(isUnderOffer) && isUnderOffer.ParseOneYesZeroNoToBool(); // Sold data. var soldDetails = document.Element("soldDetails"); if (soldDetails != null) { // SoldPrice could be price or soldPrice. Thanks REA for such a great schema. var soldPrice = soldDetails.Element("price") ?? soldDetails.Element("soldPrice"); if (soldPrice != null) { ExtractSoldPrice(soldPrice, salePricing); } var soldDate = soldDetails.Element("date") ?? soldDetails.Element("soldDate"); if (soldDate != null) { ExtractSoldOn(soldDate, salePricing); } } return(salePricing); }
private static void ExtractSoldPrice(XElement element, SalePricing salePricing) { element.ShouldNotBe(null); salePricing.SoldPrice = element.DecimalValueOrDefault(); var soldDisplayAttribute = element.ValueOrDefault(null, "display"); // NOTE: no display price assumes a 'YES' and that the price -is- to be displayed. salePricing.SoldPriceText = string.IsNullOrWhiteSpace(soldDisplayAttribute) || soldDisplayAttribute.ParseOneYesZeroNoToBool() ? null : "Sold Price Witheld"; }
public static void AssertSalePrice(SalePricing source, SalePricing destination) { if (source == null && destination == null) { return; } source.SalePrice.ShouldBe(destination.SalePrice); source.SalePriceText.ShouldBe(destination.SalePriceText); source.IsUnderOffer.ShouldBe(destination.IsUnderOffer); source.SoldOn.ShouldBe(destination.SoldOn); source.SoldPrice.ShouldBe(destination.SoldPrice); source.SoldPriceText.ShouldBe(destination.SoldPriceText); }
public void Copy(LandListing newLandListing) { if (newLandListing == null) { throw new ArgumentNullException("newLandListing"); } if (!newLandListing.IsModified) { return; } base.Copy(newLandListing); if (newLandListing.IsCategoryTypeModified) { CategoryType = newLandListing.CategoryType; } if (newLandListing.IsPricingModified) { if (newLandListing.Pricing == null) { Pricing = null; } else { if (Pricing == null) { Pricing = new SalePricing(); } if (newLandListing.IsPricingModified) { Pricing.Copy(newLandListing.Pricing); } IsPricingModified = true; } } if (newLandListing.IsAuctionOnModified) { AuctionOn = newLandListing.AuctionOn; } if (newLandListing.IsEstateModified) { if (newLandListing.Estate == null) { Estate = null; } else { if (Estate == null) { Estate = new LandEstate(); } Estate.Copy(newLandListing.Estate); IsEstateModified = true; } } if (newLandListing.IsCouncilRatesModified) { CouncilRates = newLandListing.CouncilRates; } }
public void Copy(RuralListing newRuralListing) { if (newRuralListing == null) { throw new ArgumentNullException("newRuralListing"); } base.Copy(newRuralListing); if (newRuralListing.IsCategoryTypeModified) { CategoryType = newRuralListing.CategoryType; } if (newRuralListing.IsPricingModified) { if (newRuralListing.Pricing == null) { Pricing = null; } else { if (Pricing == null) { Pricing = new SalePricing(); } if (newRuralListing.Pricing.IsModified) { Pricing.Copy(newRuralListing.Pricing); } IsPricingModified = true; } } if (newRuralListing.IsAuctionOnModified) { AuctionOn = newRuralListing.AuctionOn; } if (newRuralListing.IsRuralFeaturesModified) { if (newRuralListing.RuralFeatures == null) { RuralFeatures = null; } else { if (RuralFeatures == null) { RuralFeatures = new RuralFeatures(); } if (newRuralListing.RuralFeatures.IsModified) { RuralFeatures.Copy(newRuralListing.RuralFeatures); } IsRuralFeaturesModified = true; } } if (newRuralListing.IsCouncilRatesModified) { CouncilRates = newRuralListing.CouncilRates; } if (newRuralListing.IsBuildingDetailsModified) { if (newRuralListing.BuildingDetails == null) { BuildingDetails = null; } else { if (BuildingDetails == null) { BuildingDetails = new BuildingDetails(); } if (newRuralListing.BuildingDetails.IsModified) { BuildingDetails.Copy(newRuralListing.BuildingDetails); } IsBuildingDetailsModified = true; } } }
public void GivenTheFileREAResidentialSoldWithMissingDisplayPrice_Parse_ReturnsAResidentialSoldListing(string fileName, SalePricing salePricing, string defaultSoldPriceTextIfMissing) { // Arrange. var expectedListing = CreateAFakeEmptyResidentialListing("Residential-Sold-ABCD1234"); expectedListing.StatusType = StatusType.Sold; expectedListing.SourceStatus = "sold"; expectedListing.Pricing = salePricing; var reaXml = File.ReadAllText($"{FakeDataFolder}{fileName}"); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); if (!string.IsNullOrWhiteSpace(defaultSoldPriceTextIfMissing)) { reaXmlTransmorgrifier.DefaultSoldPriceTextIfMissing = defaultSoldPriceTextIfMissing; } // Act. var result = reaXmlTransmorgrifier.Parse(reaXml); // Assert. AssertResidentialListing(result, expectedListing); }
protected static ResidentialListing FakeResidentialListing(StatusType statusType, SalePricing salePricing = null) { var listing = new ResidentialListing(); SetupListing(listing, statusType); listing.Pricing = salePricing; return(listing); }
public void Copy(ResidentialListing newResidentialListing) { if (newResidentialListing == null) { throw new ArgumentNullException("newResidentialListing"); } if (!newResidentialListing.IsModified) { return; } base.Copy(newResidentialListing); if (newResidentialListing.IsPropertyTypeModified) { PropertyType = newResidentialListing.PropertyType; } if (newResidentialListing.IsPricingModified) { if (newResidentialListing.Pricing == null) { Pricing = null; } else { if (Pricing == null) { Pricing = new SalePricing(); } if (newResidentialListing.Pricing.IsModified) { Pricing.Copy(newResidentialListing.Pricing); } IsPricingModified = true; } } if (newResidentialListing.IsAuctionOnModified) { AuctionOn = newResidentialListing.AuctionOn; } if (newResidentialListing.IsCouncilRatesModified) { CouncilRates = newResidentialListing.CouncilRates; } if (newResidentialListing.IsBuildingDetailsModified) { if (newResidentialListing.BuildingDetails == null) { BuildingDetails = null; } else { if (BuildingDetails == null) { BuildingDetails = new BuildingDetails(); } if (newResidentialListing.BuildingDetails.IsModified) { BuildingDetails.Copy(newResidentialListing.BuildingDetails); } IsBuildingDetailsModified = true; } } }