public void ActivateSeason_InvalidEndDate_ThrowsException()
        {
            var fakeContext = new Mock<IDatabaseContext>();
            Person person = new Person
            {
                Id = 1,
            };
            var accountGroupPeople = new List<AccountGroupPerson>()
            {
                new AccountGroupPerson
                {
                    PermissionLevel = PermissionLevel.Admin, // this is imporant
                    PersonId = 1,
                    Person = person,
                }
            };
            person.AccountGroupPeople = accountGroupPeople;
            Season season = new Season
            {
                Id = 1000,
                IsActive = false, //important
                EndDate = DateTime.Today.AddDays(1),
                AccountGroup = new AccountGroup()
                {
                    AccountGroupPeople = accountGroupPeople
                },
            };

            fakeContext.Setup(x => x.List<Season>()).Returns(new[] { season }.AsQueryable());
            fakeContext.Setup(x => x.List<Person>()).Returns(new[] { person }.AsQueryable());
            var mng = new SeasonManagement(fakeContext.Object, 1);

            mng.ActivateSeason(season.Id);
        }
        public void ActivateSeason_InvalidStartDate_ThrowsException()
        {
            var fakeContext = new Mock<IDatabaseContext>();
            Person person = new Person()
            {
                Id = 100
            };

            AccountGroupPerson personJoin = new AccountGroupPerson()
            {
                Person = person,
                PersonId = person.Id,
                PermissionLevel = PermissionLevel.Admin
            };
            AccountGroup accountGroup = new AccountGroup()
            {
                Id = 1000,
                AccountGroupPeople = new List<AccountGroupPerson>()
                {
                    personJoin,
                }
            };
            personJoin.AccountGroup = accountGroup;
            personJoin.AccountGroupId = accountGroup.Id;
            person.AccountGroupPeople = new[] { personJoin };
            Season season = new Season
            {
                Id = 2,
                IsActive = false,
                AccountGroup = accountGroup,
                StartDate = null,
                EndDate = DateTime.Today,
                AccountGroupId = accountGroup.Id,
            };

            fakeContext.Setup(x => x.List<Season>()).Returns(new[] { season }.AsQueryable());
            fakeContext.Setup(x => x.List<Person>()).Returns(new[] { person }.AsQueryable());
            SeasonManagement management = new SeasonManagement(fakeContext.Object, 100);
            management.ActivateSeason(2);
        }
 private SeasonAchievementManagement Resolve(Mock<IDatabaseContext> context, bool isValidUser)
 {
     if (isValidUser)
     {
         context.Setup(x => x.List<Person>()).Returns(new[] { new Person { Id = 1 } }.AsQueryable());
     }
     AchievementManagement a = new AchievementManagement(context.Object);
     SeasonManagement s = new SeasonManagement(context.Object, 1);
     return new SeasonAchievementManagement(context.Object, 0, a, s);
 }
 //takes two crud items
 public SeasonAchievementManagement(IDatabaseContext context, int personId, AchievementManagement achievementManagement, SeasonManagement seasonManagement)
     : base(context, personId)
 {
     _achievementManagement = achievementManagement;
     _seasonManagement = seasonManagement;
 }
 //takes two crud items
 public SeasonAchievementManagement(IDatabaseContext context, int personId, AchievementManagement achievementManagement, SeasonManagement seasonManagement)
     : base(context, personId)
 {
     _achievementManagement = achievementManagement;
     _seasonManagement      = seasonManagement;
 }