コード例 #1
0
        public Fixture(TeamLeague homeTeamLeague, TeamLeague awayTeamLeague, DateTime fixtureDate, User lastUpdatedBy)
            : this()
        {
            // Check for required values
            Check.Require(homeTeamLeague != null, "homeTeamLeague must be provided");
            Check.Require(awayTeamLeague != null, "awayTeamLeague must be provided");
            Check.Require(lastUpdatedBy != null, "lastUpdatedBy must be provided");

            this.HomeTeamLeague = homeTeamLeague;
            this.AwayTeamLeague = awayTeamLeague;
            this.FixtureDate    = fixtureDate;
            this.LastUpdatedBy  = lastUpdatedBy;
        }
コード例 #2
0
 public void Setup()
 {
     user           = new User();
     season         = new Season(2008, 2009);
     homeTeam       = new Team("home", "homeTeam");
     awayTeam       = new Team("away", "awayTeam");
     league         = new League(season, "league desc", 1, 1);
     teamLeagueHome = new TeamLeague(league, homeTeam, "home", "homeTeam");
     teamLeagueAway = new TeamLeague(league, awayTeam, "away", "awayTeam");
     player         = new Player("Phil", "Hale");
     fixtureDate    = DateTime.Today;
     fixture        = new Fixture(teamLeagueHome, teamLeagueAway, fixtureDate, user);
 }
コード例 #3
0
        public void SaveMatchResult_GameNotCancelled_Success()
        {
            Fixture fixture = new Fixture() { IsCancelled = "N" };
            User user = new User() { UserName = "******"};

            matchResultService.SaveMatchResult(fixture, user);

            Assert.That(fixture.IsCancelled, Is.EqualTo("N"));
            Assert.That(fixture.ResultAddedDate, Is.Not.Null);
            Assert.That(fixture.LastUpdated, Is.Not.Null);
            Assert.That(fixture.LastUpdatedBy.UserName, Is.EqualTo(user.UserName));

            mockFixtureService.Received().Update(fixture);
            mockFixtureService.Received().Commit();
        }
コード例 #4
0
        public Fixture MapToFixture(Fixture fixture, TeamLeague homeTeamLeague, TeamLeague awayTeamLeague, Referee referee1, Referee referee2, User lastUpdatedBy, OneOffVenue oneOffVenue)
        {
            fixture.HomeTeamLeague = homeTeamLeague;
            fixture.AwayTeamLeague = awayTeamLeague;
            fixture.LastUpdatedBy  = lastUpdatedBy;
            fixture.LastUpdated    = DateTime.Now;

            // If you remove the few lines below accessing the referee objects you cannot reliably
            // set the properties to null. The assignment seems to be ignored.
            // By best guess is that the properties aren't lazy loaded until accessed so if you assign
            // a value to the property then read from it, the value gets loaded from the database. F****d up.
            fixture.Referee1.Touch();
            fixture.Referee2.Touch();

            fixture.Referee1 = referee1;
            fixture.Referee2 = referee2;

            fixture.OneOffVenue.Touch();
            fixture.OneOffVenue = oneOffVenue;

            return fixture;
        }
コード例 #5
0
 public void MapToModel(User user)
 {
     User = user;
     TeamId = user.Team.Id;
 }
コード例 #6
0
 public UserViewModel()
 {
     User = new User();
 }
コード例 #7
0
        public bool ValidateUser(User user, string password)
        {
            if (user == null)
                return false;

            return user.Password == password.ToMd5();
        }
コード例 #8
0
 public void SaveUser(User user)
 {
     membershipRepository.InsertOrUpdateUser(user);
 }
コード例 #9
0
        public void ValidateUser_ValidDetails_ReturnTrue()
        {
            var user = new User() { Password = "******" };
            mockMembershipRepository.GetUserByUserName("phil1").Returns(user);

            // Probably violating some unit testing principle here
            var returnValue = membershipService.ValidateUser("phil1", "password");

            Assert.That(returnValue, Is.True);
        }
コード例 #10
0
        public void GetRolesForUser_ZeroRoles_ReturnEmptyList()
        {
            User userWithZeroRoles = new User() { SiteAdmin = false, TeamAdmin = false };
            mockMembershipRepository.GetUserByUserName("joe").Returns(userWithZeroRoles);

            var returnedRoles = membershipService.GetRolesForUser("joe");

            Assert.That(returnedRoles, Is.Not.Null);
            Assert.That(returnedRoles.Count, Is.EqualTo(0));
        }
