Ejemplo n.º 1
0
        public async Task GetDocumentStatusesOrderByCreatedOn()
        {
            // create client
            var client = GetClient();

            // create translation job
            var operation = await CreateSingleTranslationJobAsync(client, docsCount : 3);

            await operation.WaitForCompletionAsync();

            // list docs
            var options = new GetDocumentStatusesOptions
            {
                OrderBy = { new DocumentFilterOrder(property: DocumentFilterProperty.CreatedOn, ascending: false) }
            };

            var filterResults = operation.GetDocumentStatuses(options: options);

            // assert
            var timestamp = Recording.UtcNow;

            foreach (var result in filterResults)
            {
                Assert.IsTrue(result.CreatedOn <= timestamp);
                timestamp = result.CreatedOn;
            }
        }
Ejemplo n.º 2
0
        public async Task GetDocumentStatusesFilterByStatusTest()
        {
            // create client
            var client = GetClient();

            // create translation job
            var operation = await CreateSingleTranslationJobAsync(client, docsCount : 2);

            await operation.WaitForCompletionAsync();

            // list docs
            var options = new GetDocumentStatusesOptions
            {
                Statuses = { DocumentTranslationStatus.Succeeded }
            };
            var result = operation.GetDocumentStatuses(options: options);

            // assert.
            Assert.That(result.All(d => d.Status == DocumentTranslationStatus.Succeeded));
        }
Ejemplo n.º 3
0
        public async Task GetDocumentStatusesFilterByIdsTest()
        {
            // create client
            var client = GetClient();

            // create translation job
            var operation = await CreateSingleTranslationJobAsync(client, docsCount : 2);

            await operation.WaitForCompletionAsync();

            var testIds = operation.GetDocumentStatuses().Select(d => d.Id).ToList().GetRange(0, 1);

            // list docs
            var options = new GetDocumentStatusesOptions
            {
                Ids = { testIds[0] }
            };

            var result = operation.GetDocumentStatuses(options: options);

            // assert
            Assert.That(result.All(d => testIds.Contains(d.Id)));
        }
Ejemplo n.º 4
0
        public async Task GetDocumentStatusesFilterByCreatedAfter()
        {
            // create client
            var client = GetClient();

            // create translation job
            var operation = await CreateSingleTranslationJobAsync(client, docsCount : 5);

            await operation.WaitForCompletionAsync();

            // option to sort in order of Created On
            var optionsOrdering = new GetDocumentStatusesOptions
            {
                OrderBy = { new DocumentFilterOrder(property: DocumentFilterProperty.CreatedOn, ascending: true) }
            };

            var testCreatedOnDateTimes = operation.GetDocumentStatuses(options: optionsOrdering).Select(d => d.CreatedOn).ToList();

            var optionsCreatedAfterLastDate = new GetDocumentStatusesOptions
            {
                CreatedAfter = testCreatedOnDateTimes[4]
            };

            var optionsCreatedAfterIndex2 = new GetDocumentStatusesOptions
            {
                CreatedAfter = testCreatedOnDateTimes[2]
            };

            var docsAfterLastDate   = operation.GetDocumentStatuses(options: optionsCreatedAfterLastDate).ToList();
            var docsAfterIndex2Date = operation.GetDocumentStatuses(options: optionsCreatedAfterIndex2).ToList();

            // Asserting that only the last document is returned
            Assert.AreEqual(1, docsAfterLastDate.Count());

            // Asserting that the last 3/5 docs are returned
            Assert.AreEqual(3, docsAfterIndex2Date.Count());
        }