GivenTheFileREAResidentialCurrent_ParseThenSerializeThenDeserialize_ReturnsAResidentialAvailableListing(string fileName, bool isFloorPlansCleared, StatusType statusType) { // Arrange. ResidentialListing expectedListing; if (statusType == StatusType.Available) { expectedListing = FakeListings.CreateAFakeResidentialListing(); } else { expectedListing = CreateAFakeEmptyResidentialListing("Residential-Sold-ABCD1234"); expectedListing.StatusType = StatusType.Sold; expectedListing.SourceStatus = "sold"; expectedListing.Pricing = new SalePricing { SoldOn = new DateTime(2009, 1, 10, 12, 30, 00), SoldPrice = 580000M, SoldPriceText = "$580,000" }; } if (isFloorPlansCleared) { expectedListing.FloorPlans = new List <Media>(); } var reaXml = File.ReadAllText(FakeDataFolder + fileName); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); // Parse the xml, once for the first time. var tempResult = reaXmlTransmorgrifier.Parse(reaXml); var source = tempResult.Listings.First().Listing; var json = source.SerializeObject(); // Act. var result = JsonConvertHelpers.DeserializeObject(json); // Assert. var listingResult = new ListingResult { Listing = result, SourceData = "blahblah" }; var parsedResult = new ParsedResult { Listings = new List <ListingResult> { listingResult }, UnhandledData = new List <string>(), Errors = new List <ParsedError>(), TransmorgrifierName = "REA" }; AssertResidentialListing(parsedResult, expectedListing); }
public void GivenTheFileREAResidentialCurrentWithDuplicateAgents_Parse_ReturnsAResidentialAvailableListing() { // Arrange. var agents = new List <Agent> { new Agent { Name = "Princess Leia", Order = 1, Communications = new List <Communication> { new Communication { CommunicationType = CommunicationType.Email, Details = "*****@*****.**" }, new Communication { CommunicationType = CommunicationType.Mobile, Details = "1234 1234" } } }, new Agent { Name = "Han Solo", Order = 2, Communications = new List <Communication> { new Communication { CommunicationType = CommunicationType.Email, Details = "*****@*****.**" }, new Communication { CommunicationType = CommunicationType.Mobile, Details = "0987 0987" } } } }; var expectedListing = FakeListings.CreateAFakeResidentialListing(); expectedListing.Agents = agents; var reaXml = File.ReadAllText(FakeDataFolder + "REA-Residential-Current-WithDuplicateAgents.xml"); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); // Act. var result = reaXmlTransmorgrifier.Parse(reaXml); // Assert. AssertResidentialListing(result, expectedListing); }
public void GivenTheFileREAResidentialCurrent_Parse_ReturnsAResidentialAvailableListing(string fileName) { // Arrange. var expectedListing = FakeListings.CreateAFakeResidentialListing(); var reaXml = File.ReadAllText(FakeDataFolder + fileName); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); // Act. var result = reaXmlTransmorgrifier.Parse(reaXml); // Assert. AssertResidentialListing(result, expectedListing); }
public void GivenTheFileREAResidentialCurrentWithPriceAndDisplayYesButNoPriceView_Parse_ReturnsAListing() { // Arrange. var expectedListing = FakeListings.CreateAFakeResidentialListing(); expectedListing.Pricing.SalePriceText = "$500,000"; var reaXml = File.ReadAllText(FakeDataFolder + "REA-Residential-Current-WithPriceAndDisplayYesButNoPriceView.xml"); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); // Act. var result = reaXmlTransmorgrifier.Parse(reaXml); // Assert. AssertResidentialListing(result, expectedListing); }
public void GivenTheFileREAResidentialCurrentWithASingleAgentName_Parse_ReturnsAResidentialAvailableListing() { // Arrange. var expectedListing = FakeListings.CreateAFakeResidentialListing(); expectedListing.Agents[0].Communications = new List <Communication>(); // Remove all communications for this agent. var reaXml = File.ReadAllText(FakeDataFolder + "REA-Residential-Current-WithASingleAgentName.xml"); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); // Act. var result = reaXmlTransmorgrifier.Parse(reaXml); // Assert. AssertResidentialListing(result, expectedListing); }
public void GivenTheFileREAResidentialCurrentMinimumAndAnExistingListing_Parse_ReturnsAResidentialAvailableListing() { // Arrange. var source = FakeListings.CreateAFakeResidentialListing(); var destination = FakeListings.CreateAFakeResidentialListing(); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); var reaXml = File.ReadAllText(FakeDataFolder + "REA-Residential-Current-Minimum.xml"); // Act. var result = reaXmlTransmorgrifier.Parse(reaXml, source); // Assert. AssertResidentialListing(result, destination); }
[InlineData("REA-Residential-Current-AddressDisplayIsNo.xml", "RICHMOND, Victoria 3121")] // Display == false/no. public void GivenTheFileREAResidentialWithSomeAddressDisplayValues_Parse_ReturnsAResidentialSoldListing(string fileName, string expectedDisplayAddress) { // Arrange. var expectedListing = FakeListings.CreateAFakeResidentialListing(); expectedListing.Address.DisplayAddress = expectedDisplayAddress; var reaXml = File.ReadAllText(FakeDataFolder + fileName); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); // Act. var result = reaXmlTransmorgrifier.Parse(reaXml); // Assert. AssertResidentialListing(result, expectedListing); }
GivenTheFileREAResidentialCurrentWithEmptyImagesAndFloorplans_Parse_ReturnsAResidentialAvailableListing() { // Arrange. var expectedListing = FakeListings.CreateAFakeResidentialListing(); expectedListing.Images = new List <Media>(); expectedListing.FloorPlans = new List <Media>(); var reaXml = File.ReadAllText(FakeDataFolder + "REA-Residential-Current-WithEmptyImagesAndFloorplans.xml"); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); // Act. var result = reaXmlTransmorgrifier.Parse(reaXml); // Assert. AssertResidentialListing(result, expectedListing); }
public void GivenTheFileREAResidentialCurrentBedroomIsStudio_Parse_ReturnsAResidentialAvailableListing() { // Arrange. var expectedListing = FakeListings.CreateAFakeResidentialListing(); expectedListing.PropertyType = PropertyType.Studio; expectedListing.Features.Bedrooms = 0; var reaXml = File.ReadAllText(FakeDataFolder + "REA-Residential-Current-BedroomIsStudio.xml"); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); // Act. var result = reaXmlTransmorgrifier.Parse(reaXml); // Assert. AssertResidentialListing(result, expectedListing); }
GivenTheFileREAResidentialCurrentWithNoModTimeInImagesAndFloorPlans_Parse_ReturnsAResidentialAvailableListing () { // Arrange. var expectedListing = FakeListings.CreateAFakeResidentialListing(); expectedListing.Images.ToList().ForEach(x => x.CreatedOn = null); expectedListing.FloorPlans.ToList().ForEach(x => x.CreatedOn = null); var reaXml = File.ReadAllText(FakeDataFolder + "REA-Residential-Current-WithNoModTimeInImagesAndFloorPlans.xml"); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); // Act. var result = reaXmlTransmorgrifier.Parse(reaXml); // Assert. AssertResidentialListing(result, expectedListing); }
public void GivenTheFileREAResidentialCurrentWithEnsuiteIsTrue_Parse_ReturnsAResidentialAvailableListing( string filename, byte ensuiteCount) { // Arrange. var expectedListing = FakeListings.CreateAFakeResidentialListing(); expectedListing.Features.Ensuites = ensuiteCount; var reaXml = File.ReadAllText(FakeDataFolder + filename); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); // Act. var result = reaXmlTransmorgrifier.Parse(reaXml); // Assert. AssertResidentialListing(result, expectedListing); }
GivenTheFileREAResidentialCurrentWithNoStreetNumberButASubNumber_Parse_ReturnsAResidentialAvailableListing () { // Arrange. var expectedListing = FakeListings.CreateAFakeResidentialListing(); expectedListing.Address.StreetNumber = "2/77a"; expectedListing.Address.DisplayAddress = expectedListing.Address.ToString(); var reaXml = File.ReadAllText(FakeDataFolder + "REA-Residential-Current-WithNoStreetNumberButASubNumber.xml"); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); // Act. var result = reaXmlTransmorgrifier.Parse(reaXml); // Assert. AssertResidentialListing(result, expectedListing); }
public void GivenTheFileREAResidentialCurrentWithLocalFilesForImages_Parse_ReturnsAListing() { // Arrange. var expectedListing = FakeListings.CreateAFakeResidentialListing(); expectedListing.Images[0].Url = "imageM.jpg"; expectedListing.Images[1].Url = "imageA.jpg"; expectedListing.FloorPlans[0].Url = "floorplan1.gif"; expectedListing.FloorPlans[1].Url = "floorplan2.gif"; var reaXml = File.ReadAllText(FakeDataFolder + "REA-Residential-Current-WithLocalFilesForImages.xml"); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); // Act. var result = reaXmlTransmorgrifier.Parse(reaXml); // Assert. AssertResidentialListing(result, expectedListing); }
public void GivenAnExistingListingAndTheResultListingChangesSomething_Parse_ReturnsANewListingWithTheSourceListingWasntChanged() { // Arrange. var source = FakeListings.CreateAFakeResidentialListing(); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); var reaXml = File.ReadAllText(FakeDataFolder + "REA-Residential-Current-Minimum.xml"); // Act. var result = reaXmlTransmorgrifier.Parse(reaXml, source); // Assert. // Change something on the result which shouldn't effect the original source. var newListing = result.Listings.First().Listing; newListing.Description.ShouldBe(source.Description); // Right now, both are the same. newListing.Description = DateTime.UtcNow.ToString(); // Change. newListing.Description.ShouldNotBe(source.Description); // Both should now be different. }
[InlineData("REA-Residential-Current-WithPriceAndDisplayNoAndNoPriceView.xml", false, null)] // Will use the default Sale price value. public void GivenTheFileREAResidentialCurrentSomeVariousDisplayPriceOptions_Parse_ReturnsAListing( string fileName, bool isDefaultSalePriceSet, string expectedSalePriceText) { // Arrange. var expectedListing = FakeListings.CreateAFakeResidentialListing(); expectedListing.Pricing.SalePriceText = expectedSalePriceText; var reaXml = File.ReadAllText($"{FakeDataFolder}{fileName}"); var reaXmlTransmorgrifier = new ReaXmlTransmorgrifier(); if (isDefaultSalePriceSet) { reaXmlTransmorgrifier.DefaultSalePriceTextIfMissing = expectedSalePriceText; } // Act. var result = reaXmlTransmorgrifier.Parse(reaXml); // Assert. AssertResidentialListing(result, expectedListing); }