Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        public void AddNullDiaryLogTest_ThrowsException()
        {
            //Arrange
            ReflectiveDiaryLog log = null;

            //Act & Assert
            Assert.Throws <ArgumentNullException>(() => _diaryLogRepo.CreateReflectiveDiaryLog(log));
        }
Exemplo n.º 3
0
        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();
 }
Exemplo n.º 5
0
 public ReflectiveDiaryLogTest()
 {
     _log = new ReflectiveDiaryLog
     {
         Id          = 1,
         Type        = "Life",
         Description = "Have some fun",
         DateLog     = DateTime.Today,
         UserId      = 2
     };
 }
Exemplo n.º 6
0
        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());
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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());
        }
Exemplo n.º 11
0
 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 :)
 }