Skip to content

Instantly share code, notes, and snippets.

@makomweb
Last active December 30, 2015 05:59
Show Gist options
  • Save makomweb/7785873 to your computer and use it in GitHub Desktop.
Save makomweb/7785873 to your computer and use it in GitHub Desktop.
Send a message to the WS server and receive a reply.
[Fact]
public async Task Getting_an_event_when_connecting_should_succeed()
{
using (var ws = new ReactiveWebSocket("ws://127.0.0.1:8080", true))
{
var man = new WebSocketManager(ws);
man.Send(new Message { Id = Guid.NewGuid().ToString() });
var res = await man.Results.FirstAsync();
Assert.Equal(typeof(IncomingEvent), res.GetType());
var ev = ((IncomingEvent) res).Event;
ev.Should().NotBeNull();
ev.Id.Should().Be(2);
ev.PreviousId.Should().Be(1);
ev.Client.Should().NotBeNull();
ev.Subject.Should().NotBeNull();
ev.Operation.Should().Be("update");
ev.Revision.Should().Be(2);
ev.Data["title"].Should().Be("Wow");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment