예제 #1
0
        public static LandListing CreateAFakeLandListing(string id = "Land-Current-ABCD1234",
                                                         PropertyType propertyType = PropertyType.House)
        {
            var listing = new LandListing
            {
                Id = id
            };

            FakeCommonListingHelpers.SetCommonListingData(listing);
            listing.Address.StreetNumber = "LOT 12/39";
            listing.Features.Bedrooms    = 0;
            listing.Features.Bathrooms   = 0;
            listing.Features.Ensuites    = 0;
            listing.Features.CarParking  = new CarParking();

            FakeCommonListingHelpers.SetSalePrice(listing);
            SetLandEstate(listing);
            listing.AuctionOn    = new DateTime(2009, 1, 24, 12, 30, 00, DateTimeKind.Utc);
            listing.CategoryType = CategoryType.Residential;
            listing.CouncilRates = "$2000 per month";

            listing.Features.Tags.Remove("houseAndLandPackage");
            listing.Features.Tags.Remove("isANewConstruction");
            listing.Features.Tags.Remove("hotWaterService-gas");
            listing.Features.Tags.Remove("heating-other");
            listing.Features.Tags.Remove("balcony");
            listing.Features.Tags.Remove("shed");
            listing.Features.Tags.Remove("courtyard");

            return(listing);
        }
예제 #2
0
        public static RentalListing CreateAFakeRentalListing(string id = "Rental-Current-ABCD1234",
                                                             PropertyType propertyType = PropertyType.House)
        {
            var listing = new RentalListing()
            {
                Id = id
            };

            FakeCommonListingHelpers.SetCommonListingData(listing);
            listing.Features.Tags.Remove("houseAndLandPackage");

            FakeCommonListingHelpers.SetBuildingDetails(listing);
            SetRentalPricing(listing);

            listing.AvailableOn  = new DateTime(2009, 1, 26, 12, 30, 00, DateTimeKind.Utc);
            listing.PropertyType = propertyType;

            return(listing);
        }
예제 #3
0
        public static ResidentialListing CreateAFakeResidentialListing(string id                 = "Residential-Current-ABCD1234",
                                                                       StatusType statusType     = StatusType.Available,
                                                                       PropertyType propertyType = PropertyType.House)
        {
            var listing = new ResidentialListing
            {
                Id = id
            };

            FakeCommonListingHelpers.SetCommonListingData(listing, statusType: statusType);
            FakeCommonListingHelpers.SetBuildingDetails(listing);
            FakeCommonListingHelpers.SetSalePrice(listing);

            listing.PropertyType = propertyType;
            listing.AuctionOn    = new DateTime(2009, 2, 4, 18, 30, 0, DateTimeKind.Utc);
            listing.CouncilRates = "$2000 per month";

            return(listing);
        }
예제 #4
0
        public static RuralListing CreateAFakeRuralListing(string id = "Rural-Current-ABCD1234",
                                                           PropertyType propertyType = PropertyType.House)
        {
            var listing = new RuralListing()
            {
                Id = id
            };

            FakeCommonListingHelpers.SetCommonListingData(listing);
            listing.Features.Tags.Remove("houseAndLandPackage");
            listing.Features.Tags.Remove("isANewConstruction");

            FakeCommonListingHelpers.SetBuildingDetails(listing);
            FakeCommonListingHelpers.SetSalePrice(listing);

            SetRuralFeatures(listing);

            listing.AuctionOn    = new DateTime(2009, 1, 24, 14, 30, 00, DateTimeKind.Utc);
            listing.CategoryType = Core.Rural.CategoryType.Cropping;
            listing.CouncilRates = "$2,200 per annum";

            return(listing);
        }
