public async Task Docs_Collaboration_Versioning_CheckOut()
        {
            // ALIGN
            // ReSharper disable once InconsistentNaming
            await using var Console = new StringWriter();
            await EnsureContentAsync("/Root/Content/IT/Document_Library", "DocumentLibrary");
            await EnsureContentAsync("/Root/Content/IT/Document_Library/Calgary", "Folder");
            await EnsureContentAsync("/Root/Content/IT/Document_Library/Calgary/BusinessPlan.docx", "File");

            try
            {
                // ACTION for doc
                var result = await RESTCaller.GetResponseJsonAsync(method : HttpMethod.Post, requestData : new ODataRequest
                {
                    IsCollectionRequest = false,
                    Path       = "/Root/Content/IT/Document_Library/Calgary/BusinessPlan.docx",
                    ActionName = "Checkout",
                });

                Console.WriteLine(result);

                // ASSERT
                var message = Console.GetStringBuilder().ToString();
                Assert.Inconclusive();
            }
            finally
            {
                var c = await Content.LoadAsync("/Root/Content/IT/Document_Library/Calgary/BusinessPlan.docx");

                if (c != null)
                {
                    await c.DeleteAsync(true);
                }
            }
        }
        public async Task <AuthorityInfo> GetAuthorityInfoAsync(ServerContext server, CancellationToken cancel = default)
        {
            var req = new ODataRequest(server)
            {
                Path       = "/Root",
                ActionName = "GetClientRequestParameters"
            };

            // The client type is hardcoded because the real client id
            // is provided by the repository using the request below.
            req.Parameters.Add("clientType", "client");

            //TODO: remove this assertion when the GetResponse method below
            // is able to receive a cancellation token.
            cancel.ThrowIfCancellationRequested();

            try
            {
                dynamic response = await RESTCaller.GetResponseJsonAsync(req, server)
                                   .ConfigureAwait(false);

                return(new AuthorityInfo
                {
                    Authority = response.authority,
                    ClientId = response.client_id
                });
            }
            catch (Exception ex)
            {
                _logger?.LogError(ex, $"Could not access repository {server.Url} for getting the authority url.");
            }

            return(new AuthorityInfo());
        }
        // GetContentAsync GetResponseStringAsync GetResponseJsonAsync
        public async Task Docs_BasicConcepts_Select()
        {
            // ACTION for doc
            dynamic content = await RESTCaller.GetContentAsync(new ODataRequest
            {
                Path   = "/Root/Content/IT",
                Select = new[] { "DisplayName", "Description" }
            });

            // ASSERT-1
            var responseString = await RESTCaller.GetResponseStringAsync(new ODataRequest
            {
                Path   = "/Root/Content/IT",
                Select = new[] { "DisplayName", "Description" }
            });

            Assert.AreEqual("{\"d\":{\"DisplayName\":\"IT\",\"Description\":null}}", responseString.RemoveWhitespaces());

            // ASSERT-2
            var responseJson = await RESTCaller.GetResponseJsonAsync(new ODataRequest
            {
                Path   = "/Root/Content/IT",
                Select = new[] { "DisplayName", "Description" }
            });

            var displayName = responseJson.d.DisplayName.ToString();
            var description = responseJson.d.Description.ToString();

            Assert.AreEqual(displayName, content.DisplayName.ToString());
            Assert.AreEqual(description, content.Description.ToString());
        }
        public async Task Docs_BasicConcepts_ChildrenInlineCount()
        {
            await EnsureContentAsync("/Root/Content/IT/Document_Library", "DocumentLibrary");

            //UNDONE:- Feature request: should returns a collection with property: TotalCount
            //var result3 = await Content.LoadCollectionAsync(new ODataRequest
            //{
            //    Path = "/Root/IMS/BuiltIn/Portal",
            //    Top = 3,
            //    Skip = 4,
            //    InlineCount = InlineCountOptions.AllPages // Default, AllPages, None
            //});

            // ACTION for doc
            var result = await RESTCaller.GetResponseJsonAsync(new ODataRequest
            {
                IsCollectionRequest = true,
                Path       = "/Root/Content/IT",
                Top        = 3,
                Skip       = 4,
                Parameters = { { "$inlinecount", "allpages" } }
            });

            // ASSERT
            // { "d": { "__count": 1, "results": [] }}

            var array       = ((JToken)result).SelectTokens("$.d.results.*").ToArray();
            var inlineCount = ((JToken)result).SelectToken("$.d.__count").Value <int>();

            Assert.AreNotEqual(0, inlineCount);
            Assert.AreNotEqual(array.Length, inlineCount);
        }