コード例 #11
0
 public void Setup()
 {
     user = new User();
     season = new Season(2008, 2009);
     homeTeam = new Team("home", "homeTeam");
     homeTeam.Id = 1;
     awayTeam = new Team("away", "awayTeam");
     awayTeam.Id = 2;
     league = new League(season, "league desc", 1, 1);
     homeTeamLeague = new TeamLeague(league, homeTeam, "home", "homeTeam");
     awayTeamLeague = new TeamLeague(league, awayTeam, "away", "awayTeam");
     fixtureDate = DateTime.Today;
 }
コード例 #12
0
 public void InsertOrUpdateUser(User user)
 {
     userRepository.InsertOrUpdate(user);
 }
コード例 #13
0
        // This is a bit confusing. It's not really saving the match result. What's the point?
        public Fixture SaveMatchResult(Fixture fixtureToUpdate, User lastUpdatedBy, int? forfeitingTeamId = null)
        {
            if(forfeitingTeamId.HasValue && fixtureToUpdate.IsForfeit)
                fixtureToUpdate.ForfeitingTeam = fixtureToUpdate.HomeTeamLeague.Team.Id == forfeitingTeamId ? fixtureToUpdate.HomeTeamLeague.Team : fixtureToUpdate.AwayTeamLeague.Team;
            else if(fixtureToUpdate.HasPlayerStats.YesNoToBool())
            {
                fixtureToUpdate.IsForfeit = false;
                fixtureToUpdate.ForfeitingTeam.Touch();
                fixtureToUpdate.ForfeitingTeam = null;
            }

            fixtureToUpdate.IsPlayed = "Y"; // TODO Add tickbox for played?

            if (fixtureToUpdate.ResultAddedDate == null)
                fixtureToUpdate.ResultAddedDate = DateTime.Now;

            fixtureToUpdate.LastUpdated = DateTime.Now;
            fixtureToUpdate.LastUpdatedBy = lastUpdatedBy;

            fixtureService.Update(fixtureToUpdate);
            Commit();

            return fixtureToUpdate;
        }
コード例 #14
0
 public ActionResult Edit(User @user)
 {
     if (ModelState.IsValid) {
                 userService.Update(@user);
                 userService.Commit();
                 SuccessMessage(FormMessages.SaveSuccess);
                 return RedirectToAction("Index");
         }
         return View(@user);
 }
コード例 #15
0
        //public void AddTeamLeaguePenalty(int teamLeagueId, int penaltyPoints)
        //{
        //    TeamLeague teamLeague = teamLeagueRepository.Get(teamLeagueId);
        //    teamLeague.PointsPenalty = penaltyPoints;
        //    //teamLeague = teamLeagueRepository.SaveOrUpdate(teamLeague);
        //    //FlushSessionAndEvict(teamLeague);
        //}
        private Fixture AddFixture(TeamLeague home, TeamLeague away, string fixtureDate, User lastUpdatedBy)
        {
            Fixture fixture = new Fixture(home, away, DateTime.Parse(fixtureDate), lastUpdatedBy);

            fixture.IsCupFixture = false;
            //fixture = fixtureRepository.SaveOrUpdate(fixture);
            //FlushSessionAndEvict(fixture);

            CurrentSeasonFixtures.Add(fixture);

            return fixture;
        }
コード例 #16
0
        public void GetRolesForUser_HasRoles_ReturnRoleList()
        {
            User userWithRoles = new User() {SiteAdmin = true, TeamAdmin = true};
            mockMembershipRepository.GetUserByUserName("joe").Returns(userWithRoles);

            var returnedRoles = membershipService.GetRolesForUser("joe");

            Assert.That(returnedRoles, Is.Not.Null);
            Assert.That(returnedRoles.Count, Is.EqualTo(2));
            Assert.Contains("Site Admin", returnedRoles);
            Assert.Contains("Team Admin", returnedRoles);
        }
コード例 #17
0
 private User AddUser()
 {
     User myUser = new User();
     myUser.UserName = "******";
     myUser.SiteAdmin = true;
     return myUser;
 }
コード例 #18
0
        public static User CreateUser()
        {
            User user = new User();

            user.Team = CreateTeam();

            EntityIdSetter.SetIdOf(user, 1);
            return user;
        }