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()); }
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); }
public void AddNullDailyCheckInTest_ThrowsException() { //Arrange DailyCheckIn checkIn = null; //Act & Assert Assert.Throws <ArgumentNullException>(() => _checkInRepo.CreateDailyCheckIn(checkIn)); }
public void DeleteNullDailyCheckInTest_ThrowsException() { //Arrange DailyCheckIn checkIn = new DailyCheckIn(); //Act & Assert Assert.Throws <ArgumentNullException>(() => _checkInRepo.DeleteDailyCheckInById(checkIn.ID)); }
public void CreateDailyCheckIn(DailyCheckIn newCheckIn) { if (newCheckIn == null) { throw new ArgumentNullException(nameof(newCheckIn)); } _context.DailyCheckIns.Add(newCheckIn); }
public DailyCheckInTest() { _testCheckIn = new DailyCheckIn { Date = DateTime.Today, PhysicalState = PhysicalState.GOOD, MentalState = MentalState.MEH, PositiveFeelings = null, NegativeFeelings = NegativeFeelings.LONELY, UserID = 2 }; }
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()); }
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); }
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); }
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); }
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); }
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 :) }