public async Task GetCalendarEvent_ById_ShouldReturnEventWithReminder(
            int id,
            string color,
            string title,
            string description,
            string start,
            string end,
            string reminderTime,
            bool isReminderActive,
            ReminderTimeOffset reminderTimeOffset)
        {
            var optionalEndDate = end == null ? default(DateTime?) : DateTime.Parse(end);
            var response        = await _client.GetAsync($"/api/calendar/events/{id}");

            response.EnsureSuccessStatusCode();
            var stringResponse = await response.Content.ReadAsStringAsync();

            dynamic responseResult = JsonConvert.DeserializeObject <dynamic>(stringResponse);
            var     result         = JsonConvert.DeserializeObject <CalendarEventViewModel>(responseResult.data.ToString()) as CalendarEventViewModel;

            // Assert
            result.Id.Should().Be(id);
            result.Color.Should().Be(color);
            result.Title.Should().Be(title);
            result.Description.Should().Be(description);
            result.Start.Should().Be(DateTime.Parse(start));
            result.End.Should().Be(optionalEndDate);
            result.Reminders.ToArray()[0].Time.Should().Be(DateTime.Parse(reminderTime));
            result.Reminders.ToArray()[0].Active.Should().Be(isReminderActive);
            result.Reminders.ToArray()[0].TimeOffset.Should().Be(reminderTimeOffset);
        }
        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);
        }
Ejemplo n.º 3
0
 public static ReminderModel CreateReminder(DateTime time, bool active, ReminderTimeOffset timeOffset)
 {
     return(new ReminderModel {
         Time = time,
         Active = active,
         TimeOffset = timeOffset
     });
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 public static Reminder Create(
     bool active,
     DateTime time,
     ReminderTimeOffset timeOffset)
 {
     return(new Reminder
     {
         Active = active,
         Time = time,
         TimeOffset = timeOffset
     });
 }
        public async Task UpdateCalendarEvent_WithReminder_ShouldReturnNoContentResult(
            int id,
            string color,
            string title,
            string description,
            string start,
            string end,
            string reminderTime,
            bool isReminderActive,
            ReminderTimeOffset reminderTimeOffset)
        {
            // Arrange
            CalendarEventInputModel inputModel = new CalendarEventInputModel {
                Color       = color,
                Title       = title,
                Description = description,
                Start       = DateTime.Parse(start),
                End         = end == null ? default(DateTime?) : DateTime.Parse(end),
                Reminders   = new List <ReminderInputModel> {
                    new ReminderInputModel {
                        Time       = DateTime.Parse(reminderTime),
                        Active     = isReminderActive,
                        TimeOffset = reminderTimeOffset
                    }
                }
            };
            var json          = JsonConvert.SerializeObject(inputModel);
            var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");

            // Act
            var response = await _client.PutAsync($"/api/calendar/events/{id}", stringContent);

            response.EnsureSuccessStatusCode();

            // Assert
            response.StatusCode.Should().Be(HttpStatusCode.NoContent);

            // Check updated data
            await GetCalendarEvent_ById_ShouldReturnEventWithReminder(id, color, title, description, start, end, reminderTime, isReminderActive, reminderTimeOffset);
        }