//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldProvideUniquePorts() internal virtual void ShouldProvideUniquePorts() { PortProvider portProvider = new SimplePortProvider(port => false, 42); int port1 = portProvider.GetNextFreePort("foo"); int port2 = portProvider.GetNextFreePort("foo"); assertThat(port1, @is(not(equalTo(port2)))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldSkipOccupiedPorts() internal virtual void ShouldSkipOccupiedPorts() { PortProbe portProbe = mock(typeof(PortProbe)); PortProvider portProvider = new SimplePortProvider(portProbe, 40); when(portProbe.IsOccupied(40)).thenReturn(false); when(portProbe.IsOccupied(41)).thenReturn(false); when(portProbe.IsOccupied(42)).thenReturn(true); when(portProbe.IsOccupied(43)).thenReturn(false); assertThat(portProvider.GetNextFreePort("foo"), @is(40)); assertThat(portProvider.GetNextFreePort("foo"), @is(41)); assertThat(portProvider.GetNextFreePort("foo"), @is(43)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldNotOverRun() internal virtual void ShouldNotOverRun() { PortProvider portProvider = new SimplePortProvider(port => false, 65534); portProvider.GetNextFreePort("foo"); portProvider.GetNextFreePort("foo"); try { portProvider.GetNextFreePort("foo"); fail("Failure was expected"); } catch (System.InvalidOperationException e) { assertThat(e.Message, @is("There are no more ports available")); } }