public void IntersectionWith_InterseccionDeFechasYDias()
        {
            Schedule lInterval1 = new Schedule() { ActiveUntil = new DateTime(2016, 2, 20), ActiveFrom = new DateTime(2016, 2, 2) };
            Schedule lInterval2 = new Schedule() { ActiveUntil = new DateTime(2016, 2, 26), ActiveFrom = new DateTime(2016, 2, 18) };

            Day lDay1 = new Day() { Id = 0, Value = Days.Domingo };
            Day lDay2 = new Day() { Id = 1, Value = Days.Lunes };
            Day lDay3 = new Day() { Id = 2, Value = Days.Martes };

            lInterval1.AddDay(lDay1);
            lInterval1.AddDay(lDay2);
            lInterval2.AddDay(lDay3);
            lInterval2.AddDay(lDay1);

            TimeSpan time1 = new TimeSpan(8, 0, 0);
            TimeSpan time2 = new TimeSpan(12, 0, 0);
            TimeSpan time3 = new TimeSpan(18, 0, 0);
            TimeSpan time4 = new TimeSpan(21, 0, 0);

            ScheduleEntry lTimeInterval1 = new ScheduleEntry() { End = time2, Start = time1 }; //8 a 12
            ScheduleEntry lTimeInterval2 = new ScheduleEntry() { End = time3, Start = time2 };//12 a 18
            ScheduleEntry lTimeInterval3 = new ScheduleEntry() { End = time4, Start = time3 };//18 a 21

            lInterval1.AddTimeInterval(lTimeInterval1);
            lInterval1.AddTimeInterval(lTimeInterval2);
            lInterval2.AddTimeInterval(lTimeInterval3);

            bool lResult = lInterval1.IntersectsWith(lInterval2);

            Assert.IsFalse(lResult);
        }
示例#2
0
        public void ActiveForDate_IsActive()
        {
            Banner lBanner = new Banner() { Name = "Informacion deportiva", Description = "Noticias del ámbito deportivo nacional de distintas fuentes" };

            Schedule lInterval = new Schedule() { Name="Mes de febrero, de lunes a viernes por la mañana",ActiveUntil = new DateTime(2016, 2, 29), ActiveFrom = new DateTime(2016, 2, 1) };

            Day lDay1 = new Day() { Id = 1, Value = Days.Lunes };
            Day lDay2 = new Day() { Id = 2, Value = Days.Martes };
            Day lDay3 = new Day() { Id = 3, Value = Days.Miercoles };
            Day lDay4 = new Day() { Id = 4, Value = Days.Jueves };
            Day lDay5 = new Day() { Id = 5, Value = Days.Viernes };

            lInterval.AddDay(lDay1);
            lInterval.AddDay(lDay2);
            lInterval.AddDay(lDay3);
            lInterval.AddDay(lDay4);
            lInterval.AddDay(lDay5);

            TimeSpan time1 = new TimeSpan(8, 0, 0);
            TimeSpan time2 = new TimeSpan(12, 0, 0);

            ScheduleEntry lTimeInterval = new ScheduleEntry() { End = time2, Start = time1 };

            lInterval.AddTimeInterval(lTimeInterval);

            lBanner.AddSchedule(DomainServiceLocator.Resolve<IScheduleChecker>(), lInterval);

            DateTime lDate = new DateTime(2016, 2, 4,20,0,0);

            bool lResult = lBanner.IsActiveAt(DomainServiceLocator.Resolve<IScheduleChecker>(), lDate);

            Assert.IsFalse(lResult);
        }
示例#3
0
        public void ActiveForDate_IsActive()
        {
            Campaign lCampaign = new Campaign() { Name = "Venta de cactus",Description="Publicidad para la venta de cactus para el vivero XX" };

            Schedule lInterval = new Schedule() {Name="Miércoles y Jueves de la primera quincena de febrero", ActiveUntil = new DateTime(2016, 2, 15), ActiveFrom = new DateTime(2016, 2, 1) };

            Day lDay1 = new Day() { Id = 4, Value = Days.Miercoles };
            Day lDay2 = new Day() { Id = 5, Value = Days.Jueves };

            lInterval.AddDay(lDay1);
            lInterval.AddDay(lDay2);

            TimeSpan time1 = new TimeSpan(18, 0, 0);
            TimeSpan time2 = new TimeSpan(21, 0, 0);

            ScheduleEntry lTimeInterval = new ScheduleEntry() { End = time2, Start = time1 };

            lInterval.AddTimeInterval(lTimeInterval);

            lCampaign.AddSchedule(DomainServiceLocator.Resolve<IScheduleChecker>(), lInterval);

            DateTime lDate = new DateTime(2016, 2, 3,19,0,0);

            bool lResult = lCampaign.IsActiveAt(DomainServiceLocator.Resolve<IScheduleChecker>(), lDate);

            //  Assert.IsTrue(lResult);





        /*    var serv1 = DomainServiceLocator.Resolve<IScheduleChecker>();
            var serv2 = DomainServiceLocator.Resolve<IScheduleChecker>();
            var serv3 = BusinessServiceLocator.Resolve<>();
            var serv4 = BusinessServiceLocator.Resolve<DateIntervalService>();



            Assert.AreSame(serv1, serv2);
            Assert.AreNotSame(serv3, serv4);*/




        }