public static RentalListing RentalListing(bool isClearAllIsModified = true) { var listing = new RentalListing { AvailableOn = new DateTime(2015, 5, 23), BuildingDetails = new BuildingDetails { Area = new UnitOfMeasure { Type = "Some type", Value = 1.2345m }, EnergyRating = 111.222m, }, PropertyType = PropertyType.Townhouse, Pricing = new RentalPricing { RentalPrice = 567.88m, RentalPriceText = "house for rent", Bond = 1000m, PaymentFrequencyType = PaymentFrequencyType.Monthly } }; if (isClearAllIsModified) { listing.ClearAllIsModified(); } return listing; }
public void Copy(RentalListing newRentalListing) { if (newRentalListing == null) { throw new ArgumentNullException("newRentalListing"); } base.Copy(newRentalListing); if (newRentalListing.IsPropertyTypeModified) { PropertyType = newRentalListing.PropertyType; } if (newRentalListing.IsAvailableOnModified) { AvailableOn = newRentalListing.AvailableOn; } if (newRentalListing.IsPricingModified) { if (newRentalListing.Pricing == null) { Pricing = null; } else { if (Pricing == null) { Pricing = new RentalPricing(); } if (newRentalListing.Pricing.IsModified) { Pricing.Copy(newRentalListing.Pricing); } IsPricingModified = true; } } if (newRentalListing.IsBuildingDetailsModified) { if (newRentalListing.BuildingDetails == null) { BuildingDetails = null; } else { if (BuildingDetails == null) { BuildingDetails = new BuildingDetails(); } if (newRentalListing.BuildingDetails.IsModified) { BuildingDetails.Copy(newRentalListing.BuildingDetails); } IsBuildingDetailsModified = true; } } }
private static void AssertRentalCurrentListing(RentalListing listing, IList<string> tags = null, bool isModified = true, int bedroomsCount = 0) { listing.AgencyId.ShouldBe("XNWXNW"); listing.IsAgencyIdModified.ShouldBe(isModified); listing.Id.ShouldBe("Rental-Current-ABCD1234"); listing.IsIdModified.ShouldBe(isModified); listing.StatusType.ShouldBe(StatusType.Current); listing.IsStatusTypeModified.ShouldBe(isModified); listing.PropertyType.ShouldBe(PropertyType.House); listing.IsPropertyTypeModified.ShouldBe(isModified); AssertAddress(listing.Address, "39", isModified); listing.IsAddressModified.ShouldBe(isModified); listing.AvailableOn.ShouldBe(new DateTime(2009, 01, 26, 12, 30, 00)); listing.Pricing.RentalPrice.ShouldBe(350); listing.Pricing.RentalPriceText.ShouldBe("$350"); listing.Pricing.PaymentFrequencyType.ShouldBe(PaymentFrequencyType.Weekly); listing.Pricing.Bond.ShouldBe(999); listing.Inspections.Count.ShouldBe(2); listing.Agents.Count.ShouldBe(1); var listingAgent = listing.Agents[0]; listingAgent.Name.ShouldBe("Mr. John Doe"); listingAgent.Order.ShouldBe(1); listingAgent.Communications[0].CommunicationType.ShouldBe(CommunicationType.Email); listingAgent.Communications[0].Details.ShouldBe("*****@*****.**"); listingAgent.Communications[1].CommunicationType.ShouldBe(CommunicationType.Landline); listingAgent.Communications[1].Details.ShouldBe("05 1234 5678"); AssertFeatures(listing.Features, tags, isModified, bedroomsCount:bedroomsCount, bathroomCount: 2, ensuitesCount: 2, carParking: new CarParking { Garages = 3, Carports = 2 }); listing.Images.Count.ShouldBe(2); listing.Images[0].Order.ShouldBe(1); listing.Images[0].Url.ShouldBe("http://www.realestate.com.au/tmp/imageM.jpg"); listing.LandDetails.Area.Value.ShouldBe(60M); listing.LandDetails.Area.Type.ShouldBe("square"); listing.LandDetails.Frontage.Value.ShouldBe(15M); listing.LandDetails.Frontage.Type.ShouldBe("meter"); listing.LandDetails.Depths[0].Value.ShouldBe(40M); listing.LandDetails.Depths[0].Type.ShouldBe("meter"); listing.LandDetails.Depths[0].Side.ShouldBe("rear"); listing.FloorPlans.Count.ShouldBe(2); }
private static Listing CreateListing(CategoryType categoryType) { Listing listing; switch (categoryType) { case CategoryType.Sale: listing = new ResidentialListing(); break; case CategoryType.Rent: listing = new RentalListing(); break; case CategoryType.Land: listing = new LandListing(); break; case CategoryType.Rural: listing = new RuralListing(); break; default: // Not sure if we should do some logging here? listing = null; break; } return listing; }
private static void ExtractRentalNewConstruction(XElement document, RentalListing listing) { document.ShouldNotBe(null); listing.ShouldNotBe(null); if (!document.BoolValueOrDefault("newConstruction")) { return; } if (listing.Features == null) { listing.Features = new Features(); } if (listing.Features.Tags == null) { listing.Features.Tags = new HashSet<string>(); } listing.Features.Tags.Add("isANewConstruction"); }
private static void ExtractRentalData(RentalListing rentalListing, XElement document, CultureInfo cultureInfo) { rentalListing.ShouldNotBe(null); document.ShouldNotBe(null); var dateAvailble = document.ValueOrDefault("dateAvailable"); if (!string.IsNullOrWhiteSpace(dateAvailble)) { rentalListing.AvailableOn = ToDateTime(dateAvailble); } rentalListing.PropertyType = ExtractResidentialAndRentalPropertyType(document); rentalListing.Pricing = ExtractRentalPricing(document, cultureInfo); rentalListing.Features = ExtractFeatures(document); rentalListing.BuildingDetails = ExtractBuildingDetails(document); ExtractRentalNewConstruction(document, rentalListing); }