Esempio n. 1
0
        public DayVm(IItemsRepository itemsRepo, TodoDay day, ILifetimeScope scope)
        {
            this.itemsRepo = itemsRepo;
            Day            = day;
            this.scope     = scope;

            NewTaskCmd = new DelegateCommand(NewTask, CanAddNew);
        }
Esempio n. 2
0
        public void GoToDay(TodoDay day)
        {
            if (!CanGoToDay(day))
            {
                return;
            }

            CurrentVm = scope.Resolve <IDayVm>(new TypedParameter(typeof(TodoDay), day));
        }
        public void IsTodayTrue()
        {
            TodoDay todoDay = new TodoDay()
            {
                Day = DateTime.Now.Date
            };

            TodoDayPresenter presenter = new TodoDayPresenter(1, todoDay);

            Assert.True(presenter.IsToday);
        }
        public void IsWeekend(int year, int month, int day, bool expected)
        {
            TodoDay todoDay = new TodoDay()
            {
                Day = new DateTime(year, month, day)
            };

            TodoDayPresenter presenter = new TodoDayPresenter(1, todoDay);

            Assert.Equal(expected, presenter.IsWeekend);
        }
        public void IsTodayFalse(int year, int month, int day)
        {
            TodoDay todoDay = new TodoDay()
            {
                Day = new DateTime(year, month, day)
            };

            TodoDayPresenter presenter = new TodoDayPresenter(1, todoDay);

            Assert.False(presenter.IsToday);
        }
        public void SameObject()
        {
            TodoDay todoDay = new TodoDay()
            {
                Day = new DateTime(2020, 1, 1)
            };

            TodoDayPresenter presenter = new TodoDayPresenter(1, todoDay);

            Assert.Same(todoDay, presenter.Original);
        }
        public void IsDayFromSelectedMonth(int selectedMonth, int year, int month, int day,
                                           bool expected)
        {
            TodoDay todoDay = new TodoDay()
            {
                Day = new DateTime(year, month, day)
            };

            TodoDayPresenter presenter = new TodoDayPresenter(selectedMonth, todoDay);

            Assert.Equal(expected, presenter.IsDayFromSelectedMonth);
        }
        public void ItemsCount(int count)
        {
            TodoDay todoDay = new TodoDay()
            {
                Day   = new DateTime(2020, 1, 1),
                Items = Enumerable.Repeat(new TodoItem(), count).ToList()
            };

            TodoDayPresenter presenter = new TodoDayPresenter(1, todoDay);

            Assert.Equal(count, presenter.ItemsCount);
        }
        public void DayProperty()
        {
            using AutoMock mock = AutoMock.GetLoose();
            TodoDay day = new TodoDay()
            {
                Day = DateTime.Now
            };

            DayVm vm = mock.Create <DayVm>(TypedParameter.From(day));

            Assert.Same(day, vm.Day);
        }
        public void AnyItems(int count, bool expected)
        {
            TodoDay todoDay = new TodoDay()
            {
                Day   = new DateTime(2020, 1, 1),
                Items = Enumerable.Repeat(new TodoItem(), count).ToList()
            };

            TodoDayPresenter presenter = new TodoDayPresenter(1, todoDay);

            Assert.Equal(expected, presenter.AnyItems);
        }
Esempio n. 11
0
        public void NewTaskCmdCanExecute(int daysFromToday, bool expected)
        {
            using AutoMock mock = AutoMock.GetLoose();
            TodoDay day = new TodoDay()
            {
                Day = DateTime.Now.AddDays(daysFromToday)
            };
            DayVm vm = mock.Create <DayVm>(TypedParameter.From(day));

            bool result = vm.NewTaskCmd.CanExecute(null);

            Assert.Equal(expected, result);
        }
