Example #1
0
        public void FileResourceImporter_WhenImporting_ExpectStreamPositionAtBeginning()
        {
            const string filePath = "eightbytes.bin";

            var sut = new FileResourceImporter <MemoryStream>(new FileResourceService());

            var stream = sut.Import(filePath);

            Assert.IsTrue(stream.Position == 0);
        }
Example #2
0
        public void FileResourceImporter_WhenImporting_ExpectStreamLengthToMatchFileLength()
        {
            const string filePath = "eightbytes.bin";

            var sut = new FileResourceImporter <MemoryStream>(new FileResourceService());

            var stream = sut.Import(filePath);

            Assert.IsTrue(stream.Length == _eightBytes.Length);
        }
Example #3
0
        public void FileResourceImporter_WhenImporting_ExpectStreamByteSequenceToMatchFileByteSequence()
        {
            const string filePath = "eightbytes.bin";

            var sut = new FileResourceImporter <MemoryStream>(new FileResourceService());

            var stream = sut.Import(filePath);

            var buffer = new byte[_eightBytes.Length];
            var _      = stream.Read(buffer, 0, _eightBytes.Length);

            Assert.IsTrue(_eightBytes.SequenceEqual(buffer));
        }
Example #4
0
        public void FileResourceExporter_WhenExportingSmallerStream_ExpectFileLengthToMatchStreamLength()
        {
            const string filePath = "eightbytes.bin";

            var sut = new FileResourceExporter <MemoryStream>(new FileResourceService());

            using (var stream = new MemoryStream(_fourBytes))
            {
                sut.Export(stream, filePath);
            }

            var importer = new FileResourceImporter <MemoryStream>(new FileResourceService());
            var result   = importer.Import(filePath);

            Assert.IsTrue(result.Length == _fourBytes.Length);
        }
Example #5
0
        public void FileResourceExporter_WhenExportingSmallerStream_ExpectFileByteSequenceToMatchStreamByteSequence()
        {
            const string filePath = "eightbytes.bin";

            var sut = new FileResourceExporter <MemoryStream>(new FileResourceService());

            using (var stream = new MemoryStream(_fourBytes))
            {
                sut.Export(stream, filePath);
            }

            var importer = new FileResourceImporter <MemoryStream>(new FileResourceService());
            var result   = importer.Import(filePath);
            var buffer   = new byte[_fourBytes.Length];
            var _        = result.Read(buffer, 0, _fourBytes.Length);

            Assert.IsTrue(_fourBytes.SequenceEqual(buffer));
        }
Example #6
0
        public void FileResourceImporter_WhenImportingAndFilePathIsWhitespace_ExpectArgumentException()
        {
            var sut = new FileResourceImporter <MemoryStream>(new StubIFileResourceService());

            var _ = sut.Import(" ");
        }
Example #7
0
        public void FileResourceImporter_WhenImportingAndFilePathIsEmpty_ExpectArgumentException()
        {
            var sut = new FileResourceImporter <MemoryStream>(new StubIFileResourceService());

            var _ = sut.Import(string.Empty);
        }