示例#1
0
 public void InitializeTest()
 {
     _persistance       = Mock.Create <IPersistance>();
     _dateTime          = Mock.Create <IDateTimeProvider>();
     _navigationService = Mock.Create <INavigationService>();
     _modelFactory      = Mock.Create <IModelFactory>();
     _storage           = new HabitService
     {
         Persistance      = _persistance,
         DateTimeProvider = _dateTime,
         ModelFactory     = _modelFactory,
         Navigation       = _navigationService,
     };
     _habitViewModel = Mock.Create <IHabitViewModel>();
 }
示例#2
0
 public IHabitModel CreateHabitModel(IHabitViewModel habit)
 {
     return(new HabitModel
     {
         Id = habit.Id,
         CreationDate = habit.CreationDate,
         RepeatType = habit.RepeatType,
         Description = habit.Description,
         Filling = JsonConvert.SerializeObject(habit.Filling),
         HabitType = habit.HabitType,
         DaysToRepeat = habit.DaysToRepeat,
         StartDate = habit.StartDate,
         Title = habit.Title,
         IsRecommended = habit.IsRecommended,
         RepeatsADay = habit.MaxRepeatsADay
     });
 }
示例#3
0
 /// <summary>
 /// Returns time between the first day and last day of a habit
 /// </summary>
 /// <returns>The time between first and last day of the habit.</returns>
 public TimeSpan HabitLength(IHabitViewModel habit) => (habit.StartDate != null)
                 ? HabitLength(habit.StartDate.Value, habit.RepeatType, habit.DaysToRepeat)
                 : throw new ArgumentException("Habit must have a StartDate.");
示例#4
0
 /// <summary>
 /// Calculates if the last date of the habit is before the given date
 /// </summary>
 /// <param name="habit">The habit for which will be made the calculation.</param>
 /// <param name="date">Date which will be used for measuring if the habit is finished at this date.</param>
 /// <returns>True if the last date of habit is before the given date</returns>
 public bool IsHabitFinished(IHabitViewModel habit, DateTime?date = null) => IsHabitFinished(date ?? _provider.Now, habit.StartDate, habit.RepeatType, habit.DaysToRepeat);
示例#5
0
 /// <summary>
 /// Returns index-th day in the filling of the habit
 /// </summary>
 /// <param name="index">Index of the day for which should be calculated the date</param>
 /// <param name="habit">The habit for day date calculation</param>
 /// <returns>If there is no day on the given index (because its higher than index of the last day) then null is returned, othervise the date corresponding to the index.</returns>
 public DateTime?GetFillingDay(int index, IHabitViewModel habit) => habit.StartDate != null
                 ? GetFillingDay(index, habit.StartDate.Value, habit.RepeatType, habit.DaysToRepeat)
                 : throw new ArgumentException("Cannot get filling day on a habit which has a null StartDate");
 public ActualHabitView(IHabitViewModel model) : base(model)
 {
     InitializeComponent();
 }
 public void TestInit()
 {
     _dateProvider   = Mock.Create <IDateTimeProvider>();
     _scheduleHelper = new HabitScheduleHelper(_dateProvider);
     _habit          = Mock.Create <IHabitViewModel>();
 }
示例#8
0
 public HabitView(IHabitViewModel habit)
     : base(habit)
 {
     InitializeComponent();
 }