Example #1
0
        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());
        }
Example #2
0
        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());
        }