//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDetectAndThrowIOExceptionOnPartiallyCreatedFile() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDetectAndThrowIOExceptionOnPartiallyCreatedFile() { // given a crashed-on-open index File file = Storage.directory().file("index"); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: Process process = (new ProcessBuilder(asList("java", "-cp", System.getProperty("java.class.path"), this.GetType().FullName, file.AbsolutePath))).redirectError(INHERIT).redirectOutput(INHERIT).start(); Thread.Sleep(ThreadLocalRandom.current().Next(1_000)); int exitCode = process.destroyForcibly().waitFor(); // then reading it should either work or throw IOException using (PageCache pageCache = Storage.pageCache()) { SimpleLongLayout layout = longLayout().build(); // check readHeader try { GBPTree.ReadHeader(pageCache, file, NO_HEADER_READER); } catch (Exception e) when(e is MetadataMismatchException || e is IOException) { // It's OK if the process was destroyed assertNotEquals(0, exitCode); } // check constructor try { (new GBPTreeBuilder <>(pageCache, file, layout)).Build().Dispose(); } catch (Exception e) when(e is MetadataMismatchException || e is IOException) { // It's OK if the process was destroyed assertNotEquals(0, exitCode); } } }