public void RegisterTwoSubscribersAndPublishMessageClient1Test() { MessageBusClient.UserCount = 0; var server = new MessageBusServer(); server.Start(_ipAddress, _port); var client1 = new MessageBusClient(); client1.Start(_ipAddress, _port); Thread.Sleep(_sleep); var client2 = new MessageBusClient(); client2.Start(_ipAddress, _port++); Thread.Sleep(_sleep); client1.RegisterProvider("channel1"); Thread.Sleep(_sleep); client1.RegisterSubscriber("channel1"); Thread.Sleep(_sleep); client2.RegisterSubscriber("channel1"); Thread.Sleep(_sleep); client1.PublishMessage("channel1", "message"); Thread.Sleep(_sleep); Thread.Sleep(_sleep); Assert.Equal("message", client1.ChannelMessageClient[0].MessageString); }
public void RegisterOneProviderAndRequestChannelsTest() { MessageBusClient.UserCount = 0; var server = new MessageBusServer(); server.Start(_ipAddress, _port); var client1 = new MessageBusClient(); client1.Start(_ipAddress, _port++); Thread.Sleep(1000); client1.RegisterProvider("channel1"); Thread.Sleep(_sleep); client1.RequestChannels(); Thread.Sleep(_sleep); Assert.Equal("channel1", client1.ChannelListMessageClient[0]); }
public void MultipleConnectionsTest() { MessageBusClient.UserCount = 0; var server = new MessageBusServer(); server.Start(_ipAddress, _port); var client1 = new MessageBusClient(); client1.Start(_ipAddress, _port); Thread.Sleep(1000); var client2 = new MessageBusClient(); client2.Start(_ipAddress, _port++); Thread.Sleep(_sleep); Assert.Equal(2, server.ConnectedClientCount); }