Exemple #1
0
 public void ConvertToDateTime()
 {
     var day = new CalendarDay(2010, 8, 1);
     Assert.AreEqual(day.ToDateTime().Year, 2010);
     Assert.AreEqual(day.ToDateTime().Month, 8);
     Assert.AreEqual(day.ToDateTime().Day, 1);
 }
Exemple #2
0
 public Goal(string description, CalendarDay day)
     : this()
 {
     Description = description;
     Day = day;
     Done = false;
 }
Exemple #3
0
 private void TheDayIs(CalendarDay day)
 {
     this.day = day;
     _documentService = Substitute.For<IDocumentService>();
     _documentService.Query(Arg.Any<AccountByNameSlug>()).Returns((new List<Account> { account }).AsQueryable());
     controller = new TodayController(_documentService);
 }
Exemple #4
0
 public void CopyForward(CalendarDay day)
 {
     var incomplete = GoalsFor(day).Where(goal => !goal.Done).ToList();
     var nextDay = day.AddDays(1);
     foreach (var goal in incomplete)
     {
         AddGoal(goal.Description, nextDay);
     }
 }
        private void ADayWithSomeCompleteAndSomeIncompleteGoals()
        {
            account = Build.An<Account>();
            today = new CalendarDay(2010, 9, 17);
            tomorrow = new CalendarDay(2010, 9, 18);
            account.AddGoal("thing I did", today);
            account.Done(account.Goals.First(g => g.Description.Equals("thing I did")).Id);
            account.AddGoal("thing I should have done", today);
            account.AddGoal("something else I did", today);
            account.Done(account.Goals.First(g => g.Description.Equals("something else I did")).Id);
            account.AddGoal("something I forgot to do", today);
            account.AddGoal("something I will do tomorrow", tomorrow);

            var docService = Substitute.For<IDocumentService>();
            docService.Query(Arg.Any<AccountByNameSlug>()).Returns(new [] {account}.AsQueryable());
            controller = new TodayController(docService);
        }
Exemple #6
0
 public void Equality_SameObject()
 {
     var day = new CalendarDay(2010, 8, 1);
     var secondReference = day;
     Assert.IsTrue(day.Equals(secondReference));
 }
Exemple #7
0
 public void Equality_NotEqual()
 {
     var day = new CalendarDay(2010, 8, 1);
     var day2 = new CalendarDay(2020, 8, 1);
     Assert.IsFalse(day.Equals(day2));
 }
Exemple #8
0
 public void Equality_DifferentObject()
 {
     var day = new CalendarDay(2010, 8, 1);
     var day2 = new CalendarDay(2010, 8, 1);
     Assert.IsTrue(day.Equals(day2));
 }
Exemple #9
0
 public void AddDays_ForwardNewMonth()
 {
     var day = new CalendarDay(2010, 8, 30);
     day = day.AddDays(2);
     Assert.AreEqual(day, new CalendarDay(2010, 9, 1));
 }
Exemple #10
0
 public void AddDays_Forward7()
 {
     var day = new CalendarDay(2010, 8, 1);
     day = day.AddDays(7);
     Assert.AreEqual(day, new CalendarDay(2010, 8, 8));
 }
Exemple #11
0
 public void AddDays_BackADay()
 {
     var day = new CalendarDay(2010, 8, 1);
     day = day.AddDays(-1);
     Assert.AreEqual(day, new CalendarDay(2010,7,31));
 }
Exemple #12
0
 public void BindTo(Account account, CalendarDay day)
 {
     Mapper.Map(account, this);
     Goals = account.GoalsFor(day);
     AccountDay = day.ToDateTime();
 }
Exemple #13
0
 public IEnumerable<Goal> GoalsFor(CalendarDay calendarDay)
 {
     return Goals.Where(goal => goal.Day.Equals(calendarDay));
 }
Exemple #14
0
 public void AddGoal(string description, CalendarDay day)
 {
     if (description == null) return;
     var goal = new Goal(description.Trim(), day);
     Goals.Add(goal);
 }
Exemple #15
0
 private void TheNewGoalHasTheDate(CalendarDay goalDate)
 {
     Assert.AreEqual(goalDate, account.Goals[0].Day);
 }