Пример #1
0
        public void GetDailyCheckInsTest()
        {
            //Arrange
            var _testCheckIn1 = new DailyCheckIn
            {
                Date             = DateTime.Today,
                PhysicalState    = PhysicalState.GOOD,
                MentalState      = MentalState.MEH,
                PositiveFeelings = null,
                NegativeFeelings = NegativeFeelings.LONELY,
                UserID           = 2
            };
            var _testCheckIn2 = new DailyCheckIn
            {
                Date             = DateTime.Today,
                PhysicalState    = PhysicalState.GREAT,
                MentalState      = MentalState.GREAT,
                PositiveFeelings = PositiveFeelings.ENTHUSIASTIC,
                NegativeFeelings = null,
                UserID           = 1
            };

            dbContext.DailyCheckIns.Add(_testCheckIn1);
            dbContext.DailyCheckIns.Add(_testCheckIn2);
            dbContext.SaveChanges();

            //Act
            var result = _checkInRepo.GetAllDailyCheckIns();

            //Arrange
            Assert.Equal(2, result.Count());
        }
Пример #2
0
        public void GetNegativeFeelingsCountTest()
        {
            //Arrange
            //Add dailycheckin with positive feeling
            var _testCheckIn = new DailyCheckIn
            {
                Date             = DateTime.Today,
                PhysicalState    = PhysicalState.GREAT,
                MentalState      = MentalState.GREAT,
                PositiveFeelings = PositiveFeelings.ENTHUSIASTIC,
                NegativeFeelings = null,
                UserID           = 2
            };

            dbContext.DailyCheckIns.Add(_testCheckIn);
            dbContext.SaveChanges();
            //add dailycheckin with negative feelings
            var _testCheckIn2 = new DailyCheckIn
            {
                Date             = DateTime.Today,
                PhysicalState    = PhysicalState.GREAT,
                MentalState      = MentalState.GREAT,
                PositiveFeelings = null,
                NegativeFeelings = NegativeFeelings.APATHETIC,
                UserID           = 2
            };

            dbContext.DailyCheckIns.Add(_testCheckIn2);
            dbContext.SaveChanges();
            //Act
            var negativeFeelingsCount = _checkInRepo.GetNegativeFeelingsCount(2);

            //Assert
            Assert.Equal(1, negativeFeelingsCount);
        }
Пример #3
0
        public void AddNullDailyCheckInTest_ThrowsException()
        {
            //Arrange
            DailyCheckIn checkIn = null;

            //Act & Assert
            Assert.Throws <ArgumentNullException>(() => _checkInRepo.CreateDailyCheckIn(checkIn));
        }
Пример #4
0
        public void DeleteNullDailyCheckInTest_ThrowsException()
        {
            //Arrange
            DailyCheckIn checkIn = new DailyCheckIn();

            //Act & Assert
            Assert.Throws <ArgumentNullException>(() => _checkInRepo.DeleteDailyCheckInById(checkIn.ID));
        }
Пример #5
0
 public void CreateDailyCheckIn(DailyCheckIn newCheckIn)
 {
     if (newCheckIn == null)
     {
         throw new ArgumentNullException(nameof(newCheckIn));
     }
     _context.DailyCheckIns.Add(newCheckIn);
 }
Пример #6
0
 public DailyCheckInTest()
 {
     _testCheckIn = new DailyCheckIn
     {
         Date             = DateTime.Today,
         PhysicalState    = PhysicalState.GOOD,
         MentalState      = MentalState.MEH,
         PositiveFeelings = null,
         NegativeFeelings = NegativeFeelings.LONELY,
         UserID           = 2
     };
 }
Пример #7
0
        public void AddDailyCheckInTest()
        {
            //Arrange
            var _testCheckIn = new DailyCheckIn
            {
                Date             = DateTime.Today,
                PhysicalState    = PhysicalState.GREAT,
                MentalState      = MentalState.GREAT,
                PositiveFeelings = PositiveFeelings.ENTHUSIASTIC,
                NegativeFeelings = null,
                UserID           = 2
            };
            var objCount = dbContext.DailyCheckIns.Count();

            //Act
            _checkInRepo.CreateDailyCheckIn(_testCheckIn);
            _checkInRepo.SaveChanges();
            //Assert
            Assert.Equal(objCount + 1, dbContext.DailyCheckIns.Count());
        }
Пример #8
0
        public void GetDailyCheckInsWithOneCheckInTest()
        {
            //Arrange
            var _testCheckIn = new DailyCheckIn
            {
                Date             = DateTime.Today,
                PhysicalState    = PhysicalState.GOOD,
                MentalState      = MentalState.MEH,
                PositiveFeelings = null,
                NegativeFeelings = NegativeFeelings.LONELY,
                UserID           = 2
            };

            dbContext.DailyCheckIns.Add(_testCheckIn);
            dbContext.SaveChanges();

            //Act
            var result = _checkInRepo.GetAllDailyCheckIns();

            //Assert
            Assert.Single(result);
        }
Пример #9
0
        public void GetDailyCheckInByUserIdTest()
        {
            //Arrange
            var _testCheckIn = new DailyCheckIn
            {
                Date             = DateTime.Today,
                PhysicalState    = PhysicalState.GREAT,
                MentalState      = MentalState.GREAT,
                PositiveFeelings = PositiveFeelings.ENTHUSIASTIC,
                NegativeFeelings = null,
                UserID           = 2
            };

            dbContext.DailyCheckIns.Add(_testCheckIn);
            dbContext.SaveChanges();
            var userId = _testCheckIn.UserID;
            //Act
            var result = _checkInRepo.GetDailyCheckInsByUserID(userId);

            //Assert
            Assert.Single(result);
        }
Пример #10
0
        public void GetDailyCheckInById_ReturnsCorrectResourceTest()
        {
            //Arrange
            var _testCheckIn = new DailyCheckIn
            {
                Date             = DateTime.Today,
                PhysicalState    = PhysicalState.GREAT,
                MentalState      = MentalState.GREAT,
                PositiveFeelings = PositiveFeelings.ENTHUSIASTIC,
                NegativeFeelings = null,
                UserID           = 2
            };

            dbContext.DailyCheckIns.Add(_testCheckIn);
            dbContext.SaveChanges();
            var id = _testCheckIn.ID;
            //Act
            var result = _checkInRepo.GetDailyCheckInById(id);

            //Assert
            Assert.Equal(id, result.ID);
        }
Пример #11
0
        public void GetDailyCheckInByUserID_ReturnsTheCorrectTypeTest()
        {
            //Arrange
            var _testCheckIn = new DailyCheckIn
            {
                Date             = DateTime.Today,
                PhysicalState    = PhysicalState.GREAT,
                MentalState      = MentalState.GREAT,
                PositiveFeelings = PositiveFeelings.ENTHUSIASTIC,
                NegativeFeelings = null,
                UserID           = 2
            };

            dbContext.DailyCheckIns.Add(_testCheckIn);
            dbContext.SaveChanges();

            var userId = _testCheckIn.UserID;
            //Act
            var result = _checkInRepo.GetDailyCheckInsByUserID(userId);

            //Assert
            Assert.IsAssignableFrom <IEnumerable <DailyCheckIn> >(result);
        }
Пример #12
0
 public void UpdateDailyCheckIn(DailyCheckIn updatedCheckIn)
 {
     // The update is being taken care of by the DBContext, however since this class implements the IUser interface we need to implement it
     // Nothing :)
 }