Beispiel #1
0
 private static void AssertRentalListing(ParsedResult result,
                                         RentalListing expectedListing)
 {
     result.ShouldNotBeNull();
     result.Listings.Count.ShouldBe(1);
     result.Errors.Count.ShouldBe(0);
     result.UnhandledData.Count.ShouldBe(0);
     RentalListingAssertHelpers.AssertRuralListing(result.Listings.First().Listing as RentalListing,
                                                   expectedListing);
 }
Beispiel #2
0
            public void GivenSomeValidJson_Parse_ReturnsAListing(Type listingType,
                                                                 int listingCount)
            {
                // Arrange.
                var existingListing = CreateListings(listingType, listingCount);
                var json            = JsonConvertHelpers.SerializeObject(existingListing);
                var transmorgrifier = new JsonTransmorgrifier();

                // Act.
                var result = transmorgrifier.Parse(json);

                // Assert.
                result.Listings.Count.ShouldBe(listingCount);
                result.UnhandledData.Count.ShouldBe(0);
                result.Errors.Count.ShouldBe(0);

                for (var i = 0; i < result.Listings.Count; i++)
                {
                    if (listingType == typeof(ResidentialListing))
                    {
                        ResidentialListingAssertHelpers.AssertResidentialListing(
                            (ResidentialListing)result.Listings[i].Listing,
                            (ResidentialListing)existingListing[i]);
                    }
                    else if (listingType == typeof(RentalListing))
                    {
                        RentalListingAssertHelpers.AssertRuralListing(
                            (RentalListing)result.Listings[i].Listing,
                            (RentalListing)existingListing[i]);
                    }
                    else if (listingType == typeof(LandListing))
                    {
                        LandListingAssertHelpers.AssertLandListing(
                            (LandListing)result.Listings[i].Listing,
                            (LandListing)existingListing[i]);
                    }
                    else if (listingType == typeof(RuralListing))
                    {
                        RuralListingAssertHelpers.AssertRuralListing(
                            (RuralListing)result.Listings[i].Listing,
                            (RuralListing)existingListing[i]);
                    }
                    else
                    {
                        throw new Exception($"Failed to assert the suggested type: '{listingType}'.");
                    }
                }
            }