コード例 #1
1
        public void GetAnonymousCompetitions()
        {
            var repository = new RepositoryForTests<Competition>();
            repository.TheContent.Add(new Competition
            {
                CompetitionType = CompetitionType.Field,
                Id = Guid.NewGuid(),
                IsPublic = true,
                Name = "Public1",
                StartDate = DateTime.Now,
                UseNorwegianCount = false
            });
            repository.TheContent.Add(new Competition
            {
                CompetitionType = CompetitionType.Field,
                Id = Guid.NewGuid(),
                IsPublic = false,
                Name = "Private1",
                StartDate = DateTime.Now,
                UseNorwegianCount = false
            });

            var rightsHelperMock = new Mock<IRightsHelper>();

            var userRolesInfoMock = new Mock<IRepository<UserRolesInfo>>();

            var competitions = new CompetitionsLogic(repository, userRolesInfoMock.Object, rightsHelperMock.Object);

            var result = competitions.GetCompetitions();
            Assert.AreEqual(1, result.Count());
        }
コード例 #2
0
        public void GetPrivateAndPublicCompetitions()
        {
            var repository = new RepositoryForTests<Competition>();
            repository.TheContent.Add(new Competition
            {
                CompetitionType = CompetitionType.Field,
                Id = Guid.NewGuid(),
                IsPublic = true,
                Name = "Public1",
                StartDate = DateTime.Now,
                UseNorwegianCount = false
            });
            repository.TheContent.Add(new Competition
            {
                CompetitionType = CompetitionType.Field,
                Id = Guid.Parse("{bd4cc387-4e7a-42ae-807a-7a750f3680ea}"),
                IsPublic = true,
                Name = "Private1",
                StartDate = DateTime.Now,
                UseNorwegianCount = false
            });

            var rightsHelperMock = new Mock<IRightsHelper>();
            rightsHelperMock.Setup(x => x.GetCompetitionIdsTheUserHasRightsOn(false))
                .Returns(new[] { Guid.Parse("{bd4cc387-4e7a-42ae-807a-7a750f3680ea}") });

            var userRolesInfoMock = new Mock<IRepository<UserRolesInfo>>();

            var competitions = new CompetitionsLogic(repository, userRolesInfoMock.Object, rightsHelperMock.Object) { CurrentUser = new User() };

            var result = competitions.GetCompetitions();
            Assert.AreEqual(2, result.Count());
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompetitionService"/> class.
 /// </summary>
 public CompetitionService()
 {
     this.log = LogManager.GetLogger(this.GetType());
     this.databaseSession = NHibernateHelper.OpenSession();
     this.logic = new CompetitionsLogic(this.databaseSession);
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompetitionsService"/> class.
 /// </summary>
 public CompetitionsService()
 {
     this.databaseSession = NHibernateHelper.OpenSession();
     this.logic = new CompetitionsLogic(this.databaseSession);
 }