Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void provideSelectiveWatcher() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ProvideSelectiveWatcher()
        {
            File specialFile = new File("special");
            File otherFile   = new File("other");

            FileSystemAbstraction normal  = mock(typeof(FileSystemAbstraction));
            FileSystemAbstraction special = mock(typeof(FileSystemAbstraction));

            FileWatcher     specialWatcher  = mock(typeof(FileWatcher));
            FileWatcher     normalWatcher   = mock(typeof(FileWatcher));
            WatchedResource specialResource = mock(typeof(WatchedResource));
            WatchedResource normalResource  = mock(typeof(WatchedResource));

            when(special.FileWatcher()).thenReturn(specialWatcher);
            when(normal.FileWatcher()).thenReturn(normalWatcher);
            when(specialWatcher.Watch(specialFile)).thenReturn(specialResource);
            when(normalWatcher.Watch(otherFile)).thenReturn(normalResource);

            using (SelectiveFileSystemAbstraction fs = new SelectiveFileSystemAbstraction(specialFile, special, normal))
            {
                FileWatcher fileWatcher = fs.FileWatcher();
                assertSame(specialResource, fileWatcher.Watch(specialFile));
                assertSame(normalResource, fileWatcher.Watch(otherFile));
            }
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldUseCorrectFileSystemForChosenFile() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldUseCorrectFileSystemForChosenFile()
        {
            // given
            File specialFile              = new File("special");
            FileSystemAbstraction normal  = mock(typeof(FileSystemAbstraction));
            FileSystemAbstraction special = mock(typeof(FileSystemAbstraction));

            // when
            using (SelectiveFileSystemAbstraction systemAbstraction = new SelectiveFileSystemAbstraction(specialFile, special, normal))
            {
                systemAbstraction.Open(specialFile, OpenMode.Read);

                // then
                verify(special).open(specialFile, OpenMode.Read);
                verifyNoMoreInteractions(special);
                verifyNoMoreInteractions(normal);
            }
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldUseDefaultFileSystemForOtherFiles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldUseDefaultFileSystemForOtherFiles()
        {
            // given
            File specialFile = new File("special");
            File otherFile   = new File("other");

            FileSystemAbstraction normal  = mock(typeof(FileSystemAbstraction));
            FileSystemAbstraction special = mock(typeof(FileSystemAbstraction));

            // when
            using (SelectiveFileSystemAbstraction fs = new SelectiveFileSystemAbstraction(specialFile, special, normal))
            {
                fs.Create(otherFile);
                fs.Open(otherFile, OpenMode.Read);

                // then
                verify(normal).create(otherFile);
                verify(normal).open(otherFile, OpenMode.Read);
                verifyNoMoreInteractions(special);
                verifyNoMoreInteractions(normal);
            }
        }