public static void SerializeToStreamAsBinary_StreamIsNotSeekableAndSeekToPreWriteIsFalse_DoesNotThrow()
        {
            // Arrange
            var objToSerialize      = new Exception();
            var ms1                 = new CannotSeekStream();
            var ms2                 = new CannotSeekStream();
            var random              = new Random();
            int numberOfRandomBytes = random.Next(50, 10000);
            var bytes               = new byte[numberOfRandomBytes];

            random.NextBytes(bytes);
            ms2.Write(bytes, 0, bytes.Length);

            // Act
            // ReSharper disable RedundantArgumentDefaultValue
            var ex1 = Record.Exception(() => objToSerialize.SerializeToStreamAsBinary(ms1, false));
            var ex2 = Record.Exception(() => objToSerialize.SerializeToStreamAsBinary(ms2, false));

            // ReSharper restore RedundantArgumentDefaultValue

            // Assert
            Assert.Null(ex1);
            Assert.Null(ex2);

            // Cleanup
            ms1.Dispose();
            ms2.Dispose();
        }
        public static void SerializeToStreamAsBinary_SeekToPreWriteIsTrueAndStreamIsNotSeekable_ThrowsArgumentException()
        {
            // Arrange
            var objToSerialize = new Exception();
            var ms             = new CannotSeekStream();

            // Act, Assert
            Assert.Throws <ArgumentException>(() => objToSerialize.SerializeToStreamAsBinary(ms, true));
        }
        public static void DeserializeFromBinary_SeekToFirstPositionIsTrueButStreamIsNotSeekable_ThrowsArgumentException()
        {
            // Arrange
            var exception = new Exception();
            var ms        = new CannotSeekStream();

            exception.SerializeToMemoryStreamAsBinary().CopyTo(ms);

            // Act, Assert
            Assert.Throws <ArgumentException>(() => ms.DeserializeFromBinary <object>(true));

            // Cleanup
            ms.Dispose();
        }