Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldTransformFromInputStreamToByteArray()
        public virtual void shouldTransformFromInputStreamToByteArray()
        {
            string testString  = "Test String";
            Stream inputStream = IoUtil.stringAsInputStream(testString);

            assertThat(IoUtil.inputStreamAsByteArray(inputStream)).isEqualTo(testString.GetBytes(IoUtil.ENCODING_CHARSET));
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldTransformBetweenInputStreamAndString()
        public virtual void shouldTransformBetweenInputStreamAndString()
        {
            Stream inputStream = IoUtil.stringAsInputStream("test");
            string @string     = IoUtil.inputStreamAsString(inputStream);

            assertThat(@string).isEqualTo("test");
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUseFallBackWhenCustomClassLoaderIsNull()
        public virtual void shouldUseFallBackWhenCustomClassLoaderIsNull()
        {
            File file = IoUtil.getClasspathFile(TEST_FILE_NAME, null);

            assertThat(file).NotNull;
            assertThat(file.Name).isEqualTo("testFile.txt");
        }
Exemple #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUseFallBackWhenCustomClassLoaderIsWrong()
        public virtual void shouldUseFallBackWhenCustomClassLoaderIsWrong()
        {
            File file = IoUtil.getClasspathFile(TEST_FILE_NAME, new ClassLoaderAnonymousInnerClass(this));

            assertThat(file).NotNull;
            assertThat(file.Name).isEqualTo("testFile.txt");
        }
Exemple #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getFileFromClassPath()
        public virtual void getFileFromClassPath()
        {
            File file = IoUtil.getClasspathFile(TEST_FILE_NAME);

            assertThat(file).NotNull;
            assertThat(file.Name).isEqualTo("testFile.txt");
        }
Exemple #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailGetFileContentAsStringWithGarbageAsFilename()
        public virtual void shouldFailGetFileContentAsStringWithGarbageAsFilename()
        {
            try
            {
                IoUtil.fileAsString("asd123");
                fail("Expected: IoUtilException");
            }
            catch (IoUtilException)
            {
                // happy way
            }
        }
Exemple #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailGetFileFromClassPathWithNull()
        public virtual void shouldFailGetFileFromClassPathWithNull()
        {
            try
            {
                IoUtil.getClasspathFile(null);
                fail("Expected: IoUtilException");
            }
            catch (IoUtilException)
            {
                // happy way
            }
        }
Exemple #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldTransformFromStringToInputStreamToByteArray()
        public virtual void shouldTransformFromStringToInputStreamToByteArray()
        {
            string testString  = "Test String";
            Stream inputStream = IoUtil.stringAsInputStream(testString);

            string newString = IoUtil.inputStreamAsString(inputStream);

            assertThat(testString).isEqualTo(newString);

            inputStream = IoUtil.stringAsInputStream(testString);
            sbyte[] newBytes = newString.GetBytes(IoUtil.ENCODING_CHARSET);
            assertThat(IoUtil.inputStreamAsByteArray(inputStream)).isEqualTo(newBytes);
        }
Exemple #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getFileContentAsStream()
        public virtual void getFileContentAsStream()
        {
            Stream        stream = IoUtil.fileAsStream(TEST_FILE_NAME);
            StreamReader  reader = new StreamReader(stream);
            StringBuilder output = new StringBuilder();
            string        line;

            try
            {
                while (!string.ReferenceEquals((line = reader.ReadLine()), null))
                {
                    output.Append(line);
                }
                assertThat(output.ToString()).isEqualTo("This is a Test!");
            }
            catch (Exception)
            {
                fail("Something went wrong while reading the input stream");
            }
        }
Exemple #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getFileContentAsString()
        public virtual void getFileContentAsString()
        {
            assertThat(IoUtil.fileAsString(TEST_FILE_NAME)).isEqualTo("This is a Test!");
        }