public async Task New_ByCollectionId_WithFolder_CreatesNewDataObject(DataObjectSyncanoClient client)
        {
            //given
            var request = new DataObjectDefinitionRequest();

            request.ProjectId    = TestData.ProjectId;
            request.CollectionId = TestData.CollectionId;
            var folderClient =
                new FolderSyncanoClient(new SyncanoHttpClient(TestData.InstanceName, TestData.BackendAdminApiKey));
            var folder = await folderClient.New(TestData.ProjectId, "testFolder", TestData.CollectionId);

            request.Folder = folder.Name;

            //when
            var result = await client.New(request);

            //then
            result.ShouldNotBeNull();
            result.Folder.ShouldEqual(request.Folder);
            result.Folder.ShouldEqual(folder.Name);

            //cleanup
            var deleteRequest = new DataObjectSimpleQueryRequest();

            deleteRequest.ProjectId    = TestData.ProjectId;
            deleteRequest.CollectionId = TestData.CollectionId;
            deleteRequest.DataId       = result.Id;
            await client.Delete(deleteRequest);

            await folderClient.Delete(TestData.ProjectId, folder.Name, TestData.CollectionId);
        }
Exemple #2
0
        public async Task GetOne_ByCollectionKey(FolderSyncanoClient client)
        {
            //when
            var folder = await client.GetOne(TestData.ProjectId, TestData.FolderName, collectionKey : TestData.CollectionKey);

            //then
            folder.Id.ShouldEqual(TestData.FolderId);
            folder.Name.ShouldEqual(TestData.FolderName);
        }
Exemple #3
0
        public async Task Get_ByCollectionKey(FolderSyncanoClient client)
        {
            //when
            var response = await client.Get(TestData.ProjectId, collectionKey : TestData.CollectionKey);

            //then
            response.ShouldNotBeEmpty();
            response.Any(f => f.Name == TestData.FolderName).ShouldBeTrue();
        }
Exemple #4
0
        public async Task Delete_ByCollectionKey(FolderSyncanoClient client)
        {
            //given
            string folderName = "Delete test " + DateTime.Now.ToLongTimeString() + " " +
                                DateTime.Now.ToShortDateString();
            await client.New(TestData.ProjectId, folderName, collectionKey : TestData.CollectionKey);

            //when
            var result = await client.Delete(TestData.ProjectId, folderName, collectionKey : TestData.CollectionKey);

            //then
            result.ShouldBeTrue();
        }
Exemple #5
0
        public async Task New_WithInvalidProjectId_ThrowsException(FolderSyncanoClient client)
        {
            try
            {
                //when
                await client.New("abcde", TestData.FolderName, TestData.CollectionId);

                throw new Exception("New should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType <SyncanoException>();
            }
        }
Exemple #6
0
        public async Task New_WithNullProjectId_ThrowsException(FolderSyncanoClient client)
        {
            try
            {
                //when
                await client.New(null, TestData.FolderName, TestData.CollectionId);

                throw new Exception("New should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType <ArgumentNullException>();
            }
        }
Exemple #7
0
        public async Task Update_WithInvalidFolderName_ThrowsException(FolderSyncanoClient client)
        {
            try
            {
                //when
                await client.Update(TestData.ProjectId, "abcde", TestData.CollectionId);

                throw new Exception("Update should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType <SyncanoException>();
            }
        }
Exemple #8
0
        public async Task Update_WithNullIdAndKey_ThrowsException(FolderSyncanoClient client)
        {
            try
            {
                //when
                await client.Update(TestData.ProjectId, TestData.FolderName);

                throw new Exception("Update should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType <ArgumentNullException>();
            }
        }
Exemple #9
0
        public async Task GetOne_WithNullFolderName_ThrowsException(FolderSyncanoClient client)
        {
            try
            {
                //when
                await client.GetOne(TestData.ProjectId, null, TestData.CollectionId);

                throw new Exception("GetOne should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType <ArgumentNullException>();
            }
        }
Exemple #10
0
        public async Task New_ByCollectionKey(FolderSyncanoClient client)
        {
            //given
            string folderName = "NewFolderTest  " + DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToShortDateString();

            //when
            var folder = await client.New(TestData.ProjectId, folderName,
                                          collectionKey : TestData.CollectionKey);

            //then
            folder.Id.ShouldNotEqual(null);

            //cleanup
            await client.Delete(TestData.ProjectId, folderName, collectionKey : TestData.CollectionKey);
        }
Exemple #11
0
        public async Task GetOne_WithInvalidIdAndKey_ThrowsException(FolderSyncanoClient client)
        {
            try
            {
                //when
                await client.GetOne(TestData.ProjectId, TestData.FolderName, "abcde", "abcde");

                throw new Exception("GetOne should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType <SyncanoException>();
            }
        }
Exemple #12
0
        public async Task Authorize_WithInvalidIdAndKey_ThrowsException(FolderSyncanoClient client)
        {
            try
            {
                //when
                await client.Authorize(TestData.UserApiClientId, Permissions.DeleteData, TestData.ProjectId,
                                       TestData.FolderName, "abcde", "abcde");

                throw new Exception("Authorize should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType <SyncanoException>();
            }
        }
Exemple #13
0
        public async Task Deauthorize_WithNullFolderName_ThrowsException(FolderSyncanoClient client)
        {
            try
            {
                //when
                await client.Deauthorize(TestData.UserApiClientId, Permissions.DeleteData, TestData.ProjectId,
                                         null, TestData.CollectionId);

                throw new Exception("Deauthorize should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType <ArgumentNullException>();
            }
        }
Exemple #14
0
        public async Task Deauthorize_WithInvalidUserApiKey_ThrowsException(FolderSyncanoClient client)
        {
            try
            {
                //when
                await client.Deauthorize("abcde", Permissions.DeleteData, TestData.ProjectId,
                                         TestData.FolderName, TestData.CollectionId);

                throw new Exception("Deauthorize should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType <SyncanoException>();
            }
        }
Exemple #15
0
        public async Task Update_ByCollectionKey(FolderSyncanoClient client)
        {
            //given
            string folderName = "Test " + DateTime.Now.ToLongTimeString() + " " +
                                DateTime.Now.ToShortDateString();
            string newFolderName = "Update test " + DateTime.Now.ToLongTimeString() + " " +
                                   DateTime.Now.ToShortDateString();
            await client.New(TestData.ProjectId, folderName, TestData.CollectionId);

            //when
            var result = await client.Update(TestData.ProjectId, folderName, null, TestData.CollectionKey, newFolderName,
                                             "qwerty");

            //then
            result.ShouldBeTrue();

            //cleanup
            await client.Delete(TestData.ProjectId, newFolderName, collectionKey : TestData.CollectionKey);
        }
Exemple #16
0
        public async Task Deauthorize_ByCollectionKey(FolderSyncanoClient client)
        {
            //given
            string folderName = "Authorize Test " + DateTime.Now.ToLongTimeString() + " " +
                                DateTime.Now.ToShortDateString();

            await client.New(TestData.ProjectId, folderName, collectionKey : TestData.CollectionKey);

            await client.Authorize(TestData.UserApiClientId, Permissions.CreateData, TestData.ProjectId,
                                   TestData.FolderName, collectionKey : TestData.CollectionKey);

            //when
            var result = await client.Deauthorize(TestData.UserApiClientId, Permissions.CreateData, TestData.ProjectId,
                                                  TestData.FolderName, collectionKey : TestData.CollectionKey);

            //then
            result.ShouldBeTrue();

            //cleanup
            await client.Delete(TestData.ProjectId, folderName, collectionKey : TestData.CollectionKey);
        }
        public async Task Delete_MultipleFolders(DataObjectSyncanoClient client)
        {
            //given
            var request = new DataObjectDefinitionRequest();

            request.ProjectId    = TestData.ProjectId;
            request.CollectionId = TestData.CollectionId;
            var folderClient =
                new FolderSyncanoClient(new SyncanoHttpClient(TestData.InstanceName, TestData.BackendAdminApiKey));
            var folderOne = await folderClient.New(TestData.ProjectId, "folderOne", TestData.CollectionId);

            var folderTwo = await folderClient.New(TestData.ProjectId, "folderTwo", TestData.CollectionId);

            var folderThree = await folderClient.New(TestData.ProjectId, "folderThree", TestData.CollectionId);

            request.Folder = folderOne.Name;
            var dataObjectOne = await client.New(request);

            request.Folder = folderTwo.Name;
            var dataObjectTwo = await client.New(request);

            request.Folder = folderThree.Name;
            var dataObjectThree = await client.New(request);

            var folders = new List <string> {
                folderOne.Name, folderTwo.Name
            };
            var deleteRequest = new DataObjectSimpleQueryRequest();

            deleteRequest.ProjectId    = TestData.ProjectId;
            deleteRequest.CollectionId = TestData.CollectionId;
            deleteRequest.Folders      = folders;
            deleteRequest.Folder       = folderThree.Name;

            //when
            var result = await client.Delete(deleteRequest);

            //then
            try
            {
                await client.GetOne(TestData.ProjectId, TestData.CollectionId, dataId : dataObjectOne.Id);

                throw new Exception("GetOne should throw an exception");
            }
            catch (Exception e)
            {
                e.ShouldBeType <SyncanoException>();
            }

            try
            {
                await client.GetOne(TestData.ProjectId, TestData.CollectionId, dataId : dataObjectTwo.Id);

                throw new Exception("GetOne should throw an exception");
            }
            catch (Exception e)
            {
                e.ShouldBeType <SyncanoException>();
            }

            try
            {
                await client.GetOne(TestData.ProjectId, TestData.CollectionId, dataId : dataObjectThree.Id);

                throw new Exception("GetOne should throw an exception");
            }
            catch (Exception e)
            {
                e.ShouldBeType <SyncanoException>();
            }

            result.ShouldBeTrue();

            //cleanup
            await folderClient.Delete(TestData.ProjectId, folderOne.Name, TestData.CollectionId);

            await folderClient.Delete(TestData.ProjectId, folderTwo.Name, TestData.CollectionId);

            await folderClient.Delete(TestData.ProjectId, folderThree.Name, TestData.CollectionId);
        }