Exemplo n.º 1
0
 public PollRequest(string title, List <string> options, bool multi, DupCheck dupcheck, bool captcha)
 {
     Title    = title;
     Options  = options;
     Multi    = multi;
     Dupcheck = dupcheck;
     Captcha  = captcha;
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
        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()));
        }