public void ValidationExceptionTest() { //Arrange Twizo twizo = new Twizo(TwizoTests.apiKey, TwizoTests.apiHost); var verification = twizo.CreateVerification("601151174973"); verification.tokenLength = 11; verification.tag = "This tag contains more than 30 characters."; verification.validity = 1; //Act try { verification.Send(); } catch (ValidationException e) { var errors = e.errorFields; List <string> errorNames = errors.Select(x => x.name).ToList(); //Assert Assert.IsTrue(e.Message.StartsWith("Validation error for field")); Assert.AreEqual(errors.Count, 3); Assert.IsTrue(errorNames.Contains("tag") && errorNames.Contains("tokenLength") && errorNames.Contains("validity")); } }
public void CreateVerificationTestNull() { //Arrange string recipient = null; Twizo twizo = new Twizo(apiKey, apiHost); //Act var verification = twizo.CreateVerification(recipient); //Assert Assert.AreEqual(verification.recipient, recipient); }
public void Send() { //Create entity Twizo twizo = new Twizo(this.apiKey, this.apiHost); TwizoAPI.Entity.Verification verification; if (call) { verification = twizo.CreateVerificationCall(this.recipient); } else { verification = twizo.CreateVerification(this.recipient); } //Set variables verification.type = this.type; verification.tokenLength = this.tokenLength; verification.tokenType = this.tokenType; if (this.tag != "") { verification.tag = this.tag; } if (this.sessionId != "") { verification.sessionId = this.sessionId; } verification.validity = this.validity; verification.bodyTemplate = this.bodyTemplate; verification.sender = this.sender; if (this.senderTon >= 0) { verification.senderTon = this.senderTon; } if (this.senderTon >= 0) { verification.senderNpi = this.senderNpi; } verification.dcs = this.dcs; //Send verification.Send(); //Log LogResponse(verification); this.messageId = verification.messageId; }
public void GetVerificationTest() { //Arrange string recipient = "601151174973"; Twizo twizo = new Twizo(apiKey, apiHost); //Act var verification = twizo.CreateVerification(recipient); verification.Send(); string messageId = verification.messageId; var newVerficiation = twizo.GetVerification(messageId); //Assert Assert.AreEqual(verification.messageId, newVerficiation.messageId); Assert.AreEqual(verification.recipient, newVerficiation.recipient); }