Exemplo n.º 1
0
        public void FileSystem_NonexistingFileIsRead_ExceptionIsThrown()
        {
            var fileSystem = Substitute.For <IFileSystem>();

            fileSystem.File.ReadAllBytes(Arg.Any <string>()).Returns(x => throw new FileNotFoundException());

            IDataReader reader = new FileSystemDataReader(fileSystem);

            Action act = () => reader.ReadAllBytes(@"C:\test.txt");

            act.Should().Throw <FileNotFoundException>();
        }
Exemplo n.º 2
0
        public void FileSystem_ExistingFileIsRead_FileContentIsReturned()
        {
            var fileSystem = Substitute.For <IFileSystem>();

            fileSystem.File.ReadAllBytes(@"C:\test.txt").Returns(new byte[] { 1, 2, 3 });

            IDataReader reader = new FileSystemDataReader(fileSystem);

            byte[] actual = reader.ReadAllBytes(@"C:\test.txt");

            actual.Should().BeEquivalentTo(new byte[] { 1, 2, 3 });
        }