public void TestCalendarEvent_CreateWithReminder_ShouldReturnNewEventWithReminder( string color, string title, string description, string start, string end, bool reminderActive, string reminderTime, ReminderTimeOffset reminderTimeOffset) { var optionalEndDate = end == null ? default(DateTime?) : DateTime.Parse(end); var startDate = DateTime.Parse(start); var expectedEvent = CalendarEvent.Create(color, title, description, startDate, optionalEndDate) .WithReminder(Reminder.Create( reminderActive, DateTime.Parse(reminderTime), reminderTimeOffset)); expectedEvent.Color.Should().Be(color); expectedEvent.Title.Should().Be(title); expectedEvent.Description.Should().Be(description); expectedEvent.Start.Should().Be(startDate); expectedEvent.End.Should().Be(optionalEndDate); expectedEvent.Reminders.ToArray()[0].Time.Should().Be(DateTime.Parse(reminderTime)); expectedEvent.Reminders.ToArray()[0].Active.Should().Be(reminderActive); expectedEvent.Reminders.ToArray()[0].TimeOffset.Should().Be(reminderTimeOffset); }
public IActionResult Post([FromBody] CalendarEventInputModel item) { if (item == null) { return(BadRequest()); } // replace with command pattern or builder pattern var newItem = CalendarEvent.Create( item.Color, item.Title, item.Description, item.Start, item.End); if (item.Reminders != null) { newItem.WithReminder( Reminder.Create( item.Reminders.ToArray()[0].Active, item.Reminders.ToArray()[0].Time, item.Reminders.ToArray()[0].TimeOffset)); } _calendarService.Store(newItem); return(Ok()); }
public void TestCalendarEventReminder_Create_ShouldReturnReminder( bool active, string time, ReminderTimeOffset timeOffset) { var expectedResult = Reminder.Create(active, DateTime.Parse(time), timeOffset); expectedResult.Active.Should().Be(active); expectedResult.Time.Should().Be(DateTime.Parse(time)); expectedResult.TimeOffset.Should().Be(timeOffset); }