public void CalendarRepository_AddCalendarHoliday_Added_NotFail_Test() { var context = new MyCompanyContext(); int expected = context.CalendarHolidays.Count() + 1; var target = new CalendarRepository(context); var calendarHolidaysId = context.CalendarHolidays.Select(e => e.CalendarHolidaysId).Max() + 1; var calendarId = context.CalendarHolidays.First().CalendarId; var calendar = new CalendarHolidays() { CalendarId = calendarId, Day = DateTime.UtcNow, Name = "name", CalendarHolidaysId = calendarHolidaysId }; target.AddHoliday(calendar); int actual = context.CalendarHolidays.Count(); Assert.AreEqual(expected, actual); }
/// <summary> /// <see cref="MyCompany.Vacation.Data.Repositories.ICalendarRepository"/> /// </summary> /// <param name="calendarHoliday"><see cref="MyCompany.Vacation.Data.Repositories.ICalendarRepository"/></param> /// <returns><see cref="MyCompany.Vacation.Data.Repositories.ICalendarRepository"/></returns> public int AddHoliday(CalendarHolidays calendarHoliday) { _context.CalendarHolidays.Add(calendarHoliday); _context.SaveChanges(); return(calendarHoliday.CalendarHolidaysId); }