Example #1
0
        public List<Athlete> CreateRandomAthletes(int numberOfAthletes)
        {
            var r = new RandomProvider();
            var dateMin = new DateTime(1920, 1, 1);
            var dateMax = new DateTime(2020, 1, 1);
            var athletes = new List<Athlete>();
            using (var db = new DbDataContext())
            {
                var athleteCountBefore = db.Athletes.Count();
                for (var i = 0; i < numberOfAthletes; i++)
                {
                    var firstName = _randomFirstNamePrefix + i;
                    var lastName = _randomLastNamePrefix + i;

                    //var guid = Guid.NewGuid().ToString();
                    var user = new User { Password = "******", UserName = firstName, Roles = "" };

                    var athlete = new Athlete
                                      {
                                          FirstName = firstName,
                                          LastName = lastName,
                                          DateOfBirth = r.Next(dateMin, dateMax),
                                          User = user
                                      };
                    athletes.Add(athlete);
                    db.Users.InsertOnSubmit(user);
                }
                db.SubmitChanges();
                var athleteCountAfter = db.Athletes.Count();
                Assert.AreEqual(numberOfAthletes, athletes.Count);
                Assert.AreEqual(athleteCountAfter, athleteCountBefore + numberOfAthletes);
            }
            return athletes;
        }
Example #2
0
        private void InsertDefaultAthlete(int weight)
        {
            var user = new User { ID = 1, Password = "******", UserName = "******" };
            MemoryDataContext.InsertOnSubmit(user);
            MemoryDataContext.Commit();

            new UserDataAccess().Save(user);

            _athlete = new Athlete { ID = 0, User = user, Weight = weight};

            new AthleteDataAccess().SaveAthlete(_athlete);
        }
Example #3
0
        public User CreateUserWithDefaultAthlete(string emailAsUserName, string password)
        {
            var user = new User {Password = password, UserName = emailAsUserName};
            DataContext.InsertOnSubmit(user);
            DataContext.Commit();
            user.CustomerID = user.ID.ToString();
            DataContext.Commit();

            var athlete = new Athlete {User = user};
            DataContext.InsertOnSubmit(athlete);
            DataContext.Commit();

            return user;
        }
Example #4
0
        public Athlete Build()
        {
            var user = new User {UserName = "******", ID = 10};

            var dateOfBirth = DateTime.MinValue;
            var athlete =
                new Athlete
                              {
                                  DateOfBirth = dateOfBirth,
                                  FirstName = "Gryffe",
                                  ID = 1,
                                  LastName = null,
                                  User = user,
                              };
            return athlete;
        }
Example #5
0
 public void LogoutUser(User user)
 {
     user.SetAuthenticated(false);
 }
Example #6
0
 public Athlete GetAthlete(User user)
 {
     var existingAthlete = DataContext.Queryable<Athlete>().Single(athlete => athlete.User.Equals(user));
     return existingAthlete;
 }
Example #7
0
 partial void DeleteUser(User instance);
Example #8
0
 partial void UpdateUser(User instance);
Example #9
0
 partial void InsertUser(User instance);
Example #10
0
 public User Save(User user)
 {
     DataContext.UpdateAndAttach(user);
     DataContext.Commit();
     return user;
 }