public void Test()
        {
            //setup
            RateTest test = new RateTest();

            //act
            test.Run();

            //assert
        }
Beispiel #2
0
        public void Test()
        {
            //setup
            RateTest test = new RateTest();

            //act
            test.Run();

            //assert
        }
        static void T()
        {
            string[] hotelIds = File.ReadAllLines("c:\\hotelId.txt");
            foreach (string id in hotelIds)
            {
                if (string.IsNullOrEmpty(id))
                {
                    continue;
                }

                bool showed = false;
                var  r1     = new HotelDetailTest();
                r1.Condition = new HotelDetailCondition()
                {
                    ArrivalDate   = DateTime.Now.Date.AddDays(4),
                    DepartureDate = DateTime.Now.Date.AddDays(6),
                    HotelIds      = id,
                };
                BaseResponse <HotelList> detail = r1.Test();
                if (detail.Code == "0" && detail.Result != null)
                {
                    var hs = detail.Result.Hotels;
                    if (hs != null)
                    {
                        foreach (var h in hs)
                        {
                            if (h.Rooms != null)
                            {
                                var r2 = new InventoryTest();
                                r2.Condition = new InventoryCondition()
                                {
                                    StartDate = DateTime.Now.Date.AddDays(4),
                                    EndDate   = DateTime.Now.Date.AddDays(6),
                                    HotelIds  = id
                                };

                                var  res2 = r2.Test();
                                bool ok   = true;
                                if (res2.Result.Inventories != null)
                                {
                                    foreach (var inv in res2.Result.Inventories)
                                    {
                                        ok = ok && inv.Status;
                                    }
                                    //Console.WriteLine("\t\tinv: " + ok);
                                }

                                var r3 = new RateTest();
                                r3.Condition = new RateCondition()
                                {
                                    StartDate   = DateTime.Now.Date.AddDays(4),
                                    EndDate     = DateTime.Now.Date.AddDays(6),
                                    HotelIds    = id,
                                    PaymentType = EnumPaymentType.Prepay
                                };
                                var res3 = r3.Test();
                                if (res3.Result.Rates != null)
                                {
                                    //Console.WriteLine("\t\trate: " + res3.Result.Rates.Length);
                                }


                                foreach (var r in h.Rooms)
                                {
                                    if (r.RatePlans != null)
                                    {
                                        foreach (var rp in r.RatePlans)
                                        {
                                            if (rp.PaymentType == EnumPaymentType.Prepay)
                                            {
                                                int invCount = 0;
                                                if (res2.Result.Inventories != null)
                                                {
                                                    foreach (var inv in res2.Result.Inventories)
                                                    {
                                                        if (inv.RoomTypeId == r.RoomId)
                                                        {
                                                            invCount = inv.Status ? (inv.OverBooking == 0 ? 999 : inv.Amount) : -1;
                                                        }
                                                    }
                                                }

                                                decimal price = 0M;
                                                if (res3.Result.Rates != null)
                                                {
                                                    foreach (var rate in res3.Result.Rates)
                                                    {
                                                        if (rate.Status && rate.StartDate <= r2.Condition.StartDate && rate.EndDate >= r2.Condition.EndDate)
                                                        {
                                                            price = rate.MemberCost;
                                                        }
                                                    }
                                                }

                                                Console.WriteLine(string.Format("{0} {1} {2} {3} {4}", h.HotelId, r.RoomId, rp.RatePlanId, invCount, price));


                                                showed = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (!showed)
                {
                    Console.WriteLine("===> " + id);
                }
            }
        }