Beispiel #1
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);
        }
Beispiel #2
0
        public void DefaultHashTest()
        {
            var serializer = new CacheMemberSerializer();
            var search     = new ListingSearch();
            var hash       = serializer.Get(search);

            Assert.Equal("######", hash);
        }
Beispiel #3
0
        public void ParsesOnlyStrings()
        {
            var serializer = new CacheMemberSerializer();
            var key        = "Sandy-UT";
            var item       = serializer.Parse <StringsOnlySearch>(key);

            Assert.Equal("Sandy", item.City);
            Assert.Equal("UT", item.State);
        }
Beispiel #4
0
        public void ParsesOnlyInts()
        {
            var serializer = new CacheMemberSerializer();
            var key        = "123";
            var item       = serializer.Parse <IntsOnlySearch>(key);

            Assert.Equal(1, item.Beds);
            Assert.Equal(2, item.Baths);
            Assert.Equal(3, (int)item.PropertyType);
        }
Beispiel #5
0
        public void Parses()
        {
            var serializer = new CacheMemberSerializer();
            var key        = "#a1-Portland-OR-97209";
            var item       = serializer.Parse <ListingSearch>(key);

            Assert.Equal(0, (int)item.PropertyType);
            Assert.Equal(10, item.Bedrooms);
            Assert.Equal(1, item.Bathrooms);
            Assert.Equal("Portland", item.City);
            Assert.Equal("OR", item.State);
            Assert.Equal("97209", item.Zip);
        }
Beispiel #6
0
        public void CorrectlyParsesNullableEnums()
        {
            var serializer = new CacheMemberSerializer();
            var search     = new SomeSearchNullable
            {
                PropertyType = PropertyType.Apartment,
                Bedrooms     = 3,
                Bathrooms    = 2
            };

            var key = serializer.Get(search);

            Assert.Equal("232", key);
        }
Beispiel #7
0
        public void CorrectlyDelimitsMixedTypes()
        {
            //should be 1-Portland-2-OR-5
            var serializer = new CacheMemberSerializer();
            var search     = new SomeSearch
            {
                PropertyType = PropertyType.Apartment,
                City         = "Portland",
                State        = "OR",
                Beds         = 3,
                Baths        = 2
            };

            var key = serializer.Get(search);

            Assert.Equal("2-Portland-2-OR-3", key);
        }
Beispiel #8
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);
        }