public void TestHotelbedsGetDestinationsAsyncWithNullParameter() { Hotelbeds hotelbeds = new Hotelbeds(Hotelbeds.DEFAULT_KEY, Hotelbeds.DEFAULT_SECRET); var destinations = hotelbeds.GetDestinationsAsync(null).Result; Assert.IsNotNull(destinations); }
public void TestHotelbedsGetDestinationsAsyncWithEmptyParameter() { Hotelbeds hotelbeds = new Hotelbeds(Hotelbeds.DEFAULT_KEY, Hotelbeds.DEFAULT_SECRET); var destinations = hotelbeds.GetDestinationsAsync(new List <Country>()).Result; Assert.IsNotNull(destinations); Assert.IsTrue(destinations.Length > 0); }
public void TestHotelbedsGetCountriesAsyncWithOneParameter() { string code = "RU"; Hotelbeds hotelbeds = new Hotelbeds(Hotelbeds.DEFAULT_KEY, Hotelbeds.DEFAULT_SECRET); var countries = hotelbeds.GetCountriesAsync(code).Result; Assert.IsNotNull(countries); Assert.AreEqual <int>(countries.Length, 1); Assert.AreEqual <string>(countries[0].Code, "RU"); Assert.AreEqual <string>(countries[0].Name, "RUSSIA"); }
public void TestHotelbedsGetCountriesAsyncWithoutParameters() { Hotelbeds hotelbeds = new Hotelbeds(Hotelbeds.DEFAULT_KEY, Hotelbeds.DEFAULT_SECRET); var countries = hotelbeds.GetCountriesAsync().Result; Assert.IsNotNull(countries); Assert.IsTrue(countries.Length > 0); var russia = countries.First(c => c.Code == "RU"); Assert.IsNotNull(russia); Assert.AreEqual <string>(russia.Name, "RUSSIA"); }
public void GetHotelsByDestinationTest() { Hotelbeds hotelbeds = new Hotelbeds(Hotelbeds.DEFAULT_KEY, Hotelbeds.DEFAULT_SECRET); var destination = new Destination { Name = "St Petersburg", Code = "LED" }; var hotels = hotelbeds.GetHotelsByDestination(destination).Result; Assert.IsNotNull(hotels); Assert.IsTrue(hotels.Length > 0); }
public void PostHotelsByGPSRadiusAsyncTest() { Hotelbeds hotelbeds = new Hotelbeds(Hotelbeds.DEFAULT_KEY, Hotelbeds.DEFAULT_SECRET); Hotel[] hotels = { new Hotel { Code = "219199" } }; Accomodation[] accomodations = { new Accomodation { Guests = new Person[] { new Person { Age = 19, Name = "Nasty", Gender = Gender.Female, Type = PersonType.Adult } }, RoomsCount = 1 } }; var hotel_rooms = hotelbeds.PostHotelsByGPSRadiusAsync( hotels, TestUtils.From, TestUtils.To, accomodations, new Location { Longitude = 30.3585972f, Attitude = 59.9314033f }, 0.8f ) .Result; Assert.IsNotNull(hotel_rooms); }
public void TestHotelbedsGetCountriesAsyncWithSeveralParameters() { string code1 = "RU"; string code2 = "UK"; Hotelbeds hotelbeds = new Hotelbeds(Hotelbeds.DEFAULT_KEY, Hotelbeds.DEFAULT_SECRET); var countries = hotelbeds.GetCountriesAsync(code1, code2).Result; Assert.IsNotNull(countries); Assert.AreEqual <int>(countries.Length, 2); var russia = countries.First(c => c.Code == "RU"); var uk = countries.First(c => c.Code == "UK"); Assert.IsNotNull(russia); Assert.IsNotNull(uk); Assert.AreEqual(russia.Name, "RUSSIA"); Assert.AreEqual(uk.Name, "UNITED KINGDOM"); }
public void TestHotelbedsGetDestinationsAsyncWithOneParameter() { Hotelbeds hotelbeds = new Hotelbeds(Hotelbeds.DEFAULT_KEY, Hotelbeds.DEFAULT_SECRET); Country[] countries = { new Country { Code = "RU", Name = "RUSSIA" } }; var destinations = hotelbeds.GetDestinationsAsync(countries).Result; Assert.IsNotNull(destinations); var spb = destinations.First(c => c.Code == "LED"); Assert.IsNotNull(spb); Assert.IsTrue(spb.Name.Contains("Petersburg")); }
public void PostHotelsAsyncTest() { Hotelbeds hotelbeds = new Hotelbeds(Hotelbeds.DEFAULT_KEY, Hotelbeds.DEFAULT_SECRET); Hotel[] hotels = { new Hotel { Code = "219199" } }; Accomodation[] accomodations = { new Accomodation { Guests = new Person[] { new Person { Age = 19, Name = "Nasty", Gender = Gender.Female, Type = PersonType.Adult } }, RoomsCount = 1 } }; var hotel_rooms = hotelbeds.PostHotelsAsync(hotels, TestUtils.From, TestUtils.To, accomodations) .Result; Assert.IsNotNull(hotel_rooms); }
public async Task <Adventure> GetResultAsync() { if (options == null || options.StartDate == null || options.FinishDate == null || options.Persons == null || options.AvailableHotels == null) { return(null); } var hotelbeds = new Hotelbeds(Hotelbeds.DEFAULT_KEY, Hotelbeds.DEFAULT_SECRET); var checkIn = options.StartDate.AddHours(options.AfterArrivalRelaxTime); var checkOut = options.FinishDate.AddHours(options.BeforeDepartureRelaxTime); var h = options.Hotel; if (h == null) { h = options.AvailableHotels.First(); } var rooms = await hotelbeds.PostHotelsAsync ( new Hotel[1] { h }, checkIn, checkOut, new Accomodation[1] { new Accomodation { Guests = options.Persons, RoomsCount = options.CountOfRooms } } ); if (rooms == null) { return(null); } var r = rooms.FirstOrDefault(); if (r == null) { return(null); } var occupancies = new Occupancy[1] { new Occupancy { Code = r.Code, Name = r.Name, CheckIn = checkIn, CheckOut = checkOut, RoomsCount = r.RoomsCount, Capacity = r.AdultsNumber + r.ChildrenNumber, OrderLink = r.OrderLink, Cost = r.Cost, Currency = r.Currency, Guests = options.Persons } }; h.Occupancies = occupancies; var weather = await new Openweathermap(Openweathermap.DEFAULT_KEY) .GetWeatherAsync(options.Destination.Location, (uint)DateTime.Now.AddDays(10).Subtract(options.StartDate).Days); var trips = await options.GetAvailableTripsAsync(); if (trips == null) { return(null); } var trip = trips.First(); return(new Adventure { Attractions = options.Attractions, Home = options.Origin, Destination = options.Destination, StartDate = options.StartDate, FinishDate = options.FinishDate, Hotels = new Hotel[1] { h }, Persons = options.Persons, Tickets = new Ticket[2] { trip.There, trip.Back }, Weather = weather, Currency = options.Currency }); }