/// <summary>
 /// 计算餐厅是否可以送餐
 /// </summary>
 /// <param name="status">餐厅营业状态</param>
 /// <param name="deliverTime">餐厅可以送餐时间</param>
 /// <returns>true表示可以送餐,false不可以送餐</returns>
 public Boolean GetDeliveryStatus(BusinessStatus status, DeliveryTime[] deliverTime)
 {
     if (status == BusinessStatus.Close)
     {
         return false;
     }
     var now = DateTime.Now;
     return deliverTime.Count(d => now > d.Start.GetDateTime() && now <= d.End.GetDateTime()) > 0;
 }
        public void OpenStatusInDeliveryTimeTest()
        {
            var deliveryTime = new DeliveryTime[1] 
            { 
                new DeliveryTime(new Time(DateTime.Now.AddHours(-3).Hour,0),new Time(DateTime.Now.AddHours(3).Hour,0))
            };

            var service = new DeliveryStatusService();

            var result = service.GetDeliveryStatus(BusinessStatus.Open, deliveryTime);

            Assert.IsTrue(result);
        }
        public void CloseStatusDeliveryStatusTest()
        {
            var deliveryTime = new DeliveryTime[2] 
            { 
                new DeliveryTime(new Time(12,0),new Time(13,0)),
                new DeliveryTime(new Time(18,0),new Time(19,0))
            };

            var service = new DeliveryStatusService();

            var result = service.GetDeliveryStatus(BusinessStatus.Close, deliveryTime);

            Assert.IsFalse(result);
        }
        public static Model.Supplier Create(BusinessTime businessTime = null, Coordinates coordinates = null, DeliveryTime[] deliverytime = null)
        {
            var supplier = new Model.Supplier()
            {
                Name = "好美味餐厅",
                Address = "北京朝阳区三间房",
                Tel = "18500191543",
                BusinessTime = businessTime,
                Coordinates = coordinates,
                DeliveryTime = deliverytime,
            };

            return supplier;
        }
        public static Model.Supplier Create()
        {
            var coordinates = new Coordinates("133.15888", "4565566.8879879");

            var deliverytime = new DeliveryTime[2] { 
                new DeliveryTime(new Time(12,0),new Time(14,0)),
                new DeliveryTime(new Time(17,0),new Time(19,0))
            };

            var businessTime = new BusinessTime(new Time(10, 0), new Time(22, 0));

            return Create(businessTime, coordinates, deliverytime);
        }