protected IList <Listing> CreateListings(Type listingType,
                                                 int numberOfFakeListings)
        {
            if (listingType == typeof(ResidentialListing))
            {
                return(FakeListings.CreateFakeListings <ResidentialListing>(numberOfFakeListings)
                       .Cast <Listing>()
                       .ToList());
            }

            if (listingType == typeof(RentalListing))
            {
                return(FakeListings.CreateFakeListings <RentalListing>(numberOfFakeListings)
                       .Cast <Listing>()
                       .ToList());
            }

            if (listingType == typeof(LandListing))
            {
                return(FakeListings.CreateFakeListings <LandListing>(numberOfFakeListings)
                       .Cast <Listing>()
                       .ToList());
            }

            if (listingType == typeof(RuralListing))
            {
                return(FakeListings.CreateFakeListings <RuralListing>(numberOfFakeListings)
                       .Cast <Listing>()
                       .ToList());
            }

            throw new Exception($"Failed to assert the suggested type: '{listingType}'.");
        }
Пример #2
0
        [InlineData(50, 10, 3, 7)] // #50 is not included.
        public void GivenTheRequirementToCreateSomeFakeListings_CreateFakeListings_ReturnsSomeListings(int numberOfListings,
                                                                                                       int numberOfActive,
                                                                                                       int numberOfSold,
                                                                                                       int numberOfRemoved)
        {
            // Arrange
            const int defaultNumberOfFixedListings = 20;

            //Act.
            var listings = FakeListings.CreateFakeListings <ResidentialListing>(numberOfListings)
                           .Take(defaultNumberOfFixedListings)
                           .ToArray();

            // Assert.
            if (numberOfListings > defaultNumberOfFixedListings)
            {
                listings.Length.ShouldBe(defaultNumberOfFixedListings);
            }
            else
            {
                listings.Length.ShouldBe(numberOfListings);
            }

            listings.Count(x => x.StatusType == StatusType.Available).ShouldBe(numberOfActive);
            listings.Count(x => x.StatusType == StatusType.Sold).ShouldBe(numberOfSold);
            listings.Count(x => x.StatusType == StatusType.Leased).ShouldBe(0); // Can never have a leased residential listing.
            listings.Count(x => x.StatusType == StatusType.Removed).ShouldBe(numberOfRemoved);
        }
Пример #3
0
            public void GivenSomeJsonOfAnArrayOfListings_DeserializeObject_ReturnsACollectionOfListings()
            {
                // Arrange.
                var listings = FakeListings.CreateFakeListings <ResidentialListing>();
                var json     = listings.SerializeObject();

                // Act.
                var convertedListings = JsonConvertHelpers.DeserializeObjects(json);

                // Assert.
                convertedListings.Count().ShouldBe(listings.Count());
            }
Пример #4
0
            public void GivenSomeListings_SerializeObject_ReturnsSomeJson()
            {
                // Arrange.
                var listings = FakeListings.CreateFakeListings <ResidentialListing>();

                // Act.
                var json = listings.SerializeObject();

                // Assert.
                json.ShouldStartWith("[");
                json.ShouldEndWith("]");
                json.Length.ShouldBeGreaterThan(2);
            }