예제 #5
0
        public static T CreateAFakeListing <T>(string id             = null,
                                               StatusType statusType = StatusType.Unknown) where T : Listing, new()
        {
            // NBuilder fails to return the last enum type, here :(
            // var statusType = GetRandom.Enumeration<StatusType>();

            var values      = EnumHelper.GetValues(typeof(StatusType));
            var randomIndex = _random.Next(0, values.Length);

            if (statusType == StatusType.Unknown)
            {
                statusType = (StatusType)values.GetValue(randomIndex);
                if (statusType == StatusType.Unknown)
                {
                    statusType = StatusType.Available;
                }
            }

            var createdOn = GetRandom.DateTime(DateTime.UtcNow.AddDays(-7), DateTime.UtcNow.AddDays(-1));

            createdOn = DateTime.SpecifyKind(createdOn, DateTimeKind.Utc);

            var updatedOn = GetRandom.DateTimeFrom(DateTime.UtcNow.AddDays(-1));

            updatedOn = DateTime.SpecifyKind(updatedOn, DateTimeKind.Utc);

            // Yep, copied from FakeCommonListingHelpers because that is method is (correctly) internal :/
            var listing = Builder <T> .CreateNew()
                          .With(x => x.Id, id ?? $"listing-{GetRandom.Int()}")
                          .With(x => x.AgencyId, $"Agency-{GetRandom.String(6)}")
                          .With(x => x.StatusType, statusType)           // NOTE: SourceStatus is defined AFTER this instance is created.
                          .With(x => x.Address, FakeAddress.CreateAFakeAddress())
                          .With(x => x.Agents, FakeAgent.CreateFakeAgents())
                          .With(x => x.LandDetails, CreateLandDetails())
                          .With(x => x.Features, CreateFeatures())
                          .With(x => x.CreatedOn, createdOn)
                          .With(x => x.UpdatedOn, updatedOn)
                          .With(x => x.Images, CreateMedia(GetRandom.Int(1, 21)))
                          .With(x => x.FloorPlans, CreateMedia(GetRandom.Int(0, 3)))
                          .With(x => x.Documents, CreateMedia(GetRandom.Int(0, 4)))
                          .With(x => x.Inspections, CreateInspections(GetRandom.Int(0, 4)))
                          .With(x => x.Videos, CreateMedia(GetRandom.Int(0, 3), "application/octet-stream"))
                          .Do(x =>
            {
                if (x is ResidentialListing residentialListing)
                {
                    // Skip first enumeration -> Unknown.
                    var index = GetRandom.Int(1, Enum.GetValues(typeof(PropertyType)).Length);
                    residentialListing.PropertyType    = (PropertyType)Enum.GetValues(typeof(PropertyType)).GetValue(index);
                    residentialListing.AuctionOn       = CreateDateTimeAsUtcKind(100);
                    residentialListing.BuildingDetails = CreateBuildingDetails();
                    residentialListing.Pricing         = CreateSalePricing(residentialListing.StatusType);
                }
                else if (x is RentalListing rentalListing)
                {
                    var index = GetRandom.Int(1, Enum.GetValues(typeof(PropertyType)).Length);
                    rentalListing.PropertyType    = (PropertyType)Enum.GetValues(typeof(PropertyType)).GetValue(index);
                    rentalListing.AvailableOn     = CreateDateTimeAsUtcKind(1000);
                    rentalListing.BuildingDetails = CreateBuildingDetails();
                    rentalListing.Pricing         = CreateRentalPricing(rentalListing.StatusType);
                }
                else if (x is LandListing landListing)
                {
                    var index = GetRandom.Int(1, Enum.GetValues(typeof(CategoryType)).Length);
                    landListing.CategoryType = (CategoryType)Enum.GetValues(typeof(CategoryType)).GetValue(index);
                    landListing.AuctionOn    = CreateDateTimeAsUtcKind(100);
                    landListing.Estate       = Builder <LandEstate> .CreateNew().Build();
                    landListing.Pricing      = CreateSalePricing(landListing.StatusType);
                }
                else if (x is RuralListing ruralListing)
                {
                    var index = GetRandom.Int(1, Enum.GetValues(typeof(Core.Rural.CategoryType)).Length);
                    ruralListing.CategoryType    = (Core.Rural.CategoryType)Enum.GetValues(typeof(Core.Rural.CategoryType)).GetValue(index);
                    ruralListing.AuctionOn       = CreateDateTimeAsUtcKind(100);
                    ruralListing.Pricing         = CreateSalePricing(ruralListing.StatusType);
                    ruralListing.RuralFeatures   = Builder <RuralFeatures> .CreateNew().Build();
                    ruralListing.BuildingDetails = CreateBuildingDetails();
                }
            }).Build();

            FakeCommonListingHelpers.SetSourceStatus(listing);

            return(listing);
        }