コード例 #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());
        }
コード例 #2
0
        public void AddNullDiaryLogTest_ThrowsException()
        {
            //Arrange
            ReflectiveDiaryLog log = null;

            //Act & Assert
            Assert.Throws <ArgumentNullException>(() => _diaryLogRepo.CreateReflectiveDiaryLog(log));
        }
コード例 #3
0
        public void DeleteNullDiaryLog_ThrowsException()
        {
            //Arrange
            ReflectiveDiaryLog log = new ReflectiveDiaryLog();

            //Act & Assert
            Assert.Throws <ArgumentNullException>(() => _diaryLogRepo.DeleteDiaryLog(log.Id));
        }
コード例 #4
0
 public void CreateReflectiveDiaryLog(ReflectiveDiaryLog log)
 {
     if (log == null)
     {
         throw new ArgumentNullException();
     }
     _context.DiaryLogs.Add(log);
     _context.SaveChanges();
 }
コード例 #5
0
 public ReflectiveDiaryLogTest()
 {
     _log = new ReflectiveDiaryLog
     {
         Id          = 1,
         Type        = "Life",
         Description = "Have some fun",
         DateLog     = DateTime.Today,
         UserId      = 2
     };
 }
コード例 #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());
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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());
        }
コード例 #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 :)
 }