public void Test() { Ohtapi ohtapi = new Ohtapi(Tools.TestPublicKey, Tools.TestSecretKey, true); Assert.IsNotNull(ohtapi); var result = ohtapi.GetWordCount("rsc-560e7ea4650793-27822858"); Assert.IsNotNull(result); Assert.AreEqual(0, result.Status.Code); ohtapi = new Ohtapi("", "", true); result = ohtapi.GetWordCount("rsc-560e7ea4650793-27822858"); Assert.IsNotNull(result); Assert.AreNotEqual(0, result.Status.Code); Assert.AreNotEqual(-1, result.Status.Code); var provider = Substitute.For <IGetWordCountProvider>(); ohtapi.GetWordCountProvider = provider; provider.Get(string.Empty, null, string.Empty, string.Empty, string.Empty).ReturnsForAnyArgs(ExpectedJsonResultOk); result = ohtapi.GetWordCount(string.Empty); Assert.IsNotNull(result); Assert.AreEqual(0, result.Status.Code); provider.Get(string.Empty, null, string.Empty, string.Empty, string.Empty).ReturnsForAnyArgs(ExpectedJsonResultErr); result = ohtapi.GetWordCount(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).ReturnsForAnyArgs(string.Empty); result = ohtapi.GetWordCount(string.Empty); Assert.IsNotNull(result); Assert.AreEqual(-1, result.Status.Code); }
private void butGetWordCount_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(textGetQuoteResources.Text)) { tools.SetMsg("enter", textGetQuoteResources); return; } var r = _api.GetWordCount(textGetQuoteResources.Text); textWordcount.Text = r.Status.Code == 0 ? r.Result.Total.Wordcount.ToString() : ""; MessageBox.Show(r.ToString()); }