Implements repository details IRepositoryDetails leveraging entity framework
상속: RepositoryBase, IRepositoryDetails
        public void Get_All_Repositories_Test()
        {
            IRepositoryDetails repository = new RepositoryDetails(testDBContext);

            var repositories = repository.RetrieveRepositories().ToList();

            Assert.IsNotNull(repositories);

            Assert.AreEqual(repositories.Count(), 2);
        }
        public void Get_All_Repository_Types_Test()
        {
            IRepositoryDetails repository = new RepositoryDetails(testDBContext);

            var repositories = repository.RetrieveRepositoryTypes().ToList();

            Assert.IsNotNull(repositories);

            Assert.AreEqual(repositories.Count(), 1);

            Assert.AreEqual(repositories[0].BaseRepositoryId, 1);
            Assert.AreEqual(repositories[0].Name, "Merrit");
        }
        public void Update_Repository_Test()
        {
            IRepositoryDetails repository = new RepositoryDetails(testDBContext);

            var selRep = repository.GetRepositoryById(1);

            // Updating data
            selRep.AllowedFileTypes = "Updated FileTypes";
            selRep.HttpDeleteUriTemplate = "Updated HttpDeleteUriTemplate";
            selRep.HttpGetUriTemplate = "Updated HttpGetUriTemplate";
            selRep.HttpIdentifierUriTemplate = "Updated HttpIdentifierUriTemplate";
            selRep.HttpPostUriTemplate = "Updated HttpPostUriTemplate";
            selRep.ImpersonatingPassword = "******";
            selRep.ImpersonatingUserName = "******";
            selRep.IsImpersonating = true;
            selRep.IsVisibleToAll = false;
            selRep.Name = "Updated Name";
            selRep.UserAgreement = "Updated UserAgreement";

            repository.UpdateRepository(selRep);

            testDBContext.Commit();

            var updatedRep = repository.GetRepositoryById(1);

            Assert.IsNotNull(updatedRep);

            Assert.AreEqual(updatedRep.AllowedFileTypes, "Updated FileTypes");
            Assert.AreEqual(updatedRep.HttpDeleteUriTemplate, "Updated HttpDeleteUriTemplate");
            Assert.AreEqual(updatedRep.HttpGetUriTemplate, "Updated HttpGetUriTemplate");
            Assert.AreEqual(updatedRep.HttpIdentifierUriTemplate, "Updated HttpIdentifierUriTemplate");
            Assert.AreEqual(updatedRep.HttpPostUriTemplate, "Updated HttpPostUriTemplate");
            Assert.AreEqual(updatedRep.ImpersonatingPassword, "Updated ImpersonatingPassword");
            Assert.AreEqual(updatedRep.ImpersonatingUserName, "Updated ImpersonatingUserName");
            Assert.AreEqual(updatedRep.Name, "Updated Name");
            Assert.AreEqual(updatedRep.UserAgreement, "Updated UserAgreement");

            Assert.IsTrue((bool)updatedRep.IsImpersonating);
            Assert.IsFalse(updatedRep.IsVisibleToAll);
        }
 private void AddRepository(Repository repo)
 {
     IRepositoryDetails repository = new RepositoryDetails(testDBContext);
     repository.AddRepository(repo);
     testDBContext.Commit();
 }
 private void AddBaseRepository(BaseRepository repo)
 {
     IRepositoryDetails repository = new RepositoryDetails(testDBContext);
     testDBContext.BaseRepositories.Add(repo);
     testDBContext.Commit();
 }
 private void AddRepositoryMetadataFields(RepositoryMetadataField repMetadataField)
 {
     IRepositoryDetails repository = new RepositoryDetails(testDBContext);
     testDBContext.RepositoryMetadataFields.Add(repMetadataField);
     testDBContext.Commit();
 }
 private void AddRepositoryMetadata(RepositoryMetadata repMetadata)
 {
     IRepositoryDetails repository = new RepositoryDetails(testDBContext);
     testDBContext.RepositoryMetadata.Add(repMetadata);
     testDBContext.Commit();
 }
 private void AddMetaDataType(MetadataType metaDataType)
 {
     IRepositoryDetails repository = new RepositoryDetails(testDBContext);
     testDBContext.MetadataTypes.Add(metaDataType);
     testDBContext.Commit();
 }
        public void Delete_Repository_Test()
        {
            IRepositoryDetails repository = new RepositoryDetails(testDBContext);

            Repository delRep = repository.DeleteRepository(1);

            Assert.AreEqual(delRep.Name, "Repository1");
            Assert.AreEqual(delRep.RepositoryId, 1);

            testDBContext.Commit();
            var repList = repository.RetrieveRepositories();

            Assert.AreEqual(repList.Count(), 1);
        }
        public void Add_Repository_Test()
        {
            IRepositoryDetails repository = new RepositoryDetails(testDBContext);

            Repository repositoryObject = new Repository()
            {
                AllowedFileTypes = "xlsx,nc,csv",
                CreatedBy = 1,
                // Files = null,
                CreatedOn = DateTime.Now,
                HttpDeleteUriTemplate = "http://google.com",
                HttpGetUriTemplate = "http://google.com",
                HttpIdentifierUriTemplate = "http://google.com",
                HttpPostUriTemplate = "http://google.com",
                ImpersonatingPassword = "******",
                ImpersonatingUserName = "******",
                IsActive = true,
                IsImpersonating = true,
                ModifiedBy = 1,
                ModifiedOn = DateTime.Now,
                Name = "AddedRepository",
                RepositoryId = 3,
                UserAgreement = "Test Agreement Added",
                BaseRepositoryId = 1
            };

            AddRepository(repositoryObject);

            var addedRepository = repository.GetRepositoryById(3);

            Assert.AreEqual(addedRepository.AllowedFileTypes, repositoryObject.AllowedFileTypes);

            Assert.AreEqual(addedRepository.CreatedBy, repositoryObject.CreatedBy);

            Assert.AreEqual(addedRepository.CreatedOn, repositoryObject.CreatedOn);

            Assert.AreEqual(addedRepository.HttpDeleteUriTemplate, repositoryObject.HttpDeleteUriTemplate);

            Assert.AreEqual(addedRepository.HttpGetUriTemplate, repositoryObject.HttpGetUriTemplate);

            Assert.AreEqual(addedRepository.HttpIdentifierUriTemplate, repositoryObject.HttpIdentifierUriTemplate);

            Assert.AreEqual(addedRepository.HttpPostUriTemplate, repositoryObject.HttpPostUriTemplate);

            Assert.AreEqual(addedRepository.ImpersonatingPassword, repositoryObject.ImpersonatingPassword);

            Assert.AreEqual(addedRepository.ImpersonatingUserName, repositoryObject.ImpersonatingUserName);

            Assert.AreEqual(addedRepository.IsActive, repositoryObject.IsActive);

            Assert.AreEqual(addedRepository.IsImpersonating, repositoryObject.IsImpersonating);

            Assert.AreEqual(addedRepository.ModifiedBy, repositoryObject.ModifiedBy);

            Assert.AreEqual(addedRepository.ModifiedOn, repositoryObject.ModifiedOn);

            Assert.AreEqual(addedRepository.Name, repositoryObject.Name);

            Assert.AreEqual(addedRepository.RepositoryId, repositoryObject.RepositoryId);

            Assert.AreEqual(addedRepository.UserAgreement, repositoryObject.UserAgreement);
        }
 public void Throw_Exception_On_Delete_Null_Repository_Test()
 {
     IRepositoryDetails repository = new RepositoryDetails(testDBContext);
     repository.DeleteRepository(8);
 }
        public void Get_Repository_By_Name_Test()
        {
            IRepositoryDetails repository = new RepositoryDetails(testDBContext);

            var selRep = repository.GetRepositoryByName("Repository1");

            Assert.AreEqual(selRep.AllowedFileTypes, "xlsx,nc,csv");
            Assert.AreEqual(selRep.HttpDeleteUriTemplate, "http://google.com");
            Assert.AreEqual(selRep.HttpGetUriTemplate, "http://google.com");
            Assert.AreEqual(selRep.HttpIdentifierUriTemplate, "http://google.com");
            Assert.AreEqual(selRep.HttpPostUriTemplate, "http://google.com");
            Assert.AreEqual(selRep.ImpersonatingPassword, "pwd");
            Assert.AreEqual(selRep.ImpersonatingUserName, "user1");
            Assert.AreEqual(selRep.ModifiedBy, 1);
            Assert.AreEqual(selRep.CreatedBy, 1);
            Assert.AreEqual(selRep.Name, "Repository1");
            Assert.AreEqual(selRep.RepositoryId, 1);
            Assert.AreEqual(selRep.UserAgreement, "Test Agreement1");
            Assert.AreEqual(selRep.BaseRepositoryId, 1);

            Assert.IsTrue((bool)selRep.IsActive);
            Assert.IsTrue((bool)selRep.IsImpersonating);
            Assert.IsTrue(selRep.IsVisibleToAll);
        }
        public void Get_Repository_By_Name_Empty_Test()
        {
            IRepositoryDetails repository = new RepositoryDetails(testDBContext);

            var selRep = repository.GetRepositoryByName("EmptyRepository");

            Assert.IsNull(selRep);
        }
        public void Get_Base_Reopository_Name_Test()
        {
            IRepositoryDetails repository = new RepositoryDetails(testDBContext);

            var repName = repository.GetBaseRepositoryName(1);

            Assert.IsNotNull(repName);
            Assert.AreEqual(repName, "Merrit");
        }
        public void Get_Base_Reopository_Name_Empty_Test()
        {
            IRepositoryDetails repository = new RepositoryDetails(testDBContext);

            var repName = repository.GetBaseRepositoryName(2);

            Assert.IsNotNull(repName);
            Assert.AreEqual(repName, string.Empty);
        }