public async Task Publish_invalid_channel() { // arrange _fayeServerProcess.StartThinServer(); var socket = new WebSocketClient(uri: TEST_SERVER_URL); SetupWebSocket(socket); InstantiateFayeClient(); _connection = await _fayeClient.Connect(); const string invalidChannel = "/*"; var messageToSendObj = new TestMsg { Stuff = "the message" }; var messageToSend = JsonConvert.SerializeObject(messageToSendObj); // act + assert var exception = await _connection.InvokingAsync(c => c.Publish(channel: invalidChannel, message: messageToSend)) .ShouldThrow <PublishException>(); exception.Message .Should() .Be("405:/*:Invalid channel"); }
public async Task Subscribe_wildcard_channel() { // arrange _fayeServerProcess.StartThinServer(); var socket = new WebSocketClient(uri: TEST_SERVER_URL); SetupWebSocket(socket); InstantiateFayeClient(); _connection = await _fayeClient.Connect(); const string wildcardChannel = "/*"; Action <string> dummyAction = msg => Console.WriteLine("hi"); // act + assert var exception = await _connection.InvokingAsync(c => c.Subscribe(wildcardChannel, dummyAction)) .ShouldThrow <SubscriptionException>(); var expectedMessage = string.Format(FayeConnection.WILDCARD_CHANNEL_ERROR_FORMAT, wildcardChannel); exception.Message .Should() .Be(expectedMessage); }
public async Task Subscribe_reserved_channel_name() { // arrange _fayeServerProcess.StartThinServer(); var socket = new WebSocketClient(uri: TEST_SERVER_URL); SetupWebSocket(socket); InstantiateFayeClient(); _connection = await _fayeClient.Connect(); const string reservedChannelName = "/meta/subscribe"; Action <string> dummyAction = msg => Console.WriteLine("hi"); // act + assert var exception = await _connection.InvokingAsync(s => s.Subscribe(channel: reservedChannelName, messageReceivedAction: dummyAction)) .ShouldThrow <SubscriptionException>(); exception.Message .Should() .Be("403:/meta/subscribe:Forbidden channel"); }
public async Task Unsubscribe_not_currently_subscribed() { // arrange _fayeServerProcess.StartThinServer(); var socket = new WebSocketClient(uri: TEST_SERVER_URL); SetupWebSocket(socket); InstantiateFayeClient(); _connection = await _fayeClient.Connect(); const string channelWeDidntSubscribeTo = "/foobar"; // act + assert var exception = await _connection.InvokingAsync(c => c.Unsubscribe(channelWeDidntSubscribeTo)) .ShouldThrow <SubscriptionException>(); var expectedError = string.Format(FayeConnection.NOT_SUBSCRIBED, channelWeDidntSubscribeTo); exception.Message .Should() .Be(expectedError); }