public void MessagesMadeFromSetContainKeyGivenToConstructor(string key) { Chatbase.MessageSet set = new Chatbase.MessageSet(key); Chatbase.Message msg = set.NewMessage(); Assert.Equal(msg.api_key, key); set.Add(msg); Assert.Equal(set.GetMessages().Count, 1); }
public async Task <HttpResponseMessage> Send(MessageSet set) { MemoryStream stream = new MemoryStream(); DataContractJsonSerializer ser = new DataContractJsonSerializer( typeof(MessageSet), new Type[] { typeof(MessageCollection), typeof(Message) }); ser.WriteObject(stream, set); stream.Position = 0; StreamReader sr = new StreamReader(stream); string json = sr.ReadToEnd(); string url = String.Format(Client.BatchMessageEndpoint, set.api_key); StringContent content = new StringContent(json, Encoding.UTF8, Client.ContentType); return(await client.PostAsync(url, content)); }
public void SendingValidSetReturnsSuccess(string uid, string plt, string ver) { string key = Environment.GetEnvironmentVariable("CB_TEST_API_KEY"); if (String.IsNullOrEmpty(key)) { ChatbaseClientUnitTests.PrintNoAPIKeyWarning(); } else { Chatbase.MessageSet set = new Chatbase.MessageSet(key); Chatbase.Message msg = set.NewMessage(); msg.user_id = uid; msg.platform = plt; msg.version = ver; set.Add(msg); var resp = _client.Send(set).Result; Assert.Equal(resp.StatusCode, HttpStatusCode.OK); } }
public void KeyToConstructorPropagatesToInstance(string key) { Chatbase.MessageSet set = new Chatbase.MessageSet(key); Assert.Equal(set.api_key, key); }