Ejemplo n.º 1
0
        public async Task TestGetQuotes()
        {
            var job1 = new Job
            {
                Slug = "quote job 1",
                Body = "Never gonna give you up",
                SourceLanguage = "en",
                TargetLanguage = "ja"
            };

            var job2 = new Job
            {
                Slug = "quote job 2",
                Body = "Never gonna let you down",
                SourceLanguage = "en",
                TargetLanguage = "ja",
                TranslationTier = TranslationTier.Ultra
            };

            var job3 = new Job
            {
                Slug = "quote job 3",
                Body = "Never gonna run around and desert you",
                SourceLanguage = "en",
                TargetLanguage = "ja",
                TranslationTier = TranslationTier.Pro
            };

            var quotes = await client.Service.GetQuote(true, job1, job2, job3);

            Assert.AreEqual(3, quotes.Length);
        }
        internal DuplicateSubmission(Job duplicateJob, IEnumerable<SubmittedJob> existingJobs)
        {
            if (duplicateJob == null)
                throw new ArgumentNullException("duplicateJob");

            if (existingJobs == null)
                throw new ArgumentNullException("existingJobs");

            DuplicateJob = duplicateJob;
            ExistingJobs = existingJobs.ToList().AsReadOnly();
        }
        internal DuplicateSubmission(Job duplicateJob, Job existingJob)
        {
            if (duplicateJob == null)
                throw new ArgumentNullException("duplicateJob");

            if (existingJob == null)
                throw new ArgumentNullException("existingJob");

            DuplicateJob = duplicateJob;
            ExistingJob = existingJob;

        }
Ejemplo n.º 4
0
        public async Task TestGetJobGroup()
        {
            var dt = DateTime.Now;

            var job1 = new Job
            {
                Slug = "group job 1 - " + dt.ToTimeStamp(),
                Body = "We are the wooooooorld - " + dt.ToString(),
                SourceLanguage = "en",
                TargetLanguage = "ja",
            };

            var job2 = new Job
            {
                Slug = "group job 2 - " + dt.ToTimeStamp(),
                Body = "We are the chiiiildren - " + dt.ToString(),
                SourceLanguage = "en",
                TargetLanguage = "ja",
                CallbackUrl = new Uri("http://www.zombo.com")
            };

            var res = await _client.Jobs.Submit(true, false, job1, job2);

            Assert.AreEqual(0, res.Duplicates.Count);
            Assert.AreEqual(true, res.HasGroupId);

            // This seems excessively low, but at 5 seconds, this test will
            // consistantly faily.
            Thread.Sleep(TimeSpan.FromSeconds(10));

            var group = await _client.Jobs.GetJobGroup(res.GroupId);

            Assert.AreNotEqual(new DateTime(), group.Created);
            Assert.AreEqual(res.JobCount, group.Count);
        }
Ejemplo n.º 5
0
        public async Task TestSubmitSameTwice()
        {
            var job1Dt = DateTime.Now;

            var job1 = new Job
            {
                Slug = "job 1 - " + job1Dt.ToTimeStamp(),
                Body = "JUSTICE " + job1Dt.Ticks,
                SourceLanguage = "en",
                TargetLanguage = "ja",
            };


            var job2Dt = DateTime.Now;

            var job2 = new Job
            {
                Slug = "job 2 - " + job2Dt.ToTimeStamp(),
                Body = "Unrelated fooo~~~~ " + job2Dt.Ticks,
                SourceLanguage = "en",
                TargetLanguage = "ja",
            };


            var first = await _client.Jobs.Submit(false, true, job1);

            Thread.Sleep(TimeSpan.FromSeconds(5));

            var second = await _client.Jobs.Submit(false, true, job1, job2);

            Assert.AreEqual(0, first.Duplicates.Count);
            Assert.AreEqual(1, second.Duplicates.Count);

            Assert.AreEqual(job1.Slug, second.Duplicates[0].ExistingJobs[0].Slug);
        }
Ejemplo n.º 6
0
        public async Task TestSubmitTwoJobs()
        {
            var job1Dt = DateTime.Now;

            var job1 = new Job
            {
                Slug = "job 1 - " + job1Dt.ToTimeStamp(),
                Body = job1Dt.ToString(),
                SourceLanguage = "ja",
                TargetLanguage = "en",
            };

            var job2Dt = DateTime.Now;

            var job2 = new Job
            {
                Slug = "job 2 - " + job1Dt.ToTimeStamp(),
                Body = job2Dt.ToString(),
                SourceLanguage = "en",
                TargetLanguage = "ja",
                CallbackUrl = new Uri("http://www.zombo.com")
            };

            var res = await _client.Jobs.Submit(false, true, job1, job2);

            Assert.AreEqual(2, res.JobCount);
        }
Ejemplo n.º 7
0
        public async Task TestSubmitVeryLargeText()
        {
            var dateTime = DateTime.Now;

            var job = new Job
            {
                Slug = "job 1 - " + dateTime.ToTimeStamp(),
                Body = new string('a', 500000),
                SourceLanguage = "ja",
                TargetLanguage = "en",
            };

            var result = await _client.Jobs.Submit(false, true, job);

            Assert.AreEqual(1, result.JobCount);
        }
Ejemplo n.º 8
0
        public async Task TestMaximumCharacters()
        {
            var dateTime = DateTime.Now;

            var job = new Job
            {
                Slug = "job 1 - " + dateTime.ToTimeStamp(),
                Body = "Max characters test" + dateTime,
                SourceLanguage = "ja",
                TargetLanguage = "en",
                MaximumCharacters = 20
            };

            var result = await _client.Jobs.Submit(false, true, job);

            Assert.AreEqual(1, result.JobCount);
        }