Esempio n. 12
0
        public HouseBookingDateInfo getHouseBookingDateInfo(HouseBookingParam param)
        {
            HouseBookingDateInfo houseBookingDateInfo = new HouseBookingDateInfo();

            houseBookingDateInfo.todoDayList    = new List <TodoDay>();
            houseBookingDateInfo.disableDayList = new List <DisableDay>();
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat(ShipSqls.SELECT_HOUSELIST_DATA_BY_HOUSEID, param.houseId);
            string    sql = builder.ToString();
            DataTable dt  = DatabaseOperationWeb.ExecuteSelectDS(sql, "T").Tables[0];

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["BOOKINGTYPE"].ToString() == "1")
                    {
                        DisableDay disableDay = new DisableDay
                        {
                            year  = dt.Rows[i]["BOOKINGYEAR"].ToString(),
                            month = dt.Rows[i]["BOOKINGMONTH"].ToString(),
                            day   = dt.Rows[i]["BOOKINGDAY"].ToString(),
                        };
                        houseBookingDateInfo.disableDayList.Add(disableDay);
                    }
                    else
                    {
                        string todoText = "";
                        if (param.userPhone != "")
                        {
                            if (param.userPhone == dt.Rows[i]["BOOKINGYEAR"].ToString())
                            {
                                todoText = "预订";
                            }
                        }

                        TodoDay todoDay = new TodoDay
                        {
                            year     = dt.Rows[i]["BOOKINGYEAR"].ToString(),
                            month    = dt.Rows[i]["BOOKINGMONTH"].ToString(),
                            day      = dt.Rows[i]["BOOKINGDAY"].ToString(),
                            todoText = todoText,
                        };
                        houseBookingDateInfo.todoDayList.Add(todoDay);
                    }
                }
            }
            houseBookingDateInfo.house = getHouseByHouseId(param.houseId);
            return(houseBookingDateInfo);
        }
Esempio n. 13
0
        public void NewTaskCmdExecute()
        {
            using AutoMock mock = AutoMock.GetStrict(x => {
                x.RegisterType <MainVm>()
                .As <IMainVm>()
                .SingleInstance();
            });
            mock.Mock <IItemsRepository>()
            .Setup(x => x.Add(It.IsAny <TodoItem>()))
            .Returns(Task.FromResult <object>(null));
            TodoDay day = new TodoDay()
            {
                Day = DateTime.Now
            };
            DayVm vm = mock.Create <DayVm>(TypedParameter.From(day));

            vm.NewTaskCmd.Execute(null);

            IMainVm main = mock.Create <IMainVm>();

            Assert.IsAssignableFrom <IItemVm>(main.CurrentVm);
        }
Esempio n. 14
0
        public IActionResult Index()
        {
            TodoDay newday = new TodoDay();

            newday.Date = DateTime.Now;
            newday.Todos.Add(new Todo()
            {
                Name  = "almaszedés",
                Hours = 3,
            });
            newday.Todos.Add(new Todo()
            {
                Name  = "porszívózás",
                Hours = 5,
            });
            repo.TodoDays.Add(newday);
            repo.SaveChanges();



            return(View());
        }
 public TodoDayPresenter(int selectedMonth, TodoDay day)
 {
     wrapped            = day;
     this.selectedMonth = selectedMonth;
 }
Esempio n. 16
0
        public CalendarVm(IDaysRepository daysRepo, IBoundriesSelector boundriesSelector, TodoDay day = null)
        {
            this.daysRepo          = daysRepo;
            this.boundriesSelector = boundriesSelector;

            if (day == null)
            {
                selectedMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            }
            else
            {
                selectedMonth = new DateTime(day.Day.Year, day.Day.Month, 1);
            }

            minMonth = new DateTime(2020, 1, 1);
            maxMonth = new DateTime(2029, 12, 1);

            NextMonthCmd = new DelegateCommand(AddMonth, CanAddMonth);
            PrevMonthCmd = new DelegateCommand(SubMonth, CanSubMonth);
        }
Esempio n. 17
0
 void GoToCalendar(TodoDay day)
 {
     CurrentVm = scope.Resolve <ICalendarVm>(new TypedParameter(typeof(TodoDay), day));
 }
Esempio n. 18
0
 bool CanGoToDay(TodoDay day)
 {
     return(day?.Day >= new DateTime(2020, 1, 1) &&
            day?.Day <= new DateTime(2029, 12, 31));
 }