public void GetAllSubAreas() { var client = new LeadsClient(baseUrl); var subAreas = client.GetAllSubAreas(); Assert.IsTrue(subAreas.Count > 0, $"{nameof(subAreas)} is empty"); }
public void GetFilteredSubAreaWithEmptyPin() { var pinCode = string.Empty; var client = new LeadsClient(baseUrl); Assert.Throws <InvalidOperationException>(() => client.GetFilteredSubArea(pinCode), "[exception] was not thrown as expected"); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new LeadsClient(connection); var filters = new LeadFilters { PageSize = 1, PageCount = 1, StartPage = 0, ArchivedStatus = ArchivedStatus.not_archived, }; await client.GetAll(filters); Received.InOrder(async() => { await connection.GetAll <Lead>( Arg.Is <Uri>(u => u.ToString() == "leads"), Arg.Is <Dictionary <string, string> >(d => d.Count == 1 && d["archived_status"] == "not_archived"), Arg.Is <ApiOptions>(o => o.PageSize == 1 && o.PageCount == 1 && o.StartPage == 0)); }); }
public void GetFilteredSubAreaWithSpecialCharacters() { var pinCode = "{]}@(*&)"; var client = new LeadsClient(baseUrl); var subAreas = client.GetFilteredSubArea(pinCode); Assert.IsTrue(subAreas.Count == 0, $"{nameof(subAreas)} quantity is not expected amount"); }
public void GetFilteredSubAreaWithNoResults() { var pinCode = "000"; var client = new LeadsClient(baseUrl); var subAreas = client.GetFilteredSubArea(pinCode); Assert.IsTrue(subAreas.Count == 0, $"{nameof(subAreas)} quantity is not expected amount"); }
public void GetFilteredSubAreaWithSpecialCharacters2() { //Expected to fail as handing '+' on server side is not well done var pinCode = "+"; var client = new LeadsClient(baseUrl); var subAreas = client.GetFilteredSubArea(pinCode); Assert.IsTrue(subAreas.Count == 0, $"{nameof(subAreas)} quantity is not expected amount"); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new LeadsClient(connection); await client.Get(new Guid("42b9e030-0e5c-11eb-8c38-a7dff179fdd2")); Received.InOrder(async() => { await connection.Get <Lead>(Arg.Is <Uri>(u => u.ToString() == "leads/42b9e030-0e5c-11eb-8c38-a7dff179fdd2")); }); }
/// <summary> /// /// </summary> /// <param name="clientId"></param> /// <param name="clientSecret"></param> public VoiqClient(string clientId, string clientSecret, Environments environment) { BaseUrl = GetBaseUrl(environment); ClientId = clientId; ClientSecret = clientSecret; Calls = new PhoneCallsClient(this); Campaigns = new CampaignsClient(this); Leads = new LeadsClient(this); Questions = new QuestionsClient(this); SurveyResults = new SurveyResultsClient(this); Surveys = new SurveysClient(this); }
public void CreateLeadWithMismatchingSubAreaAndPin() { var client = new LeadsClient(baseUrl); var subAreas = client.GetAllSubAreas(); var selectedArea = subAreas[0]; var leadModel = new LeadsSaveViewModel() { Name = "User1", Email = "*****@*****.**", MobileNumber = "123456789", Address = "FakeAddress", PinCode = "6", SubAreaId = 1 }; Assert.Throws <InvalidOperationException>(() => client.CreateLead(leadModel), "[exception] was not thrown as expected"); }
public void CreateLeadWithFilteredSubArea() { var client = new LeadsClient(baseUrl); var selectedPin = "567"; var subAreas = client.GetFilteredSubArea(selectedPin); var selectedArea = subAreas[0]; var leadModel = new LeadsSaveViewModel() { Name = "User1", Email = "*****@*****.**", MobileNumber = "123456789", Address = "FakeAddress", PinCode = selectedArea.PinCode, SubAreaId = selectedArea.Id }; var result = client.CreateLead(leadModel); Assert.IsNotEmpty(result.Id, $"[{nameof(result.Id)}] empty"); //search for created lead var searchLead = client.SearchLead(result.Id); //compare lead model Assert.AreEqual(leadModel.Name, searchLead.Name, $"[{nameof(searchLead.Name)}] not as expected"); Assert.AreEqual(leadModel.Address, searchLead.Address, $"[{nameof(searchLead.Address)}] not as expected"); Assert.AreEqual(leadModel.Email, searchLead.Email, $"[{nameof(searchLead.Email)}] not as expected"); Assert.AreEqual(leadModel.MobileNumber, searchLead.MobileNumber, $"[{nameof(searchLead.MobileNumber)}] not as expected"); Assert.AreEqual(leadModel.PinCode, searchLead.PinCode, $"[{nameof(searchLead.PinCode)}] not as expected"); Assert.AreEqual(leadModel.SubAreaId, searchLead.SubAreaId, $"[{nameof(searchLead.SubAreaId)}] not as expected"); //compare subarea model Assert.AreEqual(selectedArea.Name, searchLead.SubArea.Name, $"[{nameof(searchLead.SubArea.Name)}] not as expected"); Assert.AreEqual(selectedArea.Id, searchLead.SubArea.Id, $"[{nameof(searchLead.SubArea.Id)}] not as expected"); Assert.AreEqual(selectedArea.PinCode, searchLead.SubArea.PinCode, $"[{nameof(searchLead.SubArea.PinCode)}] not as expected"); //Additional verificaion Assert.AreEqual(selectedPin, searchLead.PinCode, $"[{nameof(searchLead.PinCode)}] not as expected"); }
public void CreateLeadNameSpecialCharacters() { var client = new LeadsClient(baseUrl); var subAreas = client.GetAllSubAreas(); var selectedArea = subAreas[0]; var leadModel = new LeadsSaveViewModel() { Name = "User1!@#$%^&*()_0", Email = "*****@*****.**", MobileNumber = "123456789", Address = "FakeAddress", PinCode = selectedArea.PinCode, SubAreaId = selectedArea.Id }; var result = client.CreateLead(leadModel); Assert.IsNotEmpty(result.Id, $"[{nameof(result.Id)}] empty"); }
public async Task EnsuresNonNullArguments() { var client = new LeadsClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(null)); }