Beispiel #1
0
        private void butCreateProofreadingProject_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(textGetQuoteResources.Text))
            {
                tools.SetMsg("click", butResources);
                tools.SetMsg("enter", textGetQuoteResources);
                return;
            }

            if (String.IsNullOrWhiteSpace(combosource_language.Text))
            {
                tools.SetMsg("click", butSupportedLanguages);
                tools.SetMsg("enter", combosource_language);
                return;
            }

            //http://sandbox.onehourtranslation.com/api/2/projects/proof-general?notes=&sources=rsc-5618b9e3e272e2-73253523&secret_key=35aec76f5d9a015304173d1d81891f65&expertise=marketing-consumer-media&name=unittest+proof_translated+2015-10-13+17%3A23-02&source_language=en-us&callbackUrl=&public_key=c7t9NbMpG2xK6nvD834B&wordCount=0
            var r = _api.CreateProofreadingProjectSource(combosource_language.Text, textGetQuoteResources.Text, "", "", "marketing-consumer-media", "", "namne12");

            if (r.Status.Code == 0)
            {
                textProjectID.Text = r.Result.ProjectId.ToString();
            }
            MessageBox.Show(r.ToString());
        }
Beispiel #2
0
        public void Test()
        {
            Ohtapi ohtapi = new Ohtapi(Tools.TestPublicKey, Tools.TestSecretKey, true);

            Assert.IsNotNull(ohtapi);

            var result = ohtapi.CreateProofreadingProjectSource("en-us", "rsc-560e7ea4650793-27822858", "", "", "marketing-consumer-media", "", "name12");

            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.Status.Code);

            ohtapi = new Ohtapi("", "", true);
            result = ohtapi.CreateProofreadingProjectSource("en-us", "rsc-560e7ea4650793-27822858", "", "", "marketing-consumer-media", "", "name12");

            Assert.IsNotNull(result);
            Assert.AreNotEqual(0, result.Status.Code);
            Assert.AreNotEqual(-1, result.Status.Code);

            var provider = Substitute.For <ICreateProofreadingProjectSourceProvider>();

            ohtapi.CreateProofreadingProjectSourceProvider = provider;
            provider.Get(string.Empty, null, string.Empty, string.Empty, string.Empty, string.Empty).ReturnsForAnyArgs(ExpectedJsonResultOk);

            result = ohtapi.CreateProofreadingProjectSource(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.Status.Code);

            provider.Get(string.Empty, null, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty).ReturnsForAnyArgs(ExpectedJsonResultErr);
            result = ohtapi.CreateProofreadingProjectSource(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

            Assert.IsNotNull(result);
            Assert.AreNotEqual(0, result.Status.Code);
            Assert.AreNotEqual(-1, result.Status.Code);

            provider.Get(string.Empty, null, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty).ReturnsForAnyArgs(string.Empty);
            result = ohtapi.CreateProofreadingProjectSource(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

            Assert.IsNotNull(result);
            Assert.AreEqual(-1, result.Status.Code);
        }