public void Test_0400_VerifyPhone_OK() { Kii.Initialize("appId", "appKey", Kii.Site.US); MockHttpClientFactory factory = new MockHttpClientFactory(); Kii.HttpClientFactory = factory; // set response MockHttpClient client = factory.Client; this.setStandardResponse(client); // LogIn KiiUser user = KiiUser.LogIn("kii1234", "pass1234"); Assert.IsNotNull(KiiUser.CurrentUser); Assert.AreEqual(false, user.PhoneVerified); // set response client.AddResponse(204, ""); // verification user.VerifyPhone("1234"); Assert.AreEqual(true, user.PhoneVerified); }
public void Test_0401_VerifyPhone_null() { // set response this.setStandardResponse(); // LogIn KiiUser target = null; Exception exp = null; KiiUser.LogIn("kii1234", "pass1234", (KiiUser user, Exception e) => { target = user; exp = e; }); Assert.AreEqual("abcd", target.ID); Assert.IsNull(exp); Assert.IsNotNull(KiiUser.CurrentUser); Assert.AreEqual(false, target.PhoneVerified); // set response this.mockClient.AddResponse(204, ""); // verification target.VerifyPhone(null, (KiiUser user, Exception e) => { target = user; exp = e; }); Assert.IsNull(target); Assert.IsInstanceOfType(typeof(ArgumentException), exp); }
public void Test_0402_VerifyPhone_server_error() { this.setStandardResponse(); // LogIn // LogIn KiiUser target = null; Exception exp = null; KiiUser.LogIn("kii1234", "pass1234", (KiiUser user, Exception e) => { target = user; exp = e; }); Assert.AreEqual("abcd", target.ID); Assert.IsNull(exp); Assert.IsNotNull(KiiUser.CurrentUser); Assert.AreEqual(false, target.PhoneVerified); // set response this.mockClient.AddResponse(new CloudException(400, "{}")); // verification target.VerifyPhone("1234", (KiiUser user, Exception e) => { target = user; exp = e; }); Assert.IsNull(target); Assert.IsInstanceOfType(typeof(CloudException), exp); }
public void Test_0400_VerifyPhone_OK() { this.setStandardResponse(); // LogIn KiiUser target = null; Exception exp = null; KiiUser.LogIn("kii1234", "pass1234", (KiiUser user, Exception e) => { target = user; exp = e; }); Assert.AreEqual("abcd", target.ID); Assert.IsNull(exp); Assert.IsNotNull(KiiUser.CurrentUser); Assert.AreEqual(false, target.PhoneVerified); this.mockClient.AddResponse(204, ""); // verification target.VerifyPhone("1234", (KiiUser user, Exception e) => { target = user; exp = e; }); Assert.IsNull(exp); Assert.IsTrue(target.PhoneVerified); }