public void CopyData_NonReadableSource_ThrowsNotSupportedException()
        {
            var sourceStream      = CreateFakeWriteOnlyStream();
            var destinationStream = CreateFakeWriteOnlyStream();

            void copyAction()
            {
                _ = StreamCopyDataExtensions.CopyData(sourceStream, destinationStream, 1);
            }

            _ = Assert.Throws <NotSupportedException>(copyAction);
        }
        public void CopyData_CorrectArguments_CopiesData(byte[] sourceArray, long copyLimit,
                                                         long expectedCopyCount, byte[] expectedDestinationArray)
        {
            using var sourceStream      = new MemoryStream(sourceArray, false);
            using var destinationStream = new MemoryStream();

            var copyCount        = StreamCopyDataExtensions.CopyData(sourceStream, destinationStream, copyLimit);
            var destinationArray = destinationStream.ToArray();

            Assert.Equal(expectedCopyCount, copyCount);
            Assert.Equal(expectedDestinationArray, destinationArray);
        }
        public void CopyData_NullDestination_ThrowsArgumentNullException()
        {
            var sourceStream      = CreateFakeReadOnlyStream();
            var destinationStream = CreateNullStream();

            void copyAction()
            {
                _ = StreamCopyDataExtensions.CopyData(sourceStream, destinationStream, 1);
            }

            _ = Assert.Throws <ArgumentNullException>(copyAction);
        }
        public void CopyData_ZeroNegativeBufferSize_ThrowsArgumentOutOfRangeException(int bufferSize)
        {
            var sourceStream      = CreateFakeReadOnlyStream();
            var destinationStream = CreateFakeWriteOnlyStream();

            void copyAction()
            {
                _ = StreamCopyDataExtensions.CopyData(sourceStream, destinationStream, bufferSize);
            }

            _ = Assert.Throws <ArgumentOutOfRangeException>(copyAction);
        }