コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRecoverIfCrashedDuringMove() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRecoverIfCrashedDuringMove()
        {
            // Given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.IOException exception = new java.io.IOException("simulated IO Exception on create");
            IOException           exception          = new IOException("simulated IO Exception on create");
            FileSystemAbstraction crashingFileSystem = new DelegatingFileSystemAbstractionAnonymousInnerClass(this, _fs, exception);

            FileUserRepository users = new FileUserRepository(crashingFileSystem, _authFile, _logProvider);

            users.Start();
            User user = (new User.Builder("jake", LegacyCredential.Inaccessible)).withRequiredPasswordChange(true).build();

            // When
            try
            {
                users.Create(user);
                fail("Expected an IOException");
            }
            catch (IOException e)
            {
                assertSame(exception, e);
            }

            // Then
            assertFalse(crashingFileSystem.FileExists(_authFile));
            assertThat(crashingFileSystem.ListFiles(_authFile.ParentFile).Length, equalTo(0));
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRecoverIfCrashedDuringMove() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRecoverIfCrashedDuringMove()
        {
            // Given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.IOException exception = new java.io.IOException("simulated IO Exception on create");
            IOException           exception          = new IOException("simulated IO Exception on create");
            FileSystemAbstraction crashingFileSystem = new DelegatingFileSystemAbstractionAnonymousInnerClass(this, _fs, exception);

            _roleRepository = new FileRoleRepository(crashingFileSystem, _roleFile, _logProvider);
            _roleRepository.start();
            RoleRecord role = new RoleRecord("admin", "jake");

            // When
            try
            {
                _roleRepository.create(role);
                fail("Expected an IOException");
            }
            catch (IOException e)
            {
                assertSame(exception, e);
            }

            // Then
            assertFalse(crashingFileSystem.FileExists(_roleFile));
            assertThat(crashingFileSystem.ListFiles(_roleFile.ParentFile).Length, equalTo(0));
        }