public void AssertDefaultAthleteForNewUser() { var userDataAccess = new UserDataAccess(); MemoryDataContext.Clear(); const string email = "*****@*****.**"; const string password = "******"; var user = userDataAccess.CreateUserWithDefaultAthlete(email, password); var athleteDataAccess = new AthleteDataAccess(); var athlete = athleteDataAccess.GetAthlete(user); Assert.AreEqual(user, athlete.User); }
public void WhenGoalIsNewShouldAddInstance() { var dataAccess = new AthleteDataAccess(); var athlete = new Athlete { ID = 1 }; MemoryDataContext.Clear(); MemoryDataContext.InsertOnSubmit(athlete); MemoryDataContext.Commit(); Assert.AreEqual(0, MemoryDataContext.Queryable<Goal>().Count()); var goal = new Goal {Athlete = athlete}; dataAccess.SaveGoal(goal); Assert.AreEqual(1, MemoryDataContext.Queryable<Goal>().Count()); }
public void WhenGoalExistShouldUpdateExistingGoal() { var dataAccess = new AthleteDataAccess(); var athlete = new Athlete { ID = 1 }; MemoryDataContext.Clear(); MemoryDataContext.InsertOnSubmit(athlete); MemoryDataContext.Commit(); var goal = new Goal { Athlete = athlete }; dataAccess.SaveGoal(goal); goal.ID = 1; Assert.AreEqual(1, MemoryDataContext.Queryable<Goal>().Count()); dataAccess.SaveGoal(goal); Assert.AreEqual(1, MemoryDataContext.Queryable<Goal>().Count()); }
public void WhenExistingAthleteIsSavedAndWeightIsUnChangedShouldNotAddWeightHistory() { const int weight = 90; MemoryDataContext.Clear(); InsertDefaultAthlete(weight); _athlete.ID = 1; //saved var db = new AthleteDataAccess(); Assert.AreEqual(0, MemoryDataContext.Queryable<AthleteHealth>().Count()); var disconnectedAthleteWithSameWeight = new Athlete { ID = _athlete.ID, User = _athlete.User, Weight = weight }; db.SaveAthlete(disconnectedAthleteWithSameWeight); Assert.AreEqual(0, MemoryDataContext.Queryable<AthleteHealth>().Count()); }
public void WhenExistingAthleteIsSavedAndWeightIsNullShouldNotAddWeightHistory() { const int weightBefore = 90; MemoryDataContext.Clear(); InsertDefaultAthlete(weightBefore); _athlete.ID = 1; //saved var db = new AthleteDataAccess(); Assert.AreEqual(0, MemoryDataContext.Queryable<AthleteHealth>().Count()); var disconnectedAthleteThatHasGainedWeight = new Athlete { ID = _athlete.ID, User = _athlete.User, Weight = Athlete.NullIntValue }; db.SaveAthlete(disconnectedAthleteThatHasGainedWeight); Assert.AreEqual(0, MemoryDataContext.Queryable<AthleteHealth>().Count()); }
public void AssertFindsHistory() { const int pagesize = 5; var athleteBuilder = new AthleteBuilder(); var athlete = athleteBuilder.Build(); var query = new AthleteHealthQuery {PagingData = BuildPagingData(pagesize), Athlete = athlete}; MemoryDataContext.Clear(); MemoryDataContext.Add(athlete); InsertTestHealthHistory(athlete, pagesize*2); var athleteDataAccess = new AthleteDataAccess(); query = athleteDataAccess.GetHealthHistory(query); Assert.AreEqual(pagesize, query.AthleteHealthHistory.Count); Assert.AreEqual(pagesize*2, query.PagingData.TotalCount); }