Пример #1
0
        public void RoutineCanBeAdded_Order_is_correct()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);

            wdc.AddRoutine(allRoutines[5]);
            wdc.AddRoutine(allRoutines[1]);
            wdc.AddRoutine(allRoutines[2]);
            wdc.AddRoutine(allRoutines[4]);
            wdc.AddRoutine(allRoutines[3]);

            string sortOrder = "";

            foreach (var item in wdc.GetRoutineDefinitions())
            {
                sortOrder += item.Name;
            }

            Assert.AreEqual(wdc.GetRoutineDefinitions()[0], allRoutines[5], sortOrder);
            Assert.AreEqual(wdc.GetRoutineDefinitions()[1], allRoutines[1], sortOrder);
            Assert.AreEqual(wdc.GetRoutineDefinitions()[2], allRoutines[2], sortOrder);
            Assert.AreEqual(wdc.GetRoutineDefinitions()[3], allRoutines[4], sortOrder);
            Assert.AreEqual(wdc.GetRoutineDefinitions()[4], allRoutines[3], sortOrder);
        }
Пример #2
0
        public void ControllerCanBeLoaded()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            new WashingDayEditorController(wd, allRoutines, ac);
            Assert.Pass();
        }
Пример #3
0
        public void AddRoutine_CheckNullArgument()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);

            Assert.Throws <System.ArgumentNullException>(delegate { wdc.AddRoutine(null); });
        }
Пример #4
0
        public WashDayInstance(WashingDayDefinition definition, WashingDayInstance instance, HairAppBl.Interfaces.IHairBl hairbl)
        {
            InitializeComponent();

            mInstance   = instance;
            mDefinition = definition;
            mHairbl     = hairbl;

            InitFields();
        }
Пример #5
0
        public void AddWashDay()
        {
            var def = new WashingDayDefinition();

            def.ID = Guid.NewGuid().ToString();
            var contr  = new WashingDayEditorController(def, App.MainSession.GetAllDefinitions(), this.mAlarmController);
            var editor = new WashDayEditor(mMainSessionController, contr, true, mHairbl);

            Navigation.PushAsync(editor);
        }
Пример #6
0
        public void RoutineCanBeAdded()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);
            var r = allRoutines[0];

            wdc.AddRoutine(r);
            Assert.True(wdc.GetRoutineDefinitions().Contains(r));
            Assert.False(wdc.GetUnusedRoutineDefinitions().Contains(r));
        }
Пример #7
0
        public void GetWashingDayById_GetIsWorking()
        {
            MainSessionController c = new MainSessionController(new Dictionary <string, object>());

            c.Init();
            var days = c.GetAllWashingDays();
            var wdd  = new WashingDayDefinition();

            wdd.ID = "Foo";
            days.Add(wdd);

            Assert.AreEqual(wdd, c.GetWashingDayById("Foo"));
        }
Пример #8
0
        public void MoveUp()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);
            var unused = wdc.GetUnusedRoutineDefinitions();

            wdc.AddRoutine(unused[0]);
            wdc.AddRoutine(unused[1]);
            wdc.AddRoutine(unused[2]);
            wdc.MoveUp(unused[1]);
            Assert.AreEqual(wdc.GetRoutineDefinitions()[0], unused[1]);
        }
Пример #9
0
        public void Monthly_FirstSaturday_MonthlyPeriod_1()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);

            wdc.GetModel().Scheduled.Type = ScheduleDefinition.ScheduleType.Monthly;
            wdc.GetModel().Scheduled.MonthlyPeriod.Period = 1;
            wdc.GetModel().Scheduled.StartDate = new DateTime(2019, 2, 1);
            wdc.GetModel().Scheduled.MonthlyPeriod.Type = ScheduleDefinition.Monthly.ScheduleType.First;
            wdc.GetModel().Scheduled.MonthlyPeriod.WeekDay = DayOfWeek.Saturday;

            var controller = wdc.GetScheduleController();
            var days       = controller.GetScheduledDays();
        }
        public WashingDayEditorController(WashingDayDefinition wd, List <RoutineDefinition> allroutines, AlarmController ac)
        {
            if (wd == null)
            {
                throw new ArgumentNullException("wd");
            }
            if (ac == null)
            {
                throw new ArgumentNullException("ac");
            }

            this.mWashingDay         = wd;
            this.mAllRoutines        = allroutines;
            this.mScheduleController = new ScheduleController(wd.Scheduled);
            this.mAlarmController    = ac;
        }
Пример #11
0
        public void GetScheduledDays_CheckOtherWeekDay()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);

            wdc.GetModel().Scheduled.WeeklyPeriod.WeekDays = new System.Collections.Generic.List <DayOfWeek>
            {
                DayOfWeek.Sunday
            };

            var res = wdc.GetScheduledDays();

            Assert.AreEqual(DayOfWeek.Sunday, res[0].DayOfWeek);
            Assert.AreEqual(DayOfWeek.Sunday, res[1].DayOfWeek);
        }
Пример #12
0
        public void Restore_IsWorking()
        {
            MainSessionController c = new MainSessionController(new Dictionary <string, object>());

            c.Init();
            var days = c.GetAllWashingDays();
            var wdd  = new WashingDayDefinition();

            wdd.ID = "Foo";
            days.Add(wdd);

            c.Save();
            c.GetAllWashingDays().Clear();
            c.Restore();
            Assert.AreEqual(1, c.GetAllWashingDays().Count);
            Assert.AreEqual("Foo", c.GetAllWashingDays()[0].ID);
        }
Пример #13
0
        public void GetFutureDaysIsWorking()
        {
            MainSessionController c = new MainSessionController(new Dictionary <string, object>());

            c.Init();
            var days = c.GetAllWashingDays();
            var wdd  = new WashingDayDefinition();

            wdd.Scheduled.Type = ScheduleDefinition.ScheduleType.Dayly;
            wdd.Scheduled.DaylyPeriod.Period = 1;
            days.Add(wdd);

            var fDays = c.GetFutureDays();



            Assert.AreEqual(wdd, c.GetFutureDays()[ScheduleController.GetToday()][0]);
        }
Пример #14
0
        public void GetScheduledDays_Period2()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);

            wdc.GetModel().Scheduled.WeeklyPeriod.Period = 2;
            wdc.GetModel().Scheduled.WeeklyPeriod.WeekDays = new System.Collections.Generic.List <DayOfWeek>
            {
                DayOfWeek.Monday,
            };
            wdc.GetModel().Scheduled.StartDate = new DateTime(2019, 2, 5);

            var res = wdc.GetScheduledDays();

            Assert.True(ScheduleController.IsSameDay(res[0], new DateTime(2019, 2, 11)));
            Assert.True(ScheduleController.IsSameDay(res[1], new DateTime(2019, 2, 25)));
        }
Пример #15
0
        public void Monthly_SecondSaturday_BeforeStart_MonthlyPeriod_2()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);

            wdc.GetModel().Scheduled.Type = ScheduleDefinition.ScheduleType.Monthly;
            wdc.GetModel().Scheduled.MonthlyPeriod.Period = 2;
            wdc.GetModel().Scheduled.StartDate = new DateTime(2019, 2, 23);
            wdc.GetModel().Scheduled.MonthlyPeriod.Type = ScheduleDefinition.Monthly.ScheduleType.First;
            wdc.GetModel().Scheduled.MonthlyPeriod.WeekDay = DayOfWeek.Saturday;

            var controller = wdc.GetScheduleController();
            var days       = controller.GetScheduledDays();

            Assert.AreEqual(new DateTime(2019, 3, 2), days[0]);
            Assert.AreEqual(new DateTime(2019, 5, 4), days[1]);
        }
Пример #16
0
        public void Time2CareDay_is0()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);

            wdc.GetModel().Scheduled.WeeklyPeriod.WeekDays = new System.Collections.Generic.List <DayOfWeek>
            {
                DayOfWeek.Sunday,
                DayOfWeek.Thursday
            };
            wdc.GetModel().Scheduled.WeeklyPeriod.Period = 2;
            wdc.GetModel().Scheduled.StartDate = new DateTime(2019, 2, 5);

            var controller = wdc.GetScheduleController();


            Assert.AreEqual(0, controller.Time2NextCareDay(new DateTime(2019, 2, 7)));
        }
Пример #17
0
        public void GetScheduledDays_Period2_twoDays()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);

            wdc.GetModel().Scheduled.WeeklyPeriod.WeekDays = new System.Collections.Generic.List <DayOfWeek>
            {
                DayOfWeek.Sunday,
                DayOfWeek.Thursday
            };
            wdc.GetModel().Scheduled.WeeklyPeriod.Period = 2;
            wdc.GetModel().Scheduled.StartDate = new DateTime(2019, 2, 5);

            var res = wdc.GetScheduledDays();


            Assert.True(ScheduleController.ContainsDay(res, new DateTime(2019, 2, 7)));
            Assert.True(ScheduleController.ContainsDay(res, new DateTime(2019, 2, 10)));
            Assert.True(ScheduleController.ContainsDay(res, new DateTime(2019, 2, 21)));
            Assert.True(ScheduleController.ContainsDay(res, new DateTime(2019, 2, 24)));
        }
Пример #18
0
 public WashDayEditorEventArgs(WashingDayDefinition def, Boolean create)
 {
     this.Definition = def;
     this.Created    = create;
 }
        public WashingDayInstanceCalendarCell(WashingDayInstance instance, WashingDayDefinition def, HairAppBl.Interfaces.IHairBl hairbl) : base(hairbl)
        {
            this.Instance   = instance;
            this.Definition = def;
            this.HeaderName = Definition.Name;
            Color           = Definition.ItemColor;

            var commentLabel = Common.GetCalendarDetailsRow("comment.png", new Label
            {
                Text     = instance.Comment,
                FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
            }, hairbl);

            commentLabel.IsVisible = !String.IsNullOrWhiteSpace(instance.Comment);

            var picContainer = new ScrollView {
                Orientation = ScrollOrientation.Horizontal
            };
            var picListView = new StackLayout {
                Orientation = StackOrientation.Horizontal
            };

            picContainer.Content = picListView;

            foreach (var pic in instance.Pictures)
            {
                var img = new ImageButton {
                    HeightRequest = 60, Source = ImageSource.FromFile(pic.Path), BackgroundColor = Color.Transparent
                };
                img.Clicked += Img_Clicked;
                picListView.Children.Add(img);
            }

            var pictureList = Common.GetCalendarDetailsRow("camera.png", picContainer, hairbl);

            pictureList.IsVisible = instance.Pictures.Count > 0;

            var showMore = new Button
            {
                Text            = Resources.AppResources.ShowMore,
                BackgroundColor = Color.Transparent,
                TextColor       = Color.Blue
            };

            showMore.Clicked += ShowMoreButton_Clicked;

            var routineList = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
            };

            foreach (var r in instance.Routines)
            {
                var check = new XLabs.Forms.Controls.CheckBox();
                check.Checked   = r.Checked;
                check.IsEnabled = false;
                var row = new StackLayout {
                    Orientation = StackOrientation.Horizontal
                };
                row.Children.Add(check);
                row.Children.Add(new Label {
                    Text = r.Name
                });
                routineList.Children.Add(row);
            }

            var routineFrame = Common.GetCalendarDetailsRow("list.png", routineList, hairbl);
            var neededTime   = Common.GetCalendarDetailsRow("time.png", new Label {
                Text = $"{instance.NeededTime.TotalMinutes} {HairApp.Resources.AppResources.Minutes}"
            }, hairbl);

            DetailsContent.Add(commentLabel);
            DetailsContent.Add(routineFrame);
            DetailsContent.Add(neededTime);
            DetailsContent.Add(pictureList);
            DetailsContent.Add(showMore);
        }
Пример #20
0
 public void DeleteWashDay(WashingDayDefinition washingDay)
 {
     MainSession.WashingDays.Remove(washingDay);
     SendDefinitionsEdited();
 }
 public WashingDayCellEventArgs(WashingDayInstance instance, WashingDayDefinition definition)
 {
     this.Definition = definition;
     this.Instance   = instance;
 }