GetChannelAsync() public method

public GetChannelAsync ( ) : Task
return Task
		public async Task Should_Round_Robin_Between_Existing_Channels()
		{
			/* Setup */
			_channelConfig.MaxChannelCount = 3;
			_channelConfig.InitialChannelCount = 3;
			_connection
				.Setup(c => c.IsOpen)
				.Returns(true);
			_connection
				.SetupSequence(c => c.CreateModel())
				.Returns(_thirdChannel.Object)
				.Returns(_firstChannel.Object)
				.Returns(_secondChannel.Object);
			_firstChannel
				.Setup(c => c.IsOpen)
				.Returns(true);
			_secondChannel
				.Setup(c => c.IsOpen)
				.Returns(true);
			_thirdChannel
				.Setup(c => c.IsOpen)
				.Returns(true);
			var factory = new ChannelFactory(_connectionFactory.Object, _config, _channelConfig);

			/* Test */
			var first = await factory.GetChannelAsync();
			var second = await factory.GetChannelAsync();
			var third = await factory.GetChannelAsync();
			var firstAgain = await factory.GetChannelAsync();
			var secondAgain = await factory.GetChannelAsync();
			var thirdAgain = await factory.GetChannelAsync();

			/* Assert */
			Assert.Equal(first, _firstChannel.Object);
			Assert.Equal(second, _secondChannel.Object);
			Assert.Equal(third, _thirdChannel.Object);
			Assert.Equal(firstAgain, _firstChannel.Object);
			Assert.Equal(secondAgain, _secondChannel.Object);
			Assert.Equal(thirdAgain, _thirdChannel.Object);
		}
		public async Task Should_Not_Return_Close_Channel()
		{
			/* Setup */
			_channelConfig.MaxChannelCount = 3;
			_channelConfig.InitialChannelCount = 3;
			_connection
				.Setup(c => c.IsOpen)
				.Returns(true);
			_connection
				.SetupSequence(c => c.CreateModel())
				.Returns(_thirdChannel.Object)
				.Returns(_firstChannel.Object)
				.Returns(_secondChannel.Object);
			_firstChannel
				.Setup(c => c.IsOpen)
				.Returns(true);
			_secondChannel
				.SetupSequence( c => c.IsOpen)
				.Returns(true)
				.Returns(false);
			_thirdChannel
				.Setup(c => c.IsOpen)
				.Returns(true);
			_secondChannel
				.Setup(c => c.CloseReason)
				.Returns(new ShutdownEventArgs(ShutdownInitiator.Application, 200, "Test"));
			var factory = new ChannelFactory(_connectionFactory.Object, _config, _channelConfig);

			/* Test */
			var first = await factory.GetChannelAsync();
			var second = await factory.GetChannelAsync();
			var third = await factory.GetChannelAsync();
			var firstAgain = await factory.GetChannelAsync();
			var thirdAgain = await factory.GetChannelAsync();

			/* Assert */
			Assert.Equal(first, _firstChannel.Object);
			Assert.Equal(second, _secondChannel.Object);
			Assert.Equal(third, _thirdChannel.Object);
			Assert.Equal(firstAgain, _firstChannel.Object);
			Assert.Equal(thirdAgain, _thirdChannel.Object);
		}