コード例 #1
0
        public async Task CannotAlwaysDetermineCorrectType()
        {
            SearchDocument doc = new SearchDocument
            {
                ["hotelId"]     = "1",
                ["hotelName"]   = "2015-02-11T12:58:00Z",
                ["location"]    = TestExtensions.CreateDynamicPoint(-73.975403, 40.760586),    // Test that we don't confuse Geo-JSON & complex types.
                ["geoLocation"] = TestExtensions.CreateDynamicGeoPoint(-73.975403, 40.760586), // Test that we don't confuse Geo-JSON & complex types.
                ["rooms"]       = new[]
                {
                    new SearchDocument
                    {
                        ["baseRate"] = double.NaN
                    }
                }
            };

            await VerifyRoundtrip(
                d => (string)d["hotelId"],
                doc,
                new SearchDocument
            {
                ["hotelId"]     = "1",
                ["hotelName"]   = new DateTimeOffset(2015, 2, 11, 12, 58, 0, TimeSpan.Zero),
                ["location"]    = TestExtensions.CreateDynamicPoint(-73.975403, 40.760586),
                ["geoLocation"] = TestExtensions.CreateDynamicGeoPoint(-73.975403, 40.760586),
                ["rooms"]       = new[]
                {
                    new SearchDocument
                    {
                        ["baseRate"] = "NaN"
                    }
                }
            },
                new GetDocumentOptions
            {
                SelectedFields = SelectPopulatedFields(doc)
            });
        }
コード例 #2
0
 public async Task UnselectedFieldsNullStatic() =>
 await VerifyRoundtrip(
     h => h.HotelId,
     new Hotel()
 {
     HotelId            = "2",
     HotelName          = "Countryside Hotel",
     Description        = "Save up to 50% off traditional hotels.  Free WiFi, great location near downtown, full kitchen, washer & dryer, 24/7 support, bowling alley, fitness center and more.",
     DescriptionFr      = "Économisez jusqu'à 50% sur les hôtels traditionnels.  WiFi gratuit, très bien situé près du centre-ville, cuisine complète, laveuse & sécheuse, support 24/7, bowling, centre de fitness et plus encore.",
     Category           = "Budget",
     Tags               = new[] { "24-hour front desk service", "coffee in lobby", "restaurant" },
     ParkingIncluded    = false,
     SmokingAllowed     = true,
     LastRenovationDate = new DateTimeOffset(1999, 9, 6, 0, 0, 0, TimeSpan.Zero),           //aka.ms/sre-codescan/disable
     Rating             = 3,
     Location           = TestExtensions.CreatePoint(-78.940483, 35.904160),
     GeoLocation        = TestExtensions.CreateGeoPoint(-78.940483, 35.904160),
     Address            = new HotelAddress()
     {
         StreetAddress = "6910 Fayetteville Rd",
         City          = "Durham",
         StateProvince = "NC",
         Country       = "USA",
         PostalCode    = "27713"
     },
     Rooms = new[]
     {
         new HotelRoom()
         {
             Description    = "Suite, 1 King Bed (Amenities)",
             DescriptionFr  = "Suite, 1 très grand lit (Services)",
             Type           = "Suite",
             BaseRate       = 2.44,
             BedOptions     = "1 King Bed",
             SleepsCount    = 2,
             SmokingAllowed = true,
             Tags           = new[] { "coffee maker" }
         },
         new HotelRoom()
         {
             Description    = "Budget Room, 1 Queen Bed (Amenities)",
             DescriptionFr  = "Chambre Économique, 1 grand lit (Services)",
             Type           = "Budget Room",
             BaseRate       = 7.69,
             BedOptions     = "1 Queen Bed",
             SleepsCount    = 2,
             SmokingAllowed = false,
             Tags           = new[] { "coffee maker" }
         }
     }
 },
     new Hotel()
 {
     HotelName   = "Countryside Hotel",
     Description = "Save up to 50% off traditional hotels.  Free WiFi, great location near downtown, full kitchen, washer & dryer, 24/7 support, bowling alley, fitness center and more.",
     Address     = new HotelAddress()
     {
         City = "Durham"
     },
     Rooms = new[]
     {
         new HotelRoom()
         {
             BaseRate = 2.44
         },
         new HotelRoom()
         {
             BaseRate = 7.69
         }
     }
 },
     new GetDocumentOptions()
 {
     SelectedFields = new[] { "description", "hotelName", "address/city", "rooms/baseRate" }
 });