Esempio n. 1
0
        public void ReadFromStream_FileStreamWithText_StringIsFilledWithTheText()
        {
            // Arrange
            const string filePath = "temp.txt";
            const string fileText = "Hello world and everyone here!";

            File.WriteAllText(filePath, fileText);
            var myString = new MyString.MyString();

            // Act
            using (var fsa = new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                myString.ReadFromStream(fsa);
            }

            File.Delete(filePath);

            // Assert
            Assert.Equal(fileText, myString);
        }
Esempio n. 2
0
        public void ReadFromStream_FileStreamWithWhiteSpaces_StringIsFilledWithWhiteSpaces()
        {
            // Arrange
            const string filePath = "temp.txt";
            const string fileText = "            ";

            File.WriteAllText(filePath, fileText);
            var myString = new MyString.MyString("Hello");

            // Act
            using (var fsa = new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                myString.ReadFromStream(fsa);
            }

            File.Delete(filePath);

            // Assert
            Assert.Equal(fileText.Length, myString.Length);
            Assert.Equal(fileText, myString);
        }