//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void closeMustThrowIfAllThrow() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CloseMustThrowIfAllThrow() { // given IList <UncheckedIOException> failures = new List <UncheckedIOException>(); foreach (IndexPopulator alivePopulator in _alivePopulators) { UncheckedIOException failure = new UncheckedIOException(new IOException("FAILURE[" + alivePopulator + "]")); failures.Add(failure); doThrow(failure).when(alivePopulator).close(anyBoolean()); } try { // when _fusionIndexPopulator.close(anyBoolean()); fail("Should have failed"); } catch (UncheckedIOException e) { // then if (!failures.Contains(e)) { fail("Thrown exception didn't match any of the expected failures: " + failures); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: static void verifyFusionCloseThrowIfAllThrow(AutoCloseable fusionCloseable, AutoCloseable... autoCloseables) throws Exception internal static void VerifyFusionCloseThrowIfAllThrow(AutoCloseable fusionCloseable, params AutoCloseable[] autoCloseables) { // given UncheckedIOException[] failures = new UncheckedIOException[autoCloseables.Length]; for (int i = 0; i < autoCloseables.Length; i++) { failures[i] = new UncheckedIOException(new IOException("unknown")); doThrow(failures[i]).when(autoCloseables[i]).close(); } try { // when fusionCloseable.close(); fail("Should have failed"); } catch (UncheckedIOException e) { // then //JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the Java 'super' constraint: //ORIGINAL LINE: java.util.List<org.hamcrest.Matcher<? super java.io.UncheckedIOException>> matchers = new java.util.ArrayList<>(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: IList <Matcher> matchers = new List <Matcher>(); foreach (UncheckedIOException failure in failures) { matchers.Add(sameInstance(failure)); } assertThat(e, anyOf(matchers)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: static void verifyFusionCloseThrowOnSingleCloseThrow(AutoCloseable failingCloseable, AutoCloseable fusionCloseable) throws Exception internal static void VerifyFusionCloseThrowOnSingleCloseThrow(AutoCloseable failingCloseable, AutoCloseable fusionCloseable) { UncheckedIOException expectedFailure = new UncheckedIOException(new IOException("fail")); doThrow(expectedFailure).when(failingCloseable).close(); try { fusionCloseable.close(); fail("Should have failed"); } catch (UncheckedIOException e) { assertSame(expectedFailure, e); } }
private static void VerifyFailOnSingleDropFailure(IndexAccessor failingAccessor, FusionIndexAccessor fusionIndexAccessor) { UncheckedIOException expectedFailure = new UncheckedIOException(new IOException("fail")); doThrow(expectedFailure).when(failingAccessor).drop(); try { fusionIndexAccessor.Drop(); fail("Should have failed"); } catch (UncheckedIOException e) { assertSame(expectedFailure, e); } doAnswer(invocation => null).when(failingAccessor).drop(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void closeMustThrowIfCloseAnyThrow() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CloseMustThrowIfCloseAnyThrow() { foreach (IndexSlot aliveSlot in FusionVersion.aliveSlots()) { // given UncheckedIOException failure = new UncheckedIOException(new IOException("fail")); doThrow(failure).when(_populators[aliveSlot]).close(anyBoolean()); verifyCallFail(failure, () => { _fusionIndexPopulator.close(anyBoolean()); return(null); }); InitiateMocks(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void dropMustThrowIfAnyDropThrow() public virtual void DropMustThrowIfAnyDropThrow() { foreach (IndexPopulator alivePopulator in _alivePopulators) { // given UncheckedIOException failure = new UncheckedIOException(new IOException("fail")); doThrow(failure).when(alivePopulator).drop(); verifyCallFail(failure, () => { _fusionIndexPopulator.drop(); return(null); }); // reset throw for testing of next populator doAnswer(invocation => null).when(alivePopulator).drop(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: static void verifyOtherIsClosedOnSingleThrow(AutoCloseable failingCloseable, AutoCloseable fusionCloseable, AutoCloseable... successfulCloseables) throws Exception internal static void VerifyOtherIsClosedOnSingleThrow(AutoCloseable failingCloseable, AutoCloseable fusionCloseable, params AutoCloseable[] successfulCloseables) { UncheckedIOException failure = new UncheckedIOException(new IOException("fail")); doThrow(failure).when(failingCloseable).close(); // when try { fusionCloseable.close(); fail("Should have failed"); } catch (UncheckedIOException) { } // then foreach (AutoCloseable successfulCloseable in successfulCloseables) { verify(successfulCloseable, Mockito.times(1)).close(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void verifyOtherCloseOnThrow(org.neo4j.kernel.api.index.IndexPopulator throwingPopulator) throws Exception private void VerifyOtherCloseOnThrow(IndexPopulator throwingPopulator) { // given UncheckedIOException failure = new UncheckedIOException(new IOException("fail")); doThrow(failure).when(throwingPopulator).close(anyBoolean()); // when try { _fusionIndexPopulator.close(true); fail("Should have failed"); } catch (UncheckedIOException) { } // then foreach (IndexPopulator alivePopulator in _alivePopulators) { verify(alivePopulator, times(1)).close(true); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void dropMustThrowIfAllFail() public virtual void DropMustThrowIfAllFail() { // given IList <UncheckedIOException> exceptions = new List <UncheckedIOException>(); foreach (IndexAccessor indexAccessor in _aliveAccessors) { UncheckedIOException exception = new UncheckedIOException(new IOException(indexAccessor.GetType().Name + " fail")); exceptions.Add(exception); doThrow(exception).when(indexAccessor).drop(); } try { // when _fusionIndexAccessor.drop(); fail("Should have failed"); } catch (UncheckedIOException e) { // then assertThat(exceptions, hasItem(e)); } }