Пример #1
0
        public void Get_TypesOfAssociations_Correct()
        {
            // Arrange
            var repo = new RepositoryFactoryMemory();
            var bll  = new StudyBLL(repo);

            repo.GetStudyRepo().Create(new StudyEntity
            {
                Id          = 10,
                Name        = "name",
                Description = "desc"
            });
            repo.GetUserRepo().Create(new UserEntity()
            {
                Id        = 10,
                FirstName = "Mathias",
                LastName  = "Pedersen"
            });
            repo.GetUserRepo().Create(new UserEntity()
            {
                Id        = 11,
                FirstName = "John",
                LastName  = "Doe"
            });
            repo.GetStudyRoleRepo().Create(new StudyRoleEntity()
            {
                Id = 5, Name = "RoleWithId5"
            });
            repo.GetStudyRoleRepo().Create(new StudyRoleEntity()
            {
                Id = 6, Name = "RoleWithId6"
            });
            repo.GetUserStudyRelationRepo().Create(new UserStudyRelationEntity()
            {
                Study_Id     = 10,
                Id           = 10,
                StudyRole_Id = 5
            });
            repo.GetUserStudyRelationRepo().Create(new UserStudyRelationEntity()
            {
                Study_Id     = 10,
                Id           = 10,
                StudyRole_Id = 6
            });
            repo.GetUserStudyRelationRepo().Create(new UserStudyRelationEntity()
            {
                Study_Id     = 10,
                Id           = 11,
                StudyRole_Id = 5
            });


            // Act
            var model = bll.Get(10);

            // Assert
            var list = model.Persons.Where(pair => pair.Key.Id == 10).Select(pair => pair.Value).Single();

            Assert.AreEqual(2, list.Count);
        }
Пример #2
0
        public void Get_NumberOfAssociations_Correct()
        {
            // Arrange
            var repo = new RepositoryFactoryMemory();
            var bll  = new StudyBLL(repo);

            repo.GetStudyRepo().Create(new StudyEntity
            {
                Id          = 10,
                Name        = "name",
                Description = "desc"
            });
            repo.GetUserRepo().Create(new UserEntity()
            {
                Id        = 10,
                FirstName = "Mathias",
                LastName  = "Pedersen"
            });
            repo.GetUserRepo().Create(new UserEntity()
            {
                Id        = 11,
                FirstName = "John",
                LastName  = "Doe"
            });
            repo.GetStudyRoleRepo().Create(new StudyRoleEntity()
            {
                Id = 5, Name = "RoleWithId5"
            });
            repo.GetUserStudyRelationRepo().Create(new UserStudyRelationEntity()
            {
                Study_Id     = 10,
                Id           = 10,
                StudyRole_Id = 5
            });
            repo.GetUserStudyRelationRepo().Create(new UserStudyRelationEntity()
            {
                Study_Id     = 10,
                Id           = 11,
                StudyRole_Id = 5
            });
            var count = repo.GetUserStudyRelationRepo().GetAll().Count(r => r.Study_Id == 10);


            // Act
            var model = bll.Get(10);

            // Assert
            Assert.AreEqual(count, model.Persons.Count);
        }
Пример #3
0
        public void UnassociateUserToStudy_GoodInput_Success()
        {
            // Arrange
            var repo = new RepositoryFactoryMemory();
            var bll  = new UserBLL(repo);

            repo.GetUserStudyRelationRepo().Create(new UserStudyRelationEntity
            {
                Study_Id     = 15,
                StudyRole_Id = 2,
                Id           = 10
            });
            var count = repo.GetUserStudyRelationRepo().GetAll().Count();

            // Act
            bll.UnassociateUserToStudy(10, 15);

            // Assert
            Assert.AreEqual(count - 1, repo.GetUserStudyRelationRepo().GetAll().Count());
        }
Пример #4
0
        public void AssociateUserToStudy_GoodInput_Success()
        {
            // Arrange
            var repo = new RepositoryFactoryMemory();
            var bll  = new UserBLL(repo);

            repo.GetUserRepo().Create(new UserEntity()
            {
            });

            // Act
            bll.AssociateUserToStudy(10, 15, 5);

            // Assert
            var storedDto = repo.GetUserStudyRelationRepo().Read(10, 15);

            Assert.AreEqual(storedDto.Id, 10);
            Assert.AreEqual(storedDto.Study_Id, 15);
            Assert.AreEqual(storedDto.StudyRole_Id, 5);
        }