public PollRequest(string title, List <string> options, bool multi, DupCheck dupcheck, bool captcha) { Title = title; Options = options; Multi = multi; Dupcheck = dupcheck; Captcha = captcha; }
public void Can_Check_Duplicate_Chars_In_String() { // Arrange DupCheck d = new DupCheck(); // Act bool trueCase = d.Check("This string has duplicate chars"); bool falseCase = d.Check("No duplicates"); // Assert Assert.IsTrue(trueCase); Assert.IsFalse(falseCase); }
internal static string CreateRequest(string title, List <string> options, bool multi = true, DupCheck dupcheck = DupCheck.Normal, bool capcha = false) { JObject obj = new JObject { { "title", title }, { "options", new JArray(options) }, { "multi", multi } }; switch (dupcheck) { case DupCheck.Normal: obj.Add("dupcheck", "normal"); break; case DupCheck.Permissive: obj.Add("dupcheck", "permissive"); break; case DupCheck.Disabled: obj.Add("dupcheck", "disabled"); break; } obj.Add("captcha", capcha); return(obj.ToString()); }
public async Task <Poll> CreatePollAsync(string title, List <string> options, bool multi, DupCheck dupcheck, bool capcha) { HttpResponseMessage resultJson; var jsondata = Request.CreateRequest(title, options, multi, dupcheck, capcha); using (var client = new HttpClient()) { var content = new StringContent(jsondata, Encoding.UTF8, "application/json"); resultJson = await client.PostAsync(endpointURL, content); } return(JsonConvert.DeserializeObject <Poll>(await resultJson.Content.ReadAsStringAsync())); }