Example #5
0
        public async Task Docs_ContentManagement_ListFields_Select()
        {
            // ACTION for doc
            var result = await RESTCaller.GetResponseJsonAsync(new ODataRequest
            {
                IsCollectionRequest = false,
                Path   = "/Root/Content/IT",
                Select = new[] { "%23CustomField" }, // "%23": url encoded "#"
            });

            Console.WriteLine(result);

            // ASSERT
            Assert.Inconclusive();
        }
Example #6
0
        public async Task Docs_Preview_Main_GetComments()
        {
            Assert.Inconclusive();
            //UNDONE: this test has not run yet
            // ACTION for doc
            var result = await RESTCaller.GetResponseJsonAsync(new ODataRequest
            {
                IsCollectionRequest = false,
                Path       = "/Root/Content/IT/Document_Library/Calgary/BusinessPlan.docx",
                ActionName = "GetPreviewComments",
                Parameters = { { "page", "3" } }
            });

            //Console.WriteLine(result);

            // ASSERT
            Assert.Inconclusive();
        }
        public async Task Docs_Collaboration_SavedQueries_Get()
        {
            Assert.Inconclusive();
            //UNDONE:---- ERROR: (every second run if the test filter is: 'Docs_Collaboration_') Invalid response. Request: https://localhost:44362/OData.svc/Root/Content/IT/Document_Library/Calgary('BusinessPlan.docx')/GetQueries?metadata=no&onlyPublic=true. Response:
            // ACTION for doc
            var result = await RESTCaller.GetResponseJsonAsync(new ODataRequest
            {
                IsCollectionRequest = false,
                Path       = "/Root/Content/IT/Document_Library/Calgary/BusinessPlan.docx",
                ActionName = "GetQueries",
                Parameters = { { "onlyPublic", "true" } }
            });

            Console.WriteLine(result);

            // ASSERT
            Assert.Inconclusive();
        }
Example #8
0
        private static Task <dynamic> GetResponseJsonAsync(ODataRequest request, HttpMethod method = null, object body = null)
        {
            return(Retrier.RetryAsync(REQUEST_RETRY_COUNT, 50,
                                      async() => await RESTCaller.GetResponseJsonAsync(request, method: method ?? HttpMethod.Get, postData: body),
                                      (result, count, ex) =>
            {
                if (ex == null)
                {
                    return true;
                }

                // last try: throw the exception
                if (count == 1 || AsposeTools.ContentNotFound(ex))
                {
                    throw ex;
                }

                // failed, but give them a new chance
                return false;
            }));
        }
        public async Task Docs_Collaboration_Versioning_CheckIn()
        {
            Assert.Inconclusive();
            //UNDONE:---- ERROR: The server returned an error (HttpStatus: InternalServerError): Currently this action is not allowed on this content.
            // ALIGN
            // ReSharper disable once InconsistentNaming
            await using var Console = new StringWriter();
            await EnsureContentAsync("/Root/Content/IT/Document_Library", "DocumentLibrary");
            await EnsureContentAsync("/Root/Content/IT/Document_Library/Calgary", "Folder");
            await EnsureContentAsync("/Root/Content/IT/Document_Library/Calgary/BusinessPlan.docx", "File");

            try
            {
                // ACTION for doc
                var result = await RESTCaller.GetResponseJsonAsync(method : HttpMethod.Post, requestData : new ODataRequest
                {
                    IsCollectionRequest = false,
                    Path       = "/Root/Content/IT/Document_Library/Calgary/BusinessPlan.docx",
                    ActionName = "CheckIn",
                    Parameters = { { "checkInComments", "Adding new contract" } }
                });

                Console.WriteLine(result);

                // ASSERT
                var message = Console.GetStringBuilder().ToString();
                Assert.Inconclusive();
            }
            finally
            {
                var c = await Content.LoadAsync("/Root/Content/IT/Document_Library/Calgary/BusinessPlan.docx");

                if (c != null)
                {
                    await c.DeleteAsync(true);
                }
            }
        }