public void GetDiaryLogs() { //Arrange var _log = new ReflectiveDiaryLog { Type = "Life", Description = "Have some fun", DateLog = DateTime.Today, UserId = 2 }; var _log2 = new ReflectiveDiaryLog { Type = "Laugh", Description = "Have some fun2", DateLog = DateTime.Today, UserId = 1 }; dbContext.DiaryLogs.Add(_log); dbContext.DiaryLogs.Add(_log2); dbContext.SaveChanges(); //Act var result = _diaryLogRepo.GetAllReflectiveDiaryLogs(); //Assert Assert.Equal(2, result.Count()); }
public void AddNullDiaryLogTest_ThrowsException() { //Arrange ReflectiveDiaryLog log = null; //Act & Assert Assert.Throws <ArgumentNullException>(() => _diaryLogRepo.CreateReflectiveDiaryLog(log)); }
public void DeleteNullDiaryLog_ThrowsException() { //Arrange ReflectiveDiaryLog log = new ReflectiveDiaryLog(); //Act & Assert Assert.Throws <ArgumentNullException>(() => _diaryLogRepo.DeleteDiaryLog(log.Id)); }
public void CreateReflectiveDiaryLog(ReflectiveDiaryLog log) { if (log == null) { throw new ArgumentNullException(); } _context.DiaryLogs.Add(log); _context.SaveChanges(); }
public ReflectiveDiaryLogTest() { _log = new ReflectiveDiaryLog { Id = 1, Type = "Life", Description = "Have some fun", DateLog = DateTime.Today, UserId = 2 }; }
public void AddDiaryLog() { //Arrange var _log = new ReflectiveDiaryLog { Type = "Life", Description = "Have some fun", DateLog = DateTime.Today, UserId = 2 }; var objCount = dbContext.DiaryLogs.Count(); //Act _diaryLogRepo.CreateReflectiveDiaryLog(_log); _diaryLogRepo.SaveChanges(); //Assert Assert.Equal(objCount + 1, dbContext.DiaryLogs.Count()); }
public void GetDiaryLogsWithOneLogInTheDBTest() { //Arrange var _log = new ReflectiveDiaryLog { Type = "Life", Description = "Have some fun", DateLog = DateTime.Today, UserId = 2 }; dbContext.DiaryLogs.Add(_log); dbContext.SaveChanges(); //Act var result = _diaryLogRepo.GetAllReflectiveDiaryLogs(); //Assert Assert.Single(result); }
public void GetDiaryLogById_ReturnsCorrectResourceTest() { //Arrange var _log = new ReflectiveDiaryLog { Type = "Life", Description = "Have some fun", DateLog = DateTime.Today, UserId = 2 }; dbContext.DiaryLogs.Add(_log); dbContext.SaveChanges(); var id = _log.Id; //Act var result = _diaryLogRepo.GetReflectiveDiaryLogById(id); //Assert Assert.Equal(id, result.Id); }
public void GetDiaryLogsByUserId_ReturnsTheCorrectTypeTest() { //Arrange var _log = new ReflectiveDiaryLog { Type = "Life", Description = "Have some fun", DateLog = DateTime.Today, UserId = 2 }; dbContext.DiaryLogs.Add(_log); dbContext.SaveChanges(); var userId = _log.UserId; //Act var result = _diaryLogRepo.GetReflectiveDiaryLogsByUserId(userId); //Assert Assert.IsAssignableFrom <IEnumerable <ReflectiveDiaryLog> >(result); }
public void DeleteDiaryLog() { //Arrange var _log = new ReflectiveDiaryLog { Type = "Life", Description = "Have some fun", DateLog = DateTime.Today, UserId = 2 }; dbContext.DiaryLogs.Add(_log); dbContext.SaveChanges(); var id = _log.Id; var objCount = dbContext.DiaryLogs.Count(); //Act _diaryLogRepo.DeleteDiaryLog(id); _diaryLogRepo.SaveChanges(); //Assert Assert.Equal(objCount - 1, dbContext.DailyCheckIns.Count()); }
public void UpdateDiaryLog(ReflectiveDiaryLog log) { // The update is being taken care of by the DBContext, however since this class implements the IUser interface we need to implement it // Nothing :) }