示例#1
0
        public async Task PopulateList()
        {
            var search = new ListingSearch
            {
                PropertyType = PropertyType.Apartment,
                City         = "Portland",
                State        = "OR"
            };

            Func <Task <IDatabase> > getDb = async() =>
            {
                var options = services.GetService <IOptions <RedisCacheOptions> >();
                var client  = await ConnectionMultiplexer.ConnectAsync(options.Value.ConfigurationOptions);

                return(client.GetDatabase());
            };

            try
            {
                var serializer = services.GetService <ICacheMemberSerializer>();
                var service    = services.GetService <Services.SeoService>();
                var seo        = await service.GetData <ListingSearch, ListingSearchSeo>(search);

                var db = await getDb();

                var length = await db.ListLengthAsync("seo");

                var subCount = serializer.GetSubsets(search, seo).LongLength;
                Assert.Equal(length, subCount);
            }
            finally
            {
                await Flush();
            }
        }
示例#2
0
        Set()
        {
            var cache = services.GetService <ISetsCache>();

            var search = new ListingSearch
            {
                PropertyType = PropertyType.Apartment,
                Bedrooms     = 2,
                Bathrooms    = 2,
                City         = "Portland",
                State        = "OR",
                Zip          = "97209"
            };

            var sub = new ListingSearchSeo
            {
                Views = 1,
                City  = "Portland",
                State = "OR"
            };

            await cache.SetSub(search, sub);

            return(cache, search, sub);
        }
示例#3
0
        public void Subsets()
        {
            var _serializer = services.GetService <ICacheMemberSerializer>();
            var _cache      = services.GetService <ISetsCache>();

            var search = new ListingSearch
            {
                PropertyType = PropertyType.Apartment,
                Bedrooms     = 3,
                Bathrooms    = 2,
                City         = "Portland",
                State        = "OR",
                Zip          = "97209"
            };

            var m = (city : "Portland", state : "OR", count : 2);

            //[items] should link to stuff, like [apartments] = /places-for-rent/portland/or?PropertyTypes=2
            var title    = $"{m.count} Places for Rent in {m.city}, {m.state} | Rentler";
            var template = "Rentler makes it easy to find houses or apartments for " +
                           $"rent in {m.city}, {m.state}. Unlike many other rental sites, Rentler " +
                           "lets you search [houses], [townhomes], [condos], or [apartments] for " +
                           "rent - all in one place. And our easy to use search can help you find " +
                           "somewhere with just the right amenities, whether you want a " +
                           "[house with a washer and dryer], or an [apartment with a pool].";

            var keys = _serializer.GetSubsets(search);
        }
示例#4
0
        public void CacheSetTest()
        {
            var serializer = new CacheMemberSerializer();
            var search     = new ListingSearch
            {
                PropertyType = PropertyType.Apartment,
                Bedrooms     = 10,
                Bathrooms    = 1
            };

            var set = new string[]
            {
                "2A1###",
                "#A1###",
                "2#1###",
                "##1###",
                "2A####",
                "#A####",
                "2#####",
                "######"
            };

            var res = serializer.GetSubsets(search);

            Assert.Equal(set, res);
        }
示例#5
0
        public void DefaultHashTest()
        {
            var serializer = new CacheMemberSerializer();
            var search     = new ListingSearch();
            var hash       = serializer.Get(search);

            Assert.Equal("######", hash);
        }
示例#6
0
        public void CacheTest()
        {
            var serializer = new CacheMemberSerializer();
            var search     = new ListingSearch
            {
                PropertyType = PropertyType.Any,
                Bedrooms     = 10,
                Bathrooms    = 1,
                City         = "Portland",
                State        = "OR",
                Zip          = "97209"
            };

            var hash = serializer.Get(search);

            Assert.Equal("#A1-Portland-OR-97209", hash);
        }
示例#7
0
        public async Task Fills()
        {
            var search = new ListingSearch
            {
                PropertyType = PropertyType.Apartment,
                City         = "Portland",
                State        = "OR"
            };

            try
            {
                var serializer = services.GetService <ICacheMemberSerializer>();
                var service    = services.GetService <Services.SeoService>();

                //ask for it, this will populate the seo list with keys
                var seo = await service.GetData <ListingSearch, ListingSearchSeo>(search);

                Assert.Null(seo);

                //fill
                var  filler = services.GetService <Services.SeoFiller>();
                long length = await filler.FillAsync();

                while (length > 0)
                {
                    length = await filler.FillAsync();
                }

                //ask agin, this time it will have it.
                seo = await service.GetData <ListingSearch, ListingSearchSeo>(search);

                Assert.NotNull(seo);
                Assert.Equal("Portland", seo.City);
            }
            finally
            {
                await Flush();
            }
        }