Example #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);
        }
Example #2
0
        public void Add_ModelNotNull_Successful()
        {
            // Arrange
            var repo     = new RepositoryFactoryMemory();
            var bll      = new UserBLL(repo);
            var model    = new UserModel();
            var precount = repo.GetUserRepo().GetAll().Count();

            // Act
            bll.Add(model);

            // Assert
            Assert.AreEqual(repo.GetUserRepo().GetAll().Count(), precount + 1);
        }
Example #3
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);
        }
Example #4
0
        public void AssociateUserTostudy_NonexistantRoleId_ThrowArgumentOutOfRangeException()
        {
            // Arrange
            var repo = new RepositoryFactoryMemory();
            var bll  = new UserBLL(repo);

            repo.GetUserRepo().Create(new UserEntity()
            {
                Id = 10
            });
            repo.GetStudyRepo().Create(new StudyEntity()
            {
                Id = 15
            });

            // Act
            bll.AssociateUserToStudy(10, 15, 5);
        }
Example #5
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);
        }
Example #6
0
        public void Get_ElementExists_Successful()
        {
            // Arrange
            var repo = new RepositoryFactoryMemory();
            var bll  = new UserBLL(repo);

            repo.GetUserRepo().Create(new UserEntity
            {
                Id        = 10,
                FirstName = "Mathias",
                LastName  = "Pedersen"
            });

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

            // Assert
            Assert.AreEqual(model.Id, 10);
            Assert.AreEqual(model.FirstName, "Mathias");
            Assert.AreEqual(model.LastName, "Pedersen");
        }