//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReservePorts() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldReservePorts() { PortRepository portRepository1 = new PortRepository(TemporaryDirectory(), EphemeralPortMinimum); int port1 = portRepository1.ReserveNextPort("foo"); int port2 = portRepository1.ReserveNextPort("foo"); int port3 = portRepository1.ReserveNextPort("foo"); assertThat((new HashSet <>(asList(port1, port2, port3))).Count, @is(3)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldCoordinateUsingFileSystem() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldCoordinateUsingFileSystem() { Path temporaryDirectory = temporaryDirectory(); PortRepository portRepository1 = new PortRepository(temporaryDirectory, EphemeralPortMinimum); PortRepository portRepository2 = new PortRepository(temporaryDirectory, EphemeralPortMinimum); int port1 = portRepository1.ReserveNextPort("foo"); int port2 = portRepository1.ReserveNextPort("foo"); int port3 = portRepository1.ReserveNextPort("foo"); int port4 = portRepository2.ReserveNextPort("foo"); int port5 = portRepository2.ReserveNextPort("foo"); int port6 = portRepository1.ReserveNextPort("foo"); assertThat((new HashSet <>(asList(port1, port2, port3, port4, port5, port6))).Count, @is(6)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldNotOverrun() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldNotOverrun() { PortRepository portRepository1 = new PortRepository(TemporaryDirectory(), 65534); portRepository1.ReserveNextPort("foo"); portRepository1.ReserveNextPort("foo"); try { portRepository1.ReserveNextPort("foo"); fail("Failure was expected"); } catch (System.InvalidOperationException e) { assertThat(e.Message, @is("There are no more ports available")); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldSkipReservedPorts() internal virtual void ShouldSkipReservedPorts() { PortRepository portRepository = mock(typeof(PortRepository)); PortProvider portProvider = new CoordinatingPortProvider(portRepository, port => false); when(portRepository.ReserveNextPort("foo")).thenReturn(40, 41, 43); 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 shouldProvideUniquePorts() internal virtual void ShouldProvideUniquePorts() { PortRepository portRepository = mock(typeof(PortRepository)); PortProvider portProvider = new CoordinatingPortProvider(portRepository, port => false); when(portRepository.ReserveNextPort("foo")).thenReturn(40, 41); int port1 = portProvider.GetNextFreePort("foo"); int port2 = portProvider.GetNextFreePort("foo"); assertThat(port1, @is(not(equalTo(port2)))); }