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);
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
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>();
            }
        }
Ejemplo n.º 4
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>();
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }