public void Send_to_standIn()
{
var cre = PubnubCredentials.LoadFrom("pubnub credentials.txt");
using(var sut = new PubnubHostTransceiver(cre, "hostchannel"))
{
var standIn = new Pubnub(cre.PublishingKey, cre.SubscriptionKey, cre.SecretKey);
try
{
var standInChannel = Guid.NewGuid().ToString();
var are = new AutoResetEvent(false);
ReadOnlyCollection<object> result = null;
standIn.subscribe(standInChannel, (ReadOnlyCollection<object> _) =>
{
result = _;
are.Set();
});
var ho = new HostOutput{CorrelationId = Guid.NewGuid(), Data = "hello".Serialize(), Portname = "portname"};
sut.SendToStandIn(new Tuple<string, HostOutput>(standInChannel, ho));
Assert.IsTrue(are.WaitOne(5000));
var hoReceived = Convert.FromBase64String((string)((JValue)result[0]).Value).Deserialize() as HostOutput;
Assert.AreEqual(ho.CorrelationId, hoReceived.CorrelationId);
Assert.AreEqual(ho.Data, hoReceived.Data);
Assert.AreEqual(ho.Portname, hoReceived.Portname);
}
finally
{
standIn.subscribe("standIn", _ => {});
}
}
}