Beispiel #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);
 }
Beispiel #2
0
 public Goal(string description, CalendarDay day)
     : this()
 {
     Description = description;
     Day = day;
     Done = false;
 }
Beispiel #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);
 }
Beispiel #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);
        }
Beispiel #6
0
 public void Equality_SameObject()
 {
     var day = new CalendarDay(2010, 8, 1);
     var secondReference = day;
     Assert.IsTrue(day.Equals(secondReference));
 }
Beispiel #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));
 }
Beispiel #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));
 }
Beispiel #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));
 }
Beispiel #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));
 }
Beispiel #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));
 }
Beispiel #12
0
 public void BindTo(Account account, CalendarDay day)
 {
     Mapper.Map(account, this);
     Goals = account.GoalsFor(day);
     AccountDay = day.ToDateTime();
 }
Beispiel #13
0
 public IEnumerable<Goal> GoalsFor(CalendarDay calendarDay)
 {
     return Goals.Where(goal => goal.Day.Equals(calendarDay));
 }
Beispiel #14
0
 public void AddGoal(string description, CalendarDay day)
 {
     if (description == null) return;
     var goal = new Goal(description.Trim(), day);
     Goals.Add(goal);
 }
Beispiel #15
0
 private void TheNewGoalHasTheDate(CalendarDay goalDate)
 {
     Assert.AreEqual(goalDate, account.Goals[0].Day);
 }