public void AddAnExistingResourceToAnExistingList()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                BlobShareDataStoreEntities context = BlobShareDataStoreEntities.CreateInstance();
                BlobSet set = CreateBlobSetForTest("Test List", context);
                Blob blob = BlobServicesTests.CreateBlobForTest("Test Resource", context);

                BlobSetService service = new BlobSetService(context);
                service.AddBlobToSet(set.Name, blob.BlobId);

                BlobSet newSet = service.GetBlobSetById(set.BlobSetId);

                Assert.IsNotNull(newSet);
                Assert.AreEqual(1, newSet.Blobs.Count);

                BlobService bservices = new BlobService(context, CloudStorageAccount.DevelopmentStorageAccount, TestContainerName);
                Blob newResource = bservices.GetBlobById(blob.BlobId);

                Assert.IsNotNull(newResource);
                Assert.AreEqual(1, newResource.BlobSets.Count);

                Assert.AreEqual(newResource.BlobSets.First().BlobSetId, set.BlobSetId);
                Assert.AreEqual(newSet.Blobs.First().BlobId, blob.BlobId);
            }
        }
        public void AddRoleToBlobSet()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                BlobShareDataStoreEntities context = BlobShareDataStoreEntities.CreateInstance();
                BlobSetService setService = new BlobSetService(context);
                BlobSet set = new BlobSet()
                {
                    Name = "Resource Set Test",
                    Description = "Resource Set Test"
                };
                setService.CreateBlobSet(set);

                Role role = CreateRoleForTest("testrole1", context);
                PermissionService service = new PermissionService(context);
                Permission permission = service.GrantPermissionToRoleBlobSet(Privilege.Read, role, set, DateTime.UtcNow.AddDays(1));

                Assert.IsNotNull(permission);
                Assert.AreEqual(role, permission.Roles.First());
                Assert.AreEqual(set, permission.BlobSet);
                Assert.AreEqual((int)Privilege.Read, permission.Privilege);

                IEnumerable<BlobSet> sets = service.GetBlobSetsByRole(role);

                Assert.IsNotNull(sets);
                Assert.AreEqual(1, sets.Count());
                Assert.AreEqual(set.BlobSetId, sets.First().BlobSetId);
            }
        }
        public void AddUserToBlobSet()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                BlobShareDataStoreEntities context = BlobShareDataStoreEntities.CreateInstance();
                BlobSetService setService = new BlobSetService(context);
                BlobSet set = new BlobSet()
                {
                    Name = "Resource Set Test",
                    Description = "Resource Set Test"
                };
                setService.CreateBlobSet(set);

                User user = CreateUserForTest("testuser1", context);
                PermissionService service = new PermissionService(context);
                Permission permission = service.GrantPermissionToUserBlobSet(Privilege.Read, user, set, DateTime.UtcNow.AddDays(1));

                Assert.IsNotNull(permission);
                Assert.AreEqual(user, permission.Users.First());
                Assert.AreEqual(set, permission.BlobSet);
                Assert.AreEqual((int)Privilege.Read, permission.Privilege);

                IEnumerable<BlobSet> sets = service.GetBlobSetsByUser(user);

                Assert.IsNotNull(sets);
                Assert.AreEqual(1, sets.Count());
                Assert.AreEqual(set.BlobSetId, sets.First().BlobSetId);

                Assert.IsTrue(service.CheckPermissionToBlobSet(user.NameIdentifier, user.IdentityProvider, set.BlobSetId));
            }
        }
 public ChangesNotificationService(BlobShareDataStoreEntities context, BlobSetService blobSetService, SmtpNotificationService smtpNotificationService)
 {
     this.context = context;
     this.blobSetService = blobSetService;
     this.smtpNotificationService = smtpNotificationService;
 }
Beispiel #5
0
 public ChangesNotificationService(BlobShareDataStoreEntities context, BlobSetService blobSetService, SmtpNotificationService smtpNotificationService)
 {
     this.context                 = context;
     this.blobSetService          = blobSetService;
     this.smtpNotificationService = smtpNotificationService;
 }
        private static BlobSet CreateBlobSetForTest(string name, BlobShareDataStoreEntities context)
        {
            var service = new BlobSetService(context);
            BlobSet entity = new BlobSet()
            {
                Name = name
            };

            service.CreateBlobSet(entity);

            return entity;
        }
        public void UpdateExistingList()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                BlobShareDataStoreEntities context = BlobShareDataStoreEntities.CreateInstance();
                BlobSet set = CreateBlobSetForTest("Test List", context);
                Blob blob = BlobServicesTests.CreateBlobForTest("Test Resource", context);

                BlobSetService service = new BlobSetService(context);
                service.AddBlobToSet(set.Name, blob.BlobId);

                set.Name = "updated test list";
                set.Description = "updated test description";
                service.UpdateBlobSet(set);

                BlobSet newSet = service.GetBlobSetById(set.BlobSetId);

                Assert.IsNotNull(newSet);
                Assert.AreEqual(1, newSet.Blobs.Count);
                Assert.AreEqual(set.Name, newSet.Name);
                Assert.AreEqual(set.Description, newSet.Description);
            }